mirror of
https://github.com/swc-project/swc.git
synced 2024-12-20 20:22:26 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
23 lines
474 B
TypeScript
23 lines
474 B
TypeScript
// Loaded from https://deno.land/x/case@v2.1.0/swapCase.ts
|
|
|
|
|
|
import upperCase from "./upperCase.ts";
|
|
import lowerCase from "./lowerCase.ts";
|
|
|
|
export default function (str: string, locale?: string): string {
|
|
if (str == null) {
|
|
return "";
|
|
}
|
|
|
|
let result: string = "";
|
|
|
|
for (let i: number = 0; i < str.length; i++) {
|
|
const c: string = str[i];
|
|
const u: string = upperCase(c, locale);
|
|
|
|
result += u === c ? lowerCase(c, locale) : u;
|
|
}
|
|
|
|
return result;
|
|
}
|