{"id":30179895,"url":"https://github.com/capturecontext/swift-casification","last_synced_at":"2026-02-05T17:05:21.843Z","repository":{"id":307151348,"uuid":"1027724232","full_name":"CaptureContext/swift-casification","owner":"CaptureContext","description":"Package for tokenizing and case swapping for free strings","archived":false,"fork":false,"pushed_at":"2026-02-04T07:13:22.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-04T19:14:23.949Z","etag":null,"topics":["camel-case","camelcase","case","kebab-case","kebabcase","snake-case","snakecase","spm","strings","swift","swift-package-manager","swift-strings","tokenization","tokenizer"],"latest_commit_sha":null,"homepage":"","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/CaptureContext.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-28T12:44:15.000Z","updated_at":"2026-02-04T07:06:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"342862ca-14ed-4a84-aab8-e7b8b9c1d2a5","html_url":"https://github.com/CaptureContext/swift-casification","commit_stats":null,"previous_names":["capturecontext/swift-casification"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/CaptureContext/swift-casification","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-casification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-casification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-casification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-casification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CaptureContext","download_url":"https://codeload.github.com/CaptureContext/swift-casification/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-casification/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29126105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T14:05:12.718Z","status":"ssl_error","status_checked_at":"2026-02-05T14:03:53.078Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-case","camelcase","case","kebab-case","kebabcase","snake-case","snakecase","spm","strings","swift","swift-package-manager","swift-strings","tokenization","tokenizer"],"created_at":"2025-08-12T06:50:51.099Z","updated_at":"2026-02-05T17:05:21.838Z","avatar_url":"https://github.com/CaptureContext.png","language":"Swift","readme":"# swift-casification\n\n[![CI](https://github.com/capturecontext/swift-casification/actions/workflows/ci.yml/badge.svg)](https://github.com/capturecontext/swift-casification/actions/workflows/ci.yml) [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fcapturecontext%2Fswift-casification%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/capturecontext/swift-casification) [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fcapturecontext%2Fswift-casification%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/capturecontext/swift-casification)\n\nPackage for tokenizing and applying case transformations to arbitrary strings.\n\n## Table of contents\n\n- [Motivation](#motivation)\n- [Usage](#usage)\n  - [Basic modifiers](#basic-modifiers)\n  - [Token-based modifiers](#token-based-modifiers)\n  - [Composing modifiers](#composing-modifiers)\n  - [Custom modifiers](#custom-modifiers)\n- [Installation](#installation)\n- [License](#license)\n\n## Motivation\n\nSwift does not provide a standard way to tokenize strings or to build formatted strings from such tokens.\n\nAs a result, even common transformations like `camelCase` are often implemented differently across projects, leading to duplicated logic and inconsistent results.\n\nThis package focuses on providing a set of predefined, reusable string modifiers for common casing and formatting transformations, with consistent behavior across codebases.\n\n## Usage\n\nA set of predefined string modifiers is available out of the box\n\n### Basic modifiers\n\n| Modifiers    | Examples                  |\n| :----------- | ------------------------- |\n| `upper`      | string → STRING           |\n| `lower`      | STRING → string           |\n| `upperFirst` | String → String           |\n| `lowerFirst` | STRING → sTRING           |\n| `capital`    | some string → Some String |\n| `swap`       | Some String → sOME sTRING |\n\n### Token-based modifiers\n\nThose modifiers are a bit more complex and do support configuration\n\n- `String.Casification.PrefixPredicate` allows configuring allowed prefixes, `.swiftDeclarations` is used by default allowing `$` and `_` symbols for prefixes\n- You can also provide a list of acronyms. The default list is available at [`String.Casification.standardAcronyms`](./Sources/Casification/Casification.swift), there is no way to modify this list at least yet, but you can explicitly specify your own, we'll add modification mechanism in future versions of the library.\n\n| Modifiers           | Examples                  |\n| ------------------- | ------------------------- |\n| `camel(.camel)`     | some string → someString  |\n| `camel(.pascal)`    | some string → SomeString  |\n| `camel`            | some string → someString  |\n| `pascal`           | some string → SomeString  |\n| `camel(.automatic)` | some string → someString  |\n| `camel(.automatic)` | Some string → SomeString  |\n| `snake()`           | some string → some_string |\n| `kebab()`           | some string → some-string |\n| `dot()`             | some string → some.string |\n\n\u003e  [!NOTE] \n\u003e\n\u003e _See [Tests](./Tests/CasificationTests) for more examples_\n\n### Composing modifiers\n\nModifiers can be combined using `combined(with:)` method. Order matters – transformations are applied sequentially.\n\n```swift\n// \"myString\" → \"mystring\" → \"Mystring\"\n\"myString\".case(.lower.combined(with: .upperFirst))\n```\n\n```swift\n// \"myString\" → \"Mystring\" → \"mystring\"\n\"myString\".case(.upperFirst.combined(with: .lower)) // mystring\n```\n\n### Custom modifiers\n\nFor simple modifiers, conforming a type to `String.Casification.Modifier` is enough\n\n```swift\nextension String.Casification.Modifiers {\n  /// Deletes input string\n  public struct Delete: String.Casification.Modifier {\n    public init() {}\n    \n    @inlinable \n    public func transform(_ input: Substring) -\u003e Substring {\n      \"\"\n    }\n  }\n}\n```\n\n\u003e [!TIP]\n\u003e\n\u003e It's a good idea to declare convenience accessor for the protocol\n\u003e ```swift\n\u003e extension String.Casification.Modifier\n\u003e where Self == String.Casification.Modifiers.Delete {\n\u003e      public var delete: Self { .init() }\n\u003e }\n\u003e ```\n\u003e\n\u003e ```swift\n\u003e \"myString\".case(.delete) // \"\"\n\u003e ```\n\nFor more complex processing, you can operate on [tokens](./Sources/Casification/Casification.swift) instead of raw strings by conforming to `String.Casification.TokensProcessor`\n\n```swift\nextension String.Casification.TokensProcessors {\n  public struct RemoveSeparators: String.Casification.TokensProcessor {\n    public init() {}\n    @inlinable\n    public func processTokens(\n      _ tokens: ArraySlice\u003cString.Casification.Token\u003e\n    ) -\u003e ArraySlice\u003cString.Casification.Token\u003e {\n      return filter { $0.kind != .separator }[...]\n    }\n  }\n}\n\nextension String.Casification.Modifier\nwhere Self == String.Casification.Modifier.ProcessingTokens\u003c\n  String.Casification.TokensProcessors.RemoveSeparators\n\u003e{\n  public var noSeparators: Self {\n    .init(using: .init())\n  }\n}\n```\n\n```swift\n\"my test-string\".case(.noSeparators) // \"myteststring\"\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e _The package is primarily designed around predefined reusable modifiers. Custom modifiers are supported, but declarations can be verbose due to namespacing and generic types._\n\n## Installation\n\n### Basic\n\nYou can add Casification to an Xcode project by adding it as a package dependency.\n\n1. From the **File** menu, select **Swift Packages › Add Package Dependency…**\n2. Enter [`\"https://github.com/capturecontext/swift-casification.git\"`](https://github.com/capturecontext/swift-casification.git) into the package repository URL text field\n3. Choose products you need to link them to your project.\n\n### Recommended\n\nIf you use SwiftPM for your project, you can add Casification to your package file.\n\n```swift\n.package(\n  url: \"https://github.com/capturecontext/swift-casification.git\", \n  .upToNextMinor(from: \"0.1.0\")\n)\n```\n\nDo not forget about target dependencies:\n\n```swift\n.product(\n  name: \"Casification\", \n  package: \"swift-casification\"\n)\n```\n\n## License\n\nThis library is released under the MIT license. See [LICENSE](LICENSE) for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapturecontext%2Fswift-casification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcapturecontext%2Fswift-casification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapturecontext%2Fswift-casification/lists"}