mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-07 04:23:40 +09:00
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
15 lines
420 B
TypeScript
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;
|
|
};
|