Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
normalize-text
Advanced tools
Provides a simple API to normalize texts, white-spaces, paragraphs & diacritics.
Provides a simple API to normalize texts, white-spaces, names, paragraphs & diacritics (accents).
📦 Distributions in ESM, CommonJS, UMD and UMD minified formats.
⚡ Lightweight:
🔋 Bateries included:
String.prototype.normalize
polyfill for older browsers, and don't crashes without it.🏷 Safe:
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
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>
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?"
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 ?'
normalizeWhiteSpaces`It is ${temperature}\n degree\r outside. `
//=> 'It is 25 degree outside.'
Released under MIT license. You can see it here.
FAQs
Provides a simple API to normalize texts, white-spaces, paragraphs & diacritics.
The npm package normalize-text receives a total of 9,944 weekly downloads. As such, normalize-text popularity was classified as popular.
We found that normalize-text demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.