0.1.0 • Published 1 year ago
fix-unicode-strings-deeply-inplace-pmb v0.1.0
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.true/undefined/omitted: Normalize with default setting as defined byString#normalize.false: Leave as is.- anything else: … is assumed to be one of the valid modes for
String#normalize.
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:…andfix:…: 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
0.1.0
1 year ago