swc/crates/swc_bundler/tests/.cache/deno/90704641c81576d268079355a67d613274b7d7a3.ts
2021-11-09 20:42:49 +09:00

24 lines
613 B
TypeScript

// Loaded from https://deno.land/x/case/camelCase.ts
import upperCase from "./upperCase.ts";
import normalCase from "./normalCase.ts";
export default function camelCase(
value: string,
locale?: string,
mergeNumbers?: boolean,
): string {
let result = normalCase(value, locale);
// Replace periods between numeric entities with an underscore.
if (!mergeNumbers) {
result = result.replace(/ (?=\d)/g, "_");
}
// Replace spaces between words with an upper cased character.
return result.replace(/ (.)/g, function (m: string, $1: string): string {
return upperCase($1, locale);
});
}