remeda
Version:
A utility library for JavaScript and Typescript.
1 lines • 3.37 kB
Source Map (JSON)
{"version":3,"file":"uncapitalize.cjs","names":["purry"],"sources":["../src/uncapitalize.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Makes the first character of a string lowercase while leaving the rest\n * unchanged.\n *\n * It uses the built-in [`String.prototype.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)\n * for the runtime and the built-in [`Uncapitalize`](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html#Uncapitalizestringtype)\n * utility type for typing and thus shares their _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_.\n *\n * For display purposes, prefer using the CSS pseudo-element [`::first-letter`](https://developer.mozilla.org/en-US/docs/Web/CSS/::first-letter) to target\n * just the first letter of the word, and [`text-transform: lowercase`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform#lowercase)\n * to lowercase it. This transformation **is** locale-aware.\n *\n * For other case manipulations see: `toUpperCase`, `toLowerCase`, `capitalize`,\n * `toCamelCase`, `toKebabCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * @param data - A string.\n * @signature\n * R.uncapitalize(data);\n * @example\n * R.uncapitalize(\"HELLO WORLD\"); // \"hELLO WORLD\"\n * @dataFirst\n * @category String\n */\nexport function uncapitalize<T extends string>(data: T): Uncapitalize<T>;\n\n/**\n * Makes the first character of a string lowercase while leaving the rest\n * unchanged.\n *\n * It uses the built-in [`String.prototype.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)\n * for the runtime and the built-in [`Uncapitalize`](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html#Uncapitalizestringtype)\n * utility type for typing and thus shares their _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_.\n *\n * For display purposes, prefer using the CSS pseudo-element [`::first-letter`](https://developer.mozilla.org/en-US/docs/Web/CSS/::first-letter) to target\n * just the first letter of the word, and [`text-transform: lowercase`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform#lowercase)\n * to lowercase it. This transformation **is** locale-aware.\n *\n * For other case manipulations see: `toUpperCase`, `toLowerCase`, `capitalize`,\n * `toCamelCase`, `toKebabCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * @signature\n * R.uncapitalize()(data);\n * @example\n * R.pipe(\"HELLO WORLD\", R.uncapitalize()); // \"hELLO WORLD\"\n * @dataLast\n * @category String\n */\nexport function uncapitalize(): <T extends string>(data: T) => Uncapitalize<T>;\n\nexport function uncapitalize(...args: ReadonlyArray<unknown>): unknown {\n return purry(uncapitalizeImplementation, args);\n}\n\nconst uncapitalizeImplementation = <T extends string>(\n data: T,\n): Uncapitalize<T> =>\n `${data[0]?.toLowerCase() ?? \"\"}${data.slice(1)}` as Uncapitalize<T>;\n"],"mappings":"wCAmDA,SAAgB,EAAa,GAAG,EAAuC,CACrE,OAAOA,EAAAA,EAAM,EAA4B,EAAK,CAGhD,MAAM,EACJ,GAEA,GAAG,EAAK,IAAI,aAAa,EAAI,KAAK,EAAK,MAAM,EAAE"}