Files
webstudio/apps/builder/app/shared/string-utils.ts
T
Bogdan Chadkin f08fe859bb refactor: bump change-case (#2428)
Ref https://github.com/blakeembrey/change-case/releases

Change case in last major merged many packages into one to simplify
maintaining and usage. A few packages like title-case are still separate
as more rare case.

- replaced no-case with change-case (merged into change-case)
- replaced param-case with change-case (merged into change-case and
renamed to kebab (finally))
- replaced camelcase with change-case (has own camelcase utility)
- bumped title-case
2023-10-08 01:03:59 +04:00

15 lines
420 B
TypeScript

import { noCase } from "change-case";
import { titleCase } from "title-case";
// Initialize the cache with abbreviations that don't follow the title case rules.
const cache: Map<string, string> = new Map([
["id", "ID"],
["url", "URL"],
]);
export const humanizeString = (string: string): string => {
const result = cache.get(string) ?? titleCase(noCase(string));
cache.set(string, result);
return result;
};