TreasureTrails/node_modules/remeda/dist/toCamelCase.cjs.map

1 line
6.6 KiB
Text
Raw Normal View History

2026-03-18 09:02:21 -05:00
{"version":3,"file":"toCamelCase.cjs","names":["words"],"sources":["../src/toCamelCase.ts"],"sourcesContent":["import type { CamelCase } from \"type-fest\";\nimport type { OptionalOptionsWithDefaults } from \"./internal/types/OptionalOptionsWithDefaults\";\nimport { words } from \"./internal/words\";\n\nconst LOWER_CASE_CHARACTER_RE = /[a-z]/u;\n\nconst DEFAULT_PRESERVE_CONSECUTIVE_UPPERCASE = true;\n\ntype CamelCaseOptions = {\n readonly preserveConsecutiveUppercase?: boolean;\n};\n\ntype CamelCaseOptionsWithDefaults<Options extends CamelCaseOptions> =\n OptionalOptionsWithDefaults<\n CamelCaseOptions,\n Options,\n {\n // We use the runtime const for the default type so they stay coupled.\n preserveConsecutiveUppercase: typeof DEFAULT_PRESERVE_CONSECUTIVE_UPPERCASE;\n }\n >;\n\n/**\n * Converts text to **camelCase** by splitting it into words, lowercasing the\n * first word, capitalizing the rest, then joining them back together.\n *\n * Because it uses the built-in case conversion methods, the function shares\n * their _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_\n * too, making it best suited for simple strings like identifiers and internal\n * keys. For linguistic text processing, use [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)\n * with [`granularity: \"word\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#parameters),\n * [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * and [`toLocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)\n * which are purpose-built to handle nuances in languages and locales.\n *\n * For other case manipulations see: `toLowerCase`, `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toKebabCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * For *PascalCase* use `capitalize(toCamelCase(data))`.\n *\n * @param data - A string.\n * @param options - An _optional_ object with the _optional_ property\n * `preserveConsecutiveUppercase` that can be used to change the way consecutive\n * uppercase characters are handled. Defaults to `true`.\n * @signature\n * R.toCamelCase(data);\n * R.toCamelCase(data, { preserveConsecutiveUppercase });\n * @example\n * R.toCamelCase(\"hello world\"); // \"helloWorld\"\n * R.toCamelCase(\"__HELLO_WORLD__\"); // \"helloWorld\"\n * R.toCamelCase(\"HasHTML\"); // \"hasHTML\"\n * R.toCamelCase(\"HasHTML\", { preserveConsecutiveUppercase: false }); // \"hasHtml\"\n * @dataFirst\n * @category String\n */\nexport function toCamelCase<T extends string, Options extends CamelCaseOptions>(\n data: T,\n options?: Options,\n): CamelCase<T, CamelCaseOptionsWithDefaults<Options>>;\n\n/**\n * Converts text to **camelCase** by splitting it into words, lowercasing the\n * first word, capitalizing the rest, then joining them back together.\n *\n * Because it uses the built-in case conversion methods, the function shares\n * their _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_\n * too, making it best suited for simple strings like identifiers and internal\n * keys. For linguistic text processing, use [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)\n * with [`granularity: \"word\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#parameters),\n * [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * and [`toLocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)\n * which are purpose-built to handle nuances in languages and loc