Browse Source

feat: add toCameCase to strings utils.

pull/928/head
unknown 2 years ago
parent
commit
34383439e0
  1. 12
      apps/vue/src/utils/strings.ts

12
apps/vue/src/utils/strings.ts

@ -20,6 +20,18 @@ export function format(formatted: string, args: object | any[]) {
}
return formatted;
}
/**
*
* @param str
* @returns
* @example toCamelCase('hello-world') => helloWorld
* @example toCamelCase('my_variable_name') => myVariableName
*/
export function toCamelCase(str: string) {
return str.replace(/[-_\s](\w)/g, function (_, c) {
return c ? c.toUpperCase() : '';
});
}
/**
*
* @param str

Loading…
Cancel
Save