Skip to content

Commit 258497e

Browse files
committed
Version 0.3.0
- Upgrade dependencies; - Add definition types for TypeScript consumers; - Write better docs and keep them consistent on `index.d.ts`, `index.js` & `README.md` files
1 parent e324b3b commit 258497e

File tree

5 files changed

+1741
-626
lines changed

5 files changed

+1741
-626
lines changed

README.md

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,82 @@
44

55
Provides an API with useful normalization functions.
66

7-
## Getting Started
7+
## Install
8+
9+
`normalize-text` is published under NPM registry, so you can install using any Node.js package manager.
810

911
```sh
10-
npm i normalize-text
12+
npm install normalize-text --save
13+
14+
# If you're using Yarn.
15+
yarn add normalize-text
1116
```
1217

18+
## Usage
19+
1320
```js
14-
import normalize, { normalizeWhitespaces, normalizeDiacritics } from 'normalize-text'
21+
import normalize from 'normalize-text';
1522

16-
const input = document.querySelector('input[name="name"]')
17-
const name = normalize(input.value)
23+
const input = document.querySelector('input[name="name"]');
24+
const name = normalize(input.value);
1825
```
1926

2027
## API
2128

22-
### `normalize: (string|Array<string>) => string`
29+
- `normalize`
2330

24-
Join arguments (when receives an `Array`), transform to lower case and normalize its whitespaces and diacritics.
31+
```ts
32+
export default function normalize (values: string | Array<string>): string;
33+
```
2534

26-
```js
27-
normalize([
28-
' Olá, \n',
29-
'Vitor LUIz \tcavalcanti'
30-
]) === 'ola, vitor luiz cavalcanti'
31-
```
35+
Join arguments (when receives an `Array`), normalize it's whitespaces, normalize it's diacritics and transform to lower case.
3236

33-
### `normalizeWhitespaces: (string) => string`
37+
```js
38+
normalize([
39+
' Olá, \r\n',
40+
'Fernanda \t MONtenegro'
41+
])
42+
// => 'ola, fernanda montenegro'
43+
```
3444

35-
Normalizes whitespaces, line-endings and tabs.
45+
- `normalizeWhitespaces`
3646

37-
```js
38-
normalizeWhitespaces(' Vitor \nLuiz\tCavalcanti ') === 'Vitor Luiz Cavalcanti'
39-
```
47+
```ts
48+
export function normalizeWhitespaces (value: string): string;
49+
```
4050

41-
### `normalizeDiacritics: (string) => string`
51+
Remove spaces from start and end, transform multiple spaces into single one and every space character into whitespace character.
4252

43-
Normalizes character accents and diacritics.
53+
```js
54+
normalizeWhitespaces(' Fernanda \t Montenegro\r\n')
55+
// => 'Fernanda Montenegro'
56+
```
4457

45-
```js
46-
normalizeDiacritics('Olá, você aí!') === 'Ola, voce ai!'
47-
```
58+
- `normalizeDiacritics`
4859

49-
### `normalizeParagraph: (string) => string`
60+
```ts
61+
export function normalizeDiacritics (value: string): string;
62+
```
5063

51-
Normalize whitespaces, coloca ponto final
64+
Normalize diacritics removing diacritics (accents) from letters.
5265

53-
```js
54-
normalizeParagraph('era uma vez no mundo encantando ') === 'Era uma vez no mundo encantado.'
55-
```
66+
```js
67+
normalizeDiacritics('Olá, você aí!')
68+
// => 'Ola, voce ai!'
69+
```
70+
71+
- `normalizeParagraph`
72+
73+
```ts
74+
export function normalizeParagraph (value: string): string;
75+
```
76+
77+
Normalize a paragraph. Normalize it's whitespaces, transform first letter to upper case and put a dot at end.
78+
79+
```js
80+
normalizeParagraph('hello world, my friend\r\n')
81+
// => 'Hello world, my friend.'
82+
```
5683

5784
## License
5885

0 commit comments

Comments
 (0)