Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thatsjustcheesy/inanycase
Convert between programmer case styles, e.g., inAnyCase → in_any_case
https://github.com/thatsjustcheesy/inanycase
code-style code-style-modification string-case string-manipulation string-transformations swift swift-package swift-package-manager swiftpm
Last synced: about 1 month ago
JSON representation
Convert between programmer case styles, e.g., inAnyCase → in_any_case
- Host: GitHub
- URL: https://github.com/thatsjustcheesy/inanycase
- Owner: ThatsJustCheesy
- License: mit
- Created: 2019-12-28T23:47:57.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-11-27T18:29:50.000Z (about 3 years ago)
- Last Synced: 2024-10-30T00:54:16.572Z (about 2 months ago)
- Topics: code-style, code-style-modification, string-case, string-manipulation, string-transformations, swift, swift-package, swift-package-manager, swiftpm
- Language: Swift
- Size: 14.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# InAnyCase
Micro-library that converts between different identifier casing styles. e.g., "camelCasedString" → "camel\_cased\_string".
Supported join styles:
* camelStyle (`JoinStyle.camel`)
* snake\_style (`.snake`)
* kebab-style (`.kebab`)
* space style (`.space`)Supported case styles:
* Preserve—don't modify case (`CaseStyle.preserve`)
* CAPSSTYLE (`.caps`)
* UpperStyle (`.upper`)
* lowerUpperStyle (`.lowerUpper`)
* lowerstyle (`.lower`)You can implement extra join styles by conforming to `WordJoinStyle`: implement a split function and specify a join separator.
You can implement extra case styles using `WordCaseSimpleTransformer` and/or `WordCaseTransformer`. `WordCaseTransformer`s transform one word at a time given the current index. `WordCaseSimpleTransformer` is an implementation of `WordCaseTransformer` that applies another `WordCaseTransformer` for the first word, and then yet another for all subsequent words. `WordCase` implements the basic CAPS, Upper and lower transformations, or you can create your own.
See tests in `Tests/InAnyCaseTests/InAnyCaseTests.swift` for usage examples.
## Licensing
Available under the MIT License. See [`LICENSE.txt`](LICENSE.txt).
This library uses [sharplet/Regex], which is also provided by its author under the MIT License.
[sharplet/Regex]: https://github.com/sharplet/Regex