mirror of
https://github.com/swc-project/swc.git
synced 2024-12-30 00:52:29 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
24 lines
613 B
TypeScript
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);
|
|
});
|
|
}
|