UNPKG

7.34 kBMarkdownView Raw
1<div align="center" style="text-align: center;">
2 <h1 style="border-bottom: none;">normalize-diacritics</h1>
3
4 <p>Remove accents/ diacritics in string</p>
5</div>
6
7<hr />
8
9[![Follow me][follow-me-badge]][follow-me-url]
10
11[![Version][version-badge]][version-url]
12[![Node version][node-version-badge]][node-version-url]
13[![MIT License][mit-license-badge]][mit-license-url]
14
15[![Downloads][downloads-badge]][downloads-url]
16[![Total downloads][total-downloads-badge]][downloads-url]
17[![Packagephobia][packagephobia-badge]][packagephobia-url]
18[![Bundlephobia][bundlephobia-badge]][bundlephobia-url]
19
20[![CircleCI][circleci-badge]][circleci-url]
21[![Dependency Status][daviddm-badge]][daviddm-url]
22[![codecov][codecov-badge]][codecov-url]
23[![Coverage Status][coveralls-badge]][coveralls-url]
24
25[![codebeat badge][codebeat-badge]][codebeat-url]
26[![Codacy Badge][codacy-badge]][codacy-url]
27[![Code of Conduct][coc-badge]][coc-url]
28
29> Simple [NPM][npm-url] package to remove any accents/ diacritics found in a string.
30
31## Table of contents <!-- omit in toc -->
32
33- [Pre-requisite](#pre-requisite)
34- [Install](#install)
35- [Usage](#usage)
36 - [TypeScript or ES Modules](#typescript-or-es-modules)
37 - [Node.js](#nodejs)
38 - [Browser](#browser)
39 - [ES Modules](#es-modules)
40 - [UMD](#umd)
41- [Demo](#demo)
42- [deno](#deno)
43- [API Reference](#api-reference)
44 - [normalize([input])](#normalizeinput)
45 - [normalizeSync([input])](#normalizesyncinput)
46- [Contributing](#contributing)
47 - [Code of Conduct](#code-of-conduct)
48- [License](#license)
49
50## Pre-requisite
51
52- [Node.js][node-js-url] >= 8.16.0
53- [NPM][npm-url] >= 6.4.1 ([NPM][npm-url] comes with [Node.js][node-js-url] so there is no need to install separately.)
54
55
56## Install
57
58```sh
59# Install via NPM
60$ npm install --save normalize-diacritics
61```
62
63## Usage
64
65### TypeScript or ES Modules
66
67```ts
68import { normalize } from 'normalize-diacritics';
69
70/** Assuming top-level await is enabled... */
71await normalize('söme stüff with áccènts'); // 'some stuff with accents'
72```
73
74### Node.js
75
76```js
77const { normalize } = require('normalize-diacritics');
78
79/** Assuming top-level await is enabled... */
80await normalize('söme stüff with áccènts'); // 'some stuff with accents'
81```
82
83### Browser
84
85#### ES Modules
86
87```html
88<script type="module">
89 import { normalize } from 'https://unpkg.com/normalize-diacritics@latest/dist/normalize-diacritics.min.js';
90
91 // --snip
92</script>
93```
94
95#### UMD
96
97```html
98<script src="https://unpkg.com/normalize-diacritics@latest/dist/normalize-diacritics.umd.min.js"></script>
99<script>
100 const { normalize } = window.NormalizeDiacritics;
101
102 // --snip
103</script>
104```
105
106## Demo
107[![Edit normalize-diacritics demo](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/normalizediacritics-demo-wl7ef?fontsize=14)
108
109
110## deno
111
112👉 Check out the [deno][] module at [deno_mod/normalize_diacritics][].
113
114## API Reference
115
116### normalize([input])
117
118- `input` <?[string][string-mdn-url]> Optional input string that contains accents/ diacritics.
119- returns: <[Promise][promise-mdn-url]<[string][string-mdn-url]>> Promise which resolves with normalized input string.
120
121This method normalizes any accents/ diacritics found in a given input string and output a normalized string as a result.
122
123### normalizeSync([input])
124
125This methods works the same as `normalize([input])` except that this is the synchronous version.
126
127## Contributing
128
129### Code of Conduct
130
131Please note that this project is released with a [Contributor Code of Conduct][coc-url]. By participating in this project you agree to abide by its terms.
132
133## License
134
135[MIT License](http://motss.mit-license.org/) © Rong Sen Ng
136
137<!-- References -->
138[node-js-url]: https://nodejs.org
139[npm-url]: https://www.npmjs.com
140[node-releases-url]: https://nodejs.org/en/download/releases
141[typescript-url]: https://github.com/Microsoft/TypeScript
142[unpkg-url]: https://unpkg.com/normalize-diacritics@latest/dist/
143[deno]: https://github.com/denoland/deno
144[deno_mod/normalize_diacritics]: https://github.com/motss/deno_mod/tree/master/normalize_diacritics
145
146<!-- MDN -->
147[map-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
148[string-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
149[object-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
150[number-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number
151[boolean-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
152[html-style-element-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLStyleElement
153[promise-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
154
155<!-- Badges -->
156 [follow-me-badge]: https://flat.badgen.net/twitter/follow/igarshmyb?icon=twitter
157
158[version-badge]: https://flat.badgen.net/npm/v/normalize-diacritics?icon=npm
159[node-version-badge]: https://flat.badgen.net/npm/node/normalize-diacritics
160[mit-license-badge]: https://flat.badgen.net/npm/license/normalize-diacritics
161
162[downloads-badge]: https://flat.badgen.net/npm/dm/normalize-diacritics
163[total-downloads-badge]: https://flat.badgen.net/npm/dt/normalize-diacritics?label=total%20downloads
164[packagephobia-badge]: https://flat.badgen.net/packagephobia/install/normalize-diacritics
165[bundlephobia-badge]: https://flat.badgen.net/bundlephobia/minzip/normalize-diacritics
166
167[circleci-badge]: https://flat.badgen.net/circleci/github/motss/normalize-diacritics/master?icon=circleci
168[daviddm-badge]: https://flat.badgen.net/david/dep/motss/normalize-diacritics
169[codecov-badge]: https://flat.badgen.net/codecov/c/github/motss/normalize-diacritics?label=codecov&icon=codecov
170[coveralls-badge]: https://flat.badgen.net/coveralls/c/github/motss/normalize-diacritics?label=coveralls
171
172[codacy-badge]: https://api.codacy.com/project/badge/Grade/c84a41b8422245058a8c1acd17fd7e23
173[inch-badge]: http://inch-ci.org/github/motss/normalize-diacritics.svg?branch=master
174[codebeat-badge]: https://codebeat.co/badges/8a0eb7c1-b944-41b1-ad87-5f0bd392873b
175[coc-badge]: https://flat.badgen.net/badge/code%20of/conduct/pink
176
177<!-- Links -->
178[follow-me-url]: https://twitter.com/igarshmyb?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=motss/normalize-diacritics
179
180[version-url]: https://www.npmjs.com/package/normalize-diacritics
181[node-version-url]: https://nodejs.org/en/download
182[mit-license-url]: /LICENSE
183
184[downloads-url]: http://www.npmtrends.com/normalize-diacritics
185[packagephobia-url]: https://packagephobia.now.sh/result?p=normalize-diacritics
186[bundlephobia-url]: https://bundlephobia.com/result?p=normalize-diacritics
187
188[circleci-url]: https://circleci.com/gh/motss/normalize-diacritics/tree/master
189[daviddm-url]: https://david-dm.org/motss/normalize-diacritics
190[codecov-url]: https://codecov.io/gh/motss/normalize-diacritics
191[coveralls-url]: https://coveralls.io/github/motss/normalize-diacritics?branch=master
192
193[codebeat-url]: https://codebeat.co/projects/github-com-motss-normalize-diacritics-master
194[codacy-url]: https://www.codacy.com/app/motss/normalize-diacritics?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=motss/normalize-diacritics&amp;utm_campaign=Badge_Grade
195[coc-url]: /CODE-OF-CONDUCT.md