Package detail

fix-unicode-strings-deeply-inplace-pmb

mk-pmb11ISC0.1.0

Normalize/fix various common headaches with user-provided string inputs, deeply if given an object (including array).

combining characters, decompose, decomposed characters, decomposed

readme



fix-unicode-strings-deeply-inplace-pmb

Normalize/fix various common headaches with user-provided string inputs, deeply if given an object (including array).

API

This module exports one function:

fixStringsDeeplyInplace(input[, opt])

opt is an optional options object that supports these optional keys:

  • normCC: Whether to normalize composing characters, and how.
  • trim: Whether to discard whitespace at the start and end of strings.
    • false/undefined/omitted: Leave as is.
    • true: Discard. This may mess with the indentation of the first non-blank line.
  • eol: Whether to normalize end-of-line symbols (CR, LF, and potential preceeding whitespace).
    • false/undefined/omitted: Leave as is.
    • true: Alias for '\n'.
    • any string: Replace with this string.
  • pre-fix:… and fix:…: Custom callbacks to transform values before/after the default normalizations. This is meant as an easy way to add simple optimizations, in cases where you'd otherwise have to replicate this module's object-diving code. See the code for how it works.

Usage

see test/usage.mjs.

Known issues

  • Needs more/better tests and docs.

 

License

ISC