Provides a simple API to normalize texts, white-spaces, names, paragraphs & diacritics (accents).
📦 Distributions in ESM, CommonJS, UMD and UMD minified formats.
🔋 Bateries included:
- Its not based on newer browser's APIs or es2015+ features.
- Only needs
String.prototype.normalizepolyfill for older browsers, and don't crashes without it.
- Type declarations for IDEs and editor's autocomplete/intellisense.
- Made with TypeScript as strict as possible.
- Unit tests with Jest.
- Travis CI that keeps tests running.
normalize-text is published under NPM registry, so you can install using any Node.js package manager.
npm install normalize-text --save# If you're using Yarn.yarn add normalize-text
Install from CDN
The bundles of this module are also available on JSDelivr and UNPKG CDNs.
In both you can import just the bundle you want or use default one, UMD.
<!-- Using default bundle from JSDelivr --><!-- Using default bundle from UNPKG -->
All the functions are named exported from module.
;;//=> "ola como esta a senhorita?"
Capitalize first character of received text.
String.prototype.normalize is supported it normalizes diacritics by replacing them with "clean" character from received text.
It doesn't normalize special characters.
;//=> 'Ola, voce ai';//=> "aaaaaeeeeiiiiooooouuuuncAAAAAEEEEIIIIOOOOOUUUUNC";//=> "@_$><=-#!,.`'\"";
Normalize received name by normalizing it's white-spaces and capitalizing first letter of every word but exceptions (received in lower-case).
;//=> "Fernanda Montenegro";//=> "Wilson da Costa"
Normalize a paragraph by normalizing its white-spaces, capitalizing first letter and adding a period at end.
;//=> "Once upon a time.";// => 'Hello world, my friend.'
Resolve received texts (when receives an
Array) by normalizing its white-spaces and its diacritics and transforming to lower-case.
;//=> "so there\'s a way to normalize";//=> "ola como esta a senhorita?"
Normalize all white-space characters and remove trailing ones received text.
;//=> "What exactly is it?";//=> 'Hi, how is everything ?'
Released under MIT license. You can see it here.