{"id":13410818,"url":"https://github.com/sindresorhus/camelcase","last_synced_at":"2025-05-14T05:10:47.210Z","repository":{"id":21794335,"uuid":"25116836","full_name":"sindresorhus/camelcase","owner":"sindresorhus","description":"Convert a dash/dot/underscore/space separated string to camelCase: foo-bar → fooBar","archived":false,"fork":false,"pushed_at":"2023-09-29T06:30:04.000Z","size":79,"stargazers_count":692,"open_issues_count":2,"forks_count":97,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-05-07T18:24:03.543Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2014-10-12T10:58:21.000Z","updated_at":"2025-04-27T03:29:55.000Z","dependencies_parsed_at":"2023-09-27T09:48:48.376Z","dependency_job_id":"fd97e162-0c67-4111-9fbc-e05e76ff16c2","html_url":"https://github.com/sindresorhus/camelcase","commit_stats":{"total_commits":94,"total_committers":29,"mean_commits":"3.2413793103448274","dds":0.3936170212765957,"last_synced_commit":"2f1e273fc50281098d99627fef0853aa431139b5"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fcamelcase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fcamelcase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fcamelcase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fcamelcase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/camelcase/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253673123,"owners_count":21945549,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:09.521Z","updated_at":"2025-05-14T05:10:47.126Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Packages","Repository","包","目录","JavaScript","Text"],"sub_categories":["Text","Text/String","文本","文本处理"],"readme":"# camelcase\n\n\u003e Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`\n\nCorrectly handles Unicode strings.\n\nIf you use this on untrusted user input, don't forget to limit the length to something reasonable.\n\n## Install\n\n```sh\nnpm install camelcase\n```\n\n## Usage\n\n```js\nimport camelCase from 'camelcase';\n\ncamelCase('foo-bar');\n//=\u003e 'fooBar'\n\ncamelCase('foo_bar');\n//=\u003e 'fooBar'\n\ncamelCase('Foo-Bar');\n//=\u003e 'fooBar'\n\ncamelCase('розовый_пушистый_единорог');\n//=\u003e 'розовыйПушистыйЕдинорог'\n\ncamelCase('foo bar');\n//=\u003e 'fooBar'\n\nconsole.log(process.argv[3]);\n//=\u003e '--foo-bar'\ncamelCase(process.argv[3]);\n//=\u003e 'fooBar'\n\ncamelCase(['foo', 'bar']);\n//=\u003e 'fooBar'\n\ncamelCase(['__foo__', '--bar']);\n//=\u003e 'fooBar'\n```\n\n## API\n\n### camelCase(input, options?)\n\n#### input\n\nType: `string | string[]`\n\nThe string to convert to camel case.\n\n#### options\n\nType: `object`\n\n##### pascalCase\n\nType: `boolean`\\\nDefault: `false`\n\nUppercase the first character: `foo-bar` → `FooBar`\n\n```js\nimport camelCase from 'camelcase';\n\ncamelCase('foo-bar', {pascalCase: true});\n//=\u003e 'FooBar'\n\ncamelCase('foo-bar', {pascalCase: false});\n//=\u003e 'fooBar'\n```\n\n##### preserveConsecutiveUppercase\n\nType: `boolean`\\\nDefault: `false`\n\nPreserve consecutive uppercase characters: `foo-BAR` → `FooBAR`\n\n```js\nimport camelCase from 'camelcase';\n\ncamelCase('foo-BAR', {preserveConsecutiveUppercase: true});\n//=\u003e 'fooBAR'\n\ncamelCase('foo-BAR', {preserveConsecutiveUppercase: false});\n//=\u003e 'fooBar'\n````\n\n##### locale\n\nType: `false | string | string[]`\\\nDefault: The host environment’s current locale.\n\nThe locale parameter indicates the locale to be used to convert to upper/lower case according to any locale-specific case mappings. If multiple locales are given in an array, the best available locale is used.\n\n```js\nimport camelCase from 'camelcase';\n\ncamelCase('lorem-ipsum', {locale: 'en-US'});\n//=\u003e 'loremIpsum'\n\ncamelCase('lorem-ipsum', {locale: 'tr-TR'});\n//=\u003e 'loremİpsum'\n\ncamelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']});\n//=\u003e 'loremIpsum'\n\ncamelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});\n//=\u003e 'loremİpsum'\n```\n\nSetting `locale: false` ignores the platform locale and uses the [Unicode Default Case Conversion](https://unicode-org.github.io/icu/userguide/transforms/casemappings.html#simple-single-character-case-mapping) algorithm:\n\n```js\nimport camelCase from 'camelcase';\n\n// On a platform with `tr-TR`.\n\ncamelCase('lorem-ipsum');\n//=\u003e 'loremİpsum'\n\ncamelCase('lorem-ipsum', {locale: false});\n//=\u003e 'loremIpsum'\n```\n\n## Related\n\n- [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module\n- [titleize](https://github.com/sindresorhus/titleize) - Capitalize every word in string\n- [humanize-string](https://github.com/sindresorhus/humanize-string) - Convert a camelized/dasherized/underscored string into a humanized one\n- [camelcase-keys](https://github.com/sindresorhus/camelcase-keys) - Convert object keys to camel case\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fcamelcase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fcamelcase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fcamelcase/lists"}