{"id":17448343,"url":"https://github.com/mesqueeb/case-anything","last_synced_at":"2025-04-14T08:56:11.078Z","repository":{"id":35142240,"uuid":"212220260","full_name":"mesqueeb/case-anything","owner":"mesqueeb","description":"camelCase, kebab-case, PascalCase... a simple integration with nano package size. (SMALL footprint!)","archived":false,"fork":false,"pushed_at":"2025-02-19T19:07:58.000Z","size":2132,"stargazers_count":104,"open_issues_count":8,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T02:06:58.200Z","etag":null,"topics":["camel","camel-case","case-change","casing-change","change-case","change-casing","constant","constant-case","format-string","kebab","kebab-case","pascal","pascal-case","path","path-case","snake","snake-case"],"latest_commit_sha":null,"homepage":"https://github.com/sponsors/mesqueeb","language":"TypeScript","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/mesqueeb.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"mesqueeb","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2019-10-01T23:45:41.000Z","updated_at":"2025-03-17T22:53:00.000Z","dependencies_parsed_at":"2024-06-05T01:30:47.270Z","dependency_job_id":"df84054e-38ee-4cba-b7da-7c133546c58a","html_url":"https://github.com/mesqueeb/case-anything","commit_stats":{"total_commits":141,"total_committers":4,"mean_commits":35.25,"dds":0.5460992907801419,"last_synced_commit":"0a6c36b3603bb934698eabf5853600f6a6a35c97"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2Fcase-anything","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2Fcase-anything/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2Fcase-anything/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2Fcase-anything/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mesqueeb","download_url":"https://codeload.github.com/mesqueeb/case-anything/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852112,"owners_count":21171839,"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":["camel","camel-case","case-change","casing-change","change-case","change-casing","constant","constant-case","format-string","kebab","kebab-case","pascal","pascal-case","path","path-case","snake","snake-case"],"created_at":"2024-10-17T20:07:07.763Z","updated_at":"2025-04-14T08:56:11.057Z","avatar_url":"https://github.com/mesqueeb.png","language":"TypeScript","readme":"# Case anything 🐫\n\n\u003ca href=\"https://www.npmjs.com/package/case-anything\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/case-anything.svg\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/case-anything\"\u003e\u003cimg src=\"https://img.shields.io/npm/dw/case-anything.svg\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\n```sh\n# npm\nnpm i case-anything\n\n# deno\ndeno add jsr:@mesqueeb/case-anything\n\n# jsr (use any of npx, yarn dlx, pnpm dlx, or bunx)\nnpx jsr add @mesqueeb/case-anything\n```\n\n14 case changing functions: camelCase, kebab-case, PascalCase **and more**...\u003cbr /\u003e\nA simple integration with nano package size. (SMALL footprint!)\n\n## Motivation\n\nI created this package because most other packages that do simple case changing are so big...\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n      \u003cp\u003eSome features I focused on:\u003c/p\u003e\n      \u003cli\u003esmall footprint (it's \u003ca href=\"#package-size\"\u003e12+ times smaller\u003c/a\u003e than the next popular case changing package!!)\u003c/li\u003e\n      \u003cli\u003etree-shakable — only import what you need\u003c/li\u003e\n      \u003cli\u003eawesome JSDocs popup documentation on hover\u003c/li\u003e\n      \u003cli\u003efully typed with TypeScript\u003c/li\u003e\n      \u003cli\u003ecomplete coverage with unit testing\u003c/li\u003e\n      \u003cli\u003e0 dependencies\u003c/li\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003cp\u003eCase anything is used in...\u003c/p\u003e\n      \u003cli\u003eFamous Mac app \u003ca href=\"https://pilotmoon.com/popclip\"\u003ePopclip 💊\u003c/a\u003e\u003c/li\u003e\n      \u003cli\u003eState Management Library \u003ca href=\"https://github.com/cycraft/magnetar\"\u003eMagnetar 🌟\u003c/a\u003e\u003c/li\u003e\n      \u003cli\u003eVue Form Generator \u003ca href=\"https://github.com/cycraft/blitzar\"\u003eBlitzar ⚡️\u003c/a\u003e\u003c/li\u003e\n      \u003cli\u003e\u003ca href=\"https://github.com/apideck-libraries/portman\"\u003eLottie-player ∫\u003c/a\u003e\u003c/li\u003e\n      \u003cli\u003eOpenAPI CLI \u003ca href=\"https://github.com/apideck-libraries/portman\"\u003ePortman 👨🏽‍🚀\u003c/a\u003e\u003c/li\u003e\n      \u003cli\u003eand \u003ca href=\"https://github.com/mesqueeb/case-anything/network/dependents\"\u003e100s more\u003c/a\u003e...\u003c/li\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## Usage\n\ncase-anything supports tree-shaking and is side-effect free!\n\n```js\n// just import the functions you need like so:\nimport { camelCase, kebabCase } from 'case-anything'\n```\n\ncase-anything has different behaviour if the string you pass has spaces or not.\n\n- Without spaces it will split and format on every \"part\" it can detect\n- With spaces it will split and format on every \"word\" based on those spaces\n\n### Strings without spaces\n\n| Name                              | Input example                                            | Output example |\n| --------------------------------- | -------------------------------------------------------- | -------------- |\n| 🐪 camelCase                      | `camelCase('$catDog')`                                   | `catDog`       |\n| 🐫 PascalCase\u003cbr /\u003eUpperCamelCase | `pascalCase('$catDog')`\u003cbr /\u003e`upperCamelCase('$catDog')` | `CatDog`       |\n| 🥙 kebab-case                     | `kebabCase('$catDog')`                                   | `cat-dog`      |\n| 🐍 snake_case                     | `snakeCase('$catDog')`                                   | `cat_dog`      |\n| 📣 CONSTANT_CASE                  | `constantCase('$catDog')`                                | `CAT_DOG`      |\n| 🚂 Train-Case                     | `trainCase('$catDog')`                                   | `Cat-Dog`      |\n| 🕊 Ada_Case                       | `adaCase('$catDog')`                                     | `Cat_Dog`      |\n| 👔 COBOL-CASE                     | `cobolCase('$catDog')`                                   | `CAT-DOG`      |\n| 📍 Dot.notation                   | `dotNotation('$catDog')`                                 | `cat.Dog`      |\n| 📂 Path/case                      | `pathCase('$catDog')`                                    | `$cat/Dog`     |\n| 🛰 Space case                     | `spaceCase('$catDog')`                                   | `$cat Dog`     |\n| 🏛 Capital Case                   | `capitalCase('$catDog')`                                 | `$Cat Dog`     |\n| 🔡 lower case                     | `lowerCase('$catDog')`                                   | `$cat dog`     |\n| 🔠 UPPER CASE                     | `upperCase('$catDog')`                                   | `$CAT DOG`     |\n\n#### Special Characters\n\nYou can see that most functions by default remove special characters, and some functions keep special characters.\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003efunctions that \u003ci\u003eremove\u003c/i\u003e special characters*\u003c/th\u003e\n    \u003cth\u003efunctions that \u003ci\u003ekeep\u003c/i\u003e special characters*\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n      \u003cli\u003ecamelCase\u003c/li\u003e\n      \u003cli\u003epascalCase\u003c/li\u003e\n      \u003cli\u003ekebabCase\u003c/li\u003e\n      \u003cli\u003esnakeCase\u003c/li\u003e\n      \u003cli\u003econstantCase\u003c/li\u003e\n      \u003cli\u003etrainCase\u003c/li\u003e\n      \u003cli\u003eadaCase\u003c/li\u003e\n      \u003cli\u003ecobolCase\u003c/li\u003e\n      \u003cli\u003edotNotation\u003c/li\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003cli\u003epathCase\u003c/li\u003e\n      \u003cli\u003espaceCase\u003c/li\u003e\n      \u003cli\u003ecapitalCase\u003c/li\u003e\n      \u003cli\u003elowerCase\u003c/li\u003e\n      \u003cli\u003eupperCase\u003c/li\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\\*You can control wether or not to _keep or remove_ special characters like so:\n\n```js\n// default:\ncamelCase('$catDog') === 'catDog'\n// force keeping special characters:\ncamelCase('$catDog', { keepSpecialCharacters: true }) === '$catDog'\n\n// default:\npathCase('$catDog') === '$cat/Dog'\n// force removing special characters:\npathCase('$catDog', { keepSpecialCharacters: false }) === 'cat/Dog'\n```\n\n#### Case Changing\n\nThese cases _**do not change the casing**_ of the words:\n\n- dotNotation\n- pathCase\n- spaceCase\n\n```js\n// default:\ndotNotation('$catDog') === 'cat.Dog'\n// force lower case:\ndotNotation('$catDog').toLowerCase() === 'cat.dog'\n```\n\n### Strings with spaces\n\nAs soon as there is a space in the target string, it will regard the input as a _sentence_ and only split each part at the spaces.\n\n| Name                              | Input example                                                | Output example |\n| --------------------------------- | ------------------------------------------------------------ | -------------- |\n| 🐪 camelCase                      | `camelCase(\"I'm O.K.!\")`                                     | `imOk`         |\n| 🐫 PascalCase\u003cbr /\u003eUpperCamelCase | `pascalCase(\"I'm O.K.!\")`\u003cbr /\u003e`upperCamelCase(\"I'm O.K.!\")` | `ImOk`         |\n| 🥙 kebab-case                     | `kebabCase(\"I'm O.K.!\")`                                     | `im-ok`        |\n| 🐍 snake_case                     | `snakeCase(\"I'm O.K.!\")`                                     | `im_ok`        |\n| 📣 CONSTANT_CASE                  | `constantCase(\"I'm O.K.!\")`                                  | `IM_OK`        |\n| 🚂 Train-Case                     | `trainCase(\"I'm O.K.!\")`                                     | `Im-Ok`        |\n| 🕊 Ada_Case                       | `adaCase(\"I'm O.K.!\")`                                       | `Im_Ok`        |\n| 👔 COBOL-CASE                     | `cobolCase(\"I'm O.K.!\")`                                     | `IM-OK`        |\n| 📍 Dot.notation                   | `dotNotation(\"I'm O.K.!\")`                                   | `Im.OK`        |\n| 📂 Path/case                      | `pathCase(\"I'm O.K.!\")`                                      | `I'm/O.K.!`    |\n| 🛰 Space case                     | `spaceCase(\"I'm O.K.!\")`                                     | `I'm O.K.!`    |\n| 🏛 Capital Case                   | `capitalCase(\"I'm O.K.!\")`                                   | `I'm O.k.!`    |\n| 🔡 lower case                     | `lowerCase(\"I'm O.K.!\")`                                     | `i'm o.k.!`    |\n| 🔠 UPPER CASE                     | `upperCase(\"I'm O.K.!\")`                                     | `I'M O.K.!`    |\n\nAlso note, that multiple sequential spaces are treated as one space.\n\n### Keep only certain special characters\n\nInstead of removing all special characters, you can opt to keep some special characters.\n\nIn the example below we see:\n\n- input: `$cat-dog`\n- desired output: `$CatDog`\n\n```js\npascalCase('$cat-dog', { keepSpecialCharacters: false })\n// CatDog   → not what we want\n\npascalCase('$cat-dog', { keepSpecialCharacters: true })\n// $Cat-Dog → not what we want\n\npascalCase('$cat-dog', { keep: ['$'] })\n// $CatDog  → desired output\n```\n\n### Convert special characters into alphabet\n\nI have extended regular alphabet with the most common _Latin-1 Supplement_ special characters.\n\nThe coolest thing about this library is that it will **\"convert\" special characters into regular alphabet** for the cases used as variable names! 😎\n\n\u003c!-- prettier-ignore-start --\u003e\n```js\n// CONVERTS special characters:\ncamelCase('Çâfé Ågård')    === 'cafeAgard'\npascalCase('Çâfé Ågård')   === 'CafeAgard'\nkebabCase('Çâfé Ågård')    === 'cafe-agard'\nsnakeCase('Çâfé Ågård')    === 'cafe_agard'\nconstantCase('Çâfé Ågård') === 'CAFE_AGARD'\ntrainCase('Çâfé Ågård')    === 'Cafe-Agard'\nadaCase('Çâfé Ågård')      === 'Cafe_Agard'\ncobolCase('Çâfé Ågård')    === 'CAFE-AGARD'\ndotNotation('Çâfé Ågård')  === 'Cafe.Agard'\n\n// DOES NOT convert special characters:\nspaceCase('Çâfé Ågård')    === 'Çâfé Ågård'\npathCase('Çâfé Ågård')     === 'Çâfé/Ågård'\nlowerCase('Çâfé Ågård')    === 'çâfé ågård'\nupperCase('Çâfé Ågård')    === 'ÇÂFÉ ÅGÅRD'\ncapitalCase('Çâfé Ågård')  === 'Çâfé Ågård'\n```\n\u003c!-- prettier-ignore-end --\u003e\n\n## JSDocs\n\nI have made sure there is great documentation available on hover!\n\n![jsdocs preview](.media/jsdocs.gif?raw=true)\n\n## Keyboard shortcuts\n\nWith [Better Touch Tool](https://folivora.ai) you can set up keyboard shortcuts to convert selected text with JavaScript. This repo provides an easy to install preset that has shortcuts for pascal, kebab and camel case! (thanks to [@AndrewKoch](https://github.com/AndrewKoch)) It even supports multi-cursors in VSCode!\n\nHere is an example triggering keyboard shortcuts to convert the selected text to PascalCase; kebab-case; camelCase:\n\n![keyboard shortcuts example](.media/case-anything_VSCode.gif?raw=true)\n\nYou can download the BTT preset from the source code: [case-anything.bttpreset](case-anything.bttpreset).\n\n## Package size\n\nWe'll compare this package with [blakeembrey/change-case](https://github.com/blakeembrey/change-case), a very famous package on npm.\n\n|              | case-anything | change-case  |\n| ------------ | ------------- | ------------ |\n| camelCase    | 1.1K (572)    | 27.2K (6K)   |\n| pascalCase   | 1.1K (561)    | 27.4K (6.1K) |\n| kebabCase    | 1.1K (541)    | 26.8K (5.9K) |\n| snakeCase    | 1.1K (540)    | 26.8K (5.9K) |\n| constantCase | 1.1K (540)    | 27.2K (6K)   |\n| pathCase     | 1K (530)      | 26.8K (5.9K) |\n\n## Source code\n\nWhat keeps my package small, is that literally just uses a regex to separate \"words\".\n\n```js\n// the source code is similar to:\nexport function splitOnSpecialChars(string: string): any[] {\n  return string.match(/^[a-z]+|[A-Z][a-z]+|[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g)\n}\n```\n\nThe actual regex used is a little bit more comprehensive and can be found [here](https://github.com/mesqueeb/case-anything/blob/production/src/utils.ts#L7).\n\n## Meet the family (more tiny utils with TS support)\n\n- [is-what 🙉](https://github.com/mesqueeb/is-what)\n- [is-where 🙈](https://github.com/mesqueeb/is-where)\n- [merge-anything 🥡](https://github.com/mesqueeb/merge-anything)\n- [check-anything 👁](https://github.com/mesqueeb/check-anything)\n- [remove-anything ✂️](https://github.com/mesqueeb/remove-anything)\n- [getorset-anything 🐊](https://github.com/mesqueeb/getorset-anything)\n- [map-anything 🗺](https://github.com/mesqueeb/map-anything)\n- [filter-anything ⚔️](https://github.com/mesqueeb/filter-anything)\n- [copy-anything 🎭](https://github.com/mesqueeb/copy-anything)\n- [case-anything 🐫](https://github.com/mesqueeb/case-anything)\n- [flatten-anything 🏏](https://github.com/mesqueeb/flatten-anything)\n- [nestify-anything 🧅](https://github.com/mesqueeb/nestify-anything)\n","funding_links":["https://github.com/sponsors/mesqueeb"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmesqueeb%2Fcase-anything","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmesqueeb%2Fcase-anything","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmesqueeb%2Fcase-anything/lists"}