InAnyCase

1.0.2

Convert between programmer case styles, e.g., inAnyCase → in_any_case
ThatsJustCheesy/InAnyCase

What's New

v1.0.2

2021-11-27T18:29:50Z

Changed this patch release:

  • Cache compiled regex for better performance

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. WordCaseTransformers 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.

This library uses sharplet/Regex, which is also provided by its author under the MIT License.

Description

  • Swift Tools 5.1.0
View More Packages from this Author

Dependencies

Last updated: Sun Mar 17 2024 14:56:47 GMT-0900 (Hawaii-Aleutian Daylight Time)