Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 30x 24x 60x | const toCamelCase = (str) => (
// First split string on any capital letters
str.split(/(?=[A-Z])/).join(' ')
// Remove all non alpha-numeric chars, and replace _ with ' '
.replace(/[_]/gi, ' ')
.replace(/[^0-9a-zA-Z\s]/gi, '')
// CamelCase the remains
.replace(/(?:^\w|[A-Z]|\b\w)/g, (ltr, idx) => (idx === 0 ?
ltr.toLowerCase() :
ltr.toUpperCase()))
.replace(/\s+/g, '')
);
export default toCamelCase;
|