All Projects → VitorLuizC → normalize-text

VitorLuizC / normalize-text

Licence: MIT license
📝 Provides a simple API to normalize texts, whitespaces, paragraphs & diacritics.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to normalize-text

Mightystring
Making Ruby Strings Powerful
Stars: ✭ 28 (-48.15%)
Mutual labels:  string, string-manipulation
Strtk
C++ String Toolkit Library
Stars: ✭ 113 (+109.26%)
Mutual labels:  string, string-manipulation
Cracking The Coding Interview
Solutions for Cracking the Coding Interview - 6th Edition
Stars: ✭ 35 (-35.19%)
Mutual labels:  string, string-manipulation
split-on-first
Split a string on the first occurrence of a given separator
Stars: ✭ 68 (+25.93%)
Mutual labels:  string, string-manipulation
Util
A collection of useful utility functions
Stars: ✭ 201 (+272.22%)
Mutual labels:  string, string-manipulation
Portable Utf8
🉑 Portable UTF-8 library - performance optimized (unicode) string functions for php.
Stars: ✭ 405 (+650%)
Mutual labels:  string, string-manipulation
Strman Java
A Java 8 string manipulation library.
Stars: ✭ 1,362 (+2422.22%)
Mutual labels:  string, string-manipulation
Litestringbuilder
Alternative to the System.Text.StringBuilder C# class.
Stars: ✭ 48 (-11.11%)
Mutual labels:  string, string-manipulation
Str
A fast, solid and strong typed string manipulation library with multibyte support
Stars: ✭ 199 (+268.52%)
Mutual labels:  string, string-manipulation
Voca rs
Voca_rs is the ultimate Rust string library inspired by Voca.js, string.py and Inflector, implemented as independent functions and on Foreign Types (String and str).
Stars: ✭ 167 (+209.26%)
Mutual labels:  string, string-manipulation
Tiny Utf8
Unicode (UTF-8) capable std::string
Stars: ✭ 322 (+496.3%)
Mutual labels:  string, string-manipulation
vbml
Way to check, match and resist.
Stars: ✭ 27 (-50%)
Mutual labels:  string, string-manipulation
safe-string-interpolation
A type driven approach to string interpolation, aiming at consistent, secure, and only-human-readable logs and console outputs !
Stars: ✭ 14 (-74.07%)
Mutual labels:  string, string-manipulation
Stringplus
Funny and minimal string library for C++ inspired by underscore.string
Stars: ✭ 7 (-87.04%)
Mutual labels:  string, string-manipulation
stringext
Extra string functions for OCaml
Stars: ✭ 20 (-62.96%)
Mutual labels:  string, string-manipulation
Androidlibrary
Android library to reveal or obfuscate strings and assets at runtime
Stars: ✭ 162 (+200%)
Mutual labels:  string, string-manipulation
Superstring.py
A fast and memory-optimized string library for heavy-text manipulation in Python
Stars: ✭ 231 (+327.78%)
Mutual labels:  string, string-manipulation
node-red-contrib-string
Provides a string manipulation node with a chainable UI based on the concise and lightweight stringjs.com.
Stars: ✭ 15 (-72.22%)
Mutual labels:  string, string-manipulation
DrawBox
DrawBox is a multi-purpose tool to draw anything on canvas, written completely on jetpack compose.
Stars: ✭ 148 (+174.07%)
Mutual labels:  compose
kmm
Rick & Morty Kotlin Multiplatform Mobile: Ktor, Sqldelight, Koin, Flow, MVI, SwiftUI, Compose
Stars: ✭ 52 (-3.7%)
Mutual labels:  compose

Normalize Text

Build Status License Library minified size Library minified + gzipped size

Provides a simple API to normalize texts, white-spaces, names, paragraphs & diacritics (accents).

  • 📦 Distributions in ESM, CommonJS, UMD and UMD minified formats.

    • Supports NodeJS ESM and CommonJS;
  • Lightweight:

    • It's bundled with Rollup and Bublé.
    • Smaller than 1KB (min + gzip).
    • Supports tree shaking.
  • 🔋 Bateries included:

    • Its not based on newer browser's APIs or es2015+ features.
    • Only needs String.prototype.normalize polyfill for older browsers, and don't crashes without it.
  • 🏷 Safe:

    • 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.

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

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 -->
<script src="https://cdn.jsdelivr.net/npm/normalize-text"></script>

<!-- Using default bundle from UNPKG -->
<script src="https://unpkg.com/normalize-text"></script>

<script>
  /**
   * UMD bundle expose brazilian-values through `normalizeText` object.
   */
  normalizeText.capitalizeFirstLetter('vitor');
  //=> "Vitor"
</script>

Usage

All the functions are named exported from module.

import { normalizeText } from 'normalize-text';

normalizeText([
  'Olá\r\n',
  '  como  está a   senhorita?'
]);
//=> "ola como esta a senhorita?"

API

capitalizeFirstLetter

Capitalize first character of received text.

capitalizeFirstLetter('vitorLuizC');
//=> "VitorLuizC"

normalizeDiacritics

If String.prototype.normalize is supported it normalizes diacritics by replacing them with "clean" character from received text.

It doesn't normalize special characters.

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

normalizeDiacritics('àáãâäéèêëíìîïóòõôöúùûüñçÀÁÃÂÄÉÈÊËÍÌÎÏÓÒÕÔÖÚÙÛÜÑÇ');
//=> "aaaaaeeeeiiiiooooouuuuncAAAAAEEEEIIIIOOOOOUUUUNC"

normalizeDiacritics('@_$><=-#!,.`\'"');
//=> "@_$><=-#!,.`'\"";

normalizeName

Normalize received name by normalizing it's white-spaces and capitalizing first letter of every word but exceptions (received in lower-case).

normalizeName(' fernanDA  MONTENEGRO');
//=> "Fernanda Montenegro"

normalizeName(' wilson da costa', ['da']);
//=> "Wilson da Costa"

normalizeParagraph

Normalize a paragraph by normalizing its white-spaces, capitalizing first letter and adding a period at end.

normalizeParagraph(' once upon a time');
//=> "Once upon a time."

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

normalizeText

Resolve received texts (when receives an Array) by normalizing its white-spaces and its diacritics and transforming to lower-case.

normalizeText(' so there\'s  a  Way to NORMALIZE ');
//=> "so there\'s a way to normalize"

normalizeText(['Olá\r\n', 'como está a   senhorita?']);
//=> "ola como esta a senhorita?"

normalizeWhiteSpaces

Normalize all white-space characters and remove trailing ones received text.

normalizeWhiteSpaces(' What exactly is it?   ');
//=> "What exactly is it?"

normalizeWhiteSpaces('Hi,   how is \r\n everything  \t?');
//=> 'Hi, how is everything ?'

License

Released under MIT license. You can see it here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].