/string-utilities

Handy tagged template functions & other string utilities.

Primary LanguageTypeScript

API DocumentationCHANGELOG

string-utilities

Handy tagged templates & other string utilities.

To install:

npm i @karmaniverous/string-utilities

Contents:

  • Types

  • Transformations

    • normstr - Normalize a string by converting diacriticals to base characters, removing non-word characters, and converting to lower case. Non-strings return undefined.
  • Tagged Template Functions

    • Non-stringifiable to Empty String (n2e) - Replaces expressions without toString property with empty strings.

    • Some Non-stringifiable to Empty String (sn2e) - Returns empty string when any expression has no toString property.

    • Some Non-stringifiable to Null (sn2n) - Returns null when any expression has no toString property.

    • Some Non-stringifiable to Undefined (sn2u) - Returns undefined when any expression has no toString property.

  • Higher-Order Functions

    • Non-stringifiable to Default (n2d) - Returns tagged template function that replaces any expression that has no toString property with a default value.

    • Some Non-stringifiable to Default (sn2d) - Returns tagged template function that returns a default value when any expression has no toString property.


Built for you with ❤️ on Bali! Find more great tools & templates on my GitHub Profile.