Miss any of our Open RFC calls?Watch the recordings here! »

normalize-text

0.4.0 • Public • Published

Normalize Text

Build Status

Provides a simple API to normalize texts, whitespaces, paragraphs & diacritics.

Install

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

Usage

import normalize from 'normalize-text';
 
const input = document.querySelector('input[name="name"]');
const name = normalize(input.value);

API

normalize

Join arguments (when receives an Array), normalize it's whitespaces, normalize it's diacritics and transform to lower case.

normalize([
  '     Olá, \r\n',
  'Fernanda \t MONtenegro'
])
// => 'ola, fernanda montenegro'

Type definition

export default function normalize (values: string | string[]): string;

normalizeWhitespaces

Remove spaces from start and end, transform multiple spaces into single one and every space character into whitespace character.

normalizeWhitespaces('  Fernanda \t Montenegro\r\n')
// => 'Fernanda Montenegro'

Type definition

export function normalizeWhitespaces (value: string): string;

normalizeDiacritics

Normalize diacritics removing diacritics (accents) from letters.

normalizeDiacritics('Olá, você aí!')
// => 'Ola, voce ai!'

Type definition

export function normalizeDiacritics (value: string): string;

normalizeParagraph

Normalize a paragraph. Normalize it's whitespaces, transform first letter to upper case and put a dot at end.

normalizeParagraph('hello world, my friend\r\n')
// => 'Hello world, my friend.'

Type definition

export function normalizeParagraph (value: string): string;

normalizeName

Normalize a name. Normalize it's whitespaces and capitalize letters.

normalizeParagraph(' fernanda \tMONTENEGRO')
// => 'Fernanda Montenegro'

Type definition

export function normalizeName (value: string): string;

License

Released under MIT license. You can see it here.

Install

npm i [email protected]

Version

0.4.0

License

MIT

Unpacked Size

217 kB

Total Files

9

Last publish

Collaborators

  • avatar