Packages / normalizer
Clean up text: trim it, lowercase it, and collapse repeated whitespace.
MITv0.1.0experimental
New to Kaab? Every package installs the same way. Read the installation guide first.
Installation
Add the package with the package manager you use.
$ npm i @kaab/normalizer
Usage
Import normalize and pass it a string.
import { normalize } from "@kaab/normalizer";
const clean = normalize("SOO dhawoow");
// "soo dhawoow"normalize does three things:
- Removes whitespace from the start and the end.
- Replaces every run of whitespace (spaces, tabs, line breaks) with one space.
- Converts the text to lowercase.
API
| Name | Type | Description |
|---|---|---|
normalize(text) | function | Returns the cleaned text as a string. |
text | string | The text to clean up. |
Licence
Released under the MIT licence. You can use it in personal and commercial projects. Keep the licence notice in your copy.