Skip to content

Instantly share code, notes, and snippets.

@AitorAlejandro
Created March 11, 2022 10:09
Show Gist options
  • Save AitorAlejandro/2789ebe294ab358b564e6c3ae0a64915 to your computer and use it in GitHub Desktop.
Save AitorAlejandro/2789ebe294ab358b564e6c3ae0a64915 to your computer and use it in GitHub Desktop.
Converts a snake string to camel string
const snakeToCamel = (s: string): string => s.toLowerCase().replace(/(_\w)/g, (w) => w.toUpperCase().substring(1));
snakeToCamel('foo_bar'); // -> fooBar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment