{"id":17448305,"url":"https://github.com/mesqueeb/caseanything","last_synced_at":"2025-04-19T14:50:32.840Z","repository":{"id":215377176,"uuid":"738685329","full_name":"mesqueeb/CaseAnything","owner":"mesqueeb","description":"🐫 Swift Case Conversions — camelCase PascalCase UpperCamelCase kebab-case snake_case CONSTANT_CASE Train-Case Ada_Case COBOL-CASE Dot.notation Path/case Space case Capital Case lower case UPPER CASE","archived":false,"fork":false,"pushed_at":"2024-10-24T23:27:19.000Z","size":1793,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T20:33:17.969Z","etag":null,"topics":["ada-case","capital-case","case-change","case-converter","cobol-case","const-case","constant-case","convert-case","dot-notation","path-case","space-case","string-case","title-case","train-case"],"latest_commit_sha":null,"homepage":"https://swiftpackageindex.com/mesqueeb/CaseAnything/documentation/caseanything","language":"Swift","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":"2024-01-03T20:02:19.000Z","updated_at":"2024-11-12T06:18:50.000Z","dependencies_parsed_at":"2024-01-04T04:27:52.008Z","dependency_job_id":"1d127a61-3085-4194-ad25-7c742dc037cb","html_url":"https://github.com/mesqueeb/CaseAnything","commit_stats":null,"previous_names":["mesqueeb/caseanything"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2FCaseAnything","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2FCaseAnything/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2FCaseAnything/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2FCaseAnything/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mesqueeb","download_url":"https://codeload.github.com/mesqueeb/CaseAnything/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249717488,"owners_count":21315072,"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":["ada-case","capital-case","case-change","case-converter","cobol-case","const-case","constant-case","convert-case","dot-notation","path-case","space-case","string-case","title-case","train-case"],"created_at":"2024-10-17T20:06:56.242Z","updated_at":"2025-04-19T14:50:32.799Z","avatar_url":"https://github.com/mesqueeb.png","language":"Swift","readme":"# CaseAnything 🐫\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fmesqueeb%2FCaseAnything%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/mesqueeb/CaseAnything)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fmesqueeb%2FCaseAnything%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/mesqueeb/CaseAnything)\n\n```\n.package(url: \"https://github.com/mesqueeb/CaseAnything\", from: \"0.1.5\")\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 the other package that change cases do not cover all the 14 possibilities mine does.\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n      \u003cp\u003eSome features I focused on:\u003c/p\u003e\n      \u003cli\u003esmall footprint\u003c/li\u003e\n      \u003cli\u003eawesome code popup documentation\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\u003eCaseAnything 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\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\n```swift\nimport CaseAnything\n```\n\nCaseAnything 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```swift\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```swift\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```swift\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```swift\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## Code Docs\n\nI have made sure there is great documentation available on hover!\n\n![docs preview](.media/docsCaseAnything.png?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%20VSCode.gif?raw=true)\n\nYou can download the BTT preset from the source code: [CaseAnything.bttpreset](CaseAnything.bttpreset).\n\n## Source code\n\nWhat keeps my package small, is that literally just uses a regex to separate \"words\".\n\n```swift\n// the source code is similar to:\npublic func splitOnSpecialChars(string: String) -\u003e [String] {\n  let splitRegex = try! NSRegularExpression(pattern: \"^[a-z]+|[A-Z][a-z]+|[a-z]+|[0-9]+|[A-Z]+(?![a-z])\")\n  return splitRegex.matches(in: string, range: NSRange(string.startIndex..., in: string))\n}\n```\n\nThe actual regex used is a little bit more comprehensive and can be found [here](https://github.com/mesqueeb/CaseAnything/blob/main/Sources/Utils.swift#L9).\n","funding_links":["https://github.com/sponsors/mesqueeb"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmesqueeb%2Fcaseanything","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmesqueeb%2Fcaseanything","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmesqueeb%2Fcaseanything/lists"}