Skip to content

Commit

Permalink
💥 To fixed #22 for a rewrite in TypeScript
Browse files Browse the repository at this point in the history
✨ Added proper implementation of string normalization in ES6 to fix #21
  • Loading branch information
motss committed Nov 28, 2017
1 parent a30cdb5 commit d94bc76
Show file tree
Hide file tree
Showing 25 changed files with 9,755 additions and 395 deletions.
30 changes: 0 additions & 30 deletions .babelrc

This file was deleted.

1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
root = true

[*]

# Change these settings to your own preference
indent_style = space
indent_size = 2
Expand Down
8 changes: 0 additions & 8 deletions .eslintignore

This file was deleted.

27 changes: 0 additions & 27 deletions .eslintrc.json

This file was deleted.

5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
*.html text eol=lf
*.js text eol=lf
*.json text eol=lf
*.scss text eol=lf
*.md text eol=lf
*.scss text eol=lf
*.sh text eol=lf
*.ts text eol=lf
*.tsx text eol=lf
*.txt text eol=lf
*.xml text eol=lf
*.yaml text eol=lf
*.yml text eol=lf
13 changes: 8 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
.DS_Store
.vscode
node_modules/
.esm-cache
*.env
.build/
.nyc_output
.tmp/
.vscode
npm-debug.log*
*.env
yarn-error.log*
build/
coverage/
dist/
dist/**/__mocks__/
dist/**/__tests__/
.nyc_output
out/
gulpfile.js
logs/**/[^.]*
node_modules/
out/
13 changes: 8 additions & 5 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
.DS_Store
.vscode
node_modules/
*.env
.build/
.nyc_output
.tmp/
.vscode
npm-debug.log*
*.env
yarn-error.log*
build/
coverage/
dist*/
dist/**/__mocks__/
dist/**/__tests__/
.nyc_output
out/
dist/**/demo/
logs/**/[^.]*
node_modules/
out/
5 changes: 5 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# User config
package-lock=true
progress=true
quiet=true
update-binary=true
4 changes: 0 additions & 4 deletions .snyk

This file was deleted.

7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
language: node_js
dist: trusty
node_js:
- v6
- v7
- v8
- v9
script:
- npm run build
- npm run test
after_success: npm run coveralls && npm run codecov
File renamed without changes.
File renamed without changes.
158 changes: 113 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,142 @@
[![Stories in Ready](https://badge.waffle.io/motss/normalize-diacritics.png?label=ready&title=Ready)](https://waffle.io/motss/normalize-diacritics?utm_source=badge)
# normalize-diacritics
<div align="center" style="text-align: center;">
<h1 style="border-bottom: none;">normalize-diacritics</h1>

[![NPM][nodei-image]][nodei-url]
<p>Remove accents/ diacritics in strings</p>
</div>

> Simple module to normalize any diacritics in a given string.
<hr />

[![NPM version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Build status][appveyor-image]][appveyor-url]
[![Dependency Status][daviddm-image]][daviddm-url]
[![Coverage percentage][coveralls-image]][coveralls-url]
[![codecov][codecov-image]][codecov-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![NSP Status][nsp-image]][nsp-url]
[![Inline docs][inch-image]][inch-url]
[![GitHub license][license-image]][license-url]
[![Greenkeeper badge][greenkeeper-image]][greenkeeper-url]
[![NPM][nodei-badge]][nodei-url]

## Install
[![Build Status][travis-badge]][travis-url]
[![AppVeyor][appveyor-badge]][appveyor-url]
[![Version][version-badge]][version-url]
[![Downloads][downloads-badge]][downloads-url]
[![MIT License][mit-license-badge]][mit-license-url]
[![NSP Status][nsp-badge]][nsp-url]
[![Dependency Status][daviddm-badge]][daviddm-url]
[![Greenkeeper badge][greenkeeper-badge]][greenkeeper-url]

```
[![Code of Conduct][coc-badge]][coc-url]

[![Coverage percentage][coveralls-badge]][coveralls-url]
[![codecov][codecov-badge]][codecov-url]

<!-- [![Codacy Badge][codacy-badge]][codacy-url] -->
[![Inline docs][inch-badge]][inch-url]
<!-- [![codebeat badge][codebeat-badge]][codebeat-url] -->

[![Stories in Ready][waffle-badge]][waffle-url]

> A simple NPM package to remove accents/ diacritics in strings in Javascript.
## Setup

### Pre-requisites

Please make sure that you have the followings installed on your machine:

- `node >= 8.9.0` ___(In Zumata, we internally use the latest LTS version ([node:carbon][node-releases-url]) for all our Node.js applications.)___
- `npm >= 5.5.1` ___(The minimum NPM version for [node:carbon][node-releases-url].)___

### Install the package via NPM

```sh
# NPM install
$ npm install --save normalize-diacritics
```

## Usage
## How to use

Brief example to show how to use:
### Typescript or Node.js with native ES Modules

```js
const { diacritics, normalize } = require('normalize-diacritics');
Snippet for using native ES Modules:

```ts
import normalize from 'normalize-diacritics';

(async () => {
const str = 'söme stüff with áccènts';
await normalize(str); // some stuff with accents
})();
```

/* To show the list of diacritics */
console.log(diacritics); // { letter: ' ', diacritics: /[\u00a0]/g } ...
### CommonJS's require

/* To normalize string */
const str = 'söme stüff with áccènts';
normalize(str); // some stuff with accents
```js
const { normalize } = require('normalize-diacritics');

(async () => {
const str = 'söme stüff with áccènts';
await normalize(str); // some stuff with accents
})();
```

## Demo
## API Reference

### normalize(input)

- input <[string][string-mdn-url]> Input string that contains accents/ diacritics.
- returns: <[Promise][promise-mdn-url]<[string][string-mdn-url]>>

This method accepts an input string that contains any accents/ diacritics and normalizes all of them asynchronously and the normalized string will be output as a result.

[Simple demo on Runkit](https://runkit.com/motss/normalize-diacritics)
### normalizeSync(input)

- input <[string][string-mdn-url]> Input string that contains accents/ diacritics.
- returns: <[Promise][promise-mdn-url]<[string][string-mdn-url]>>

This methods works the same as `normalize(input)` except that this is a synchronous version of `normalize(input)`.

## License

[MIT License](http://motss.mit-license.org/) © Rong Sen Ng

[node-releases-url]: https://nodejs.org/en/download/releases
[string-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
[promise-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise

[nodei-badge]: https://nodei.co/npm/normalize-diacritics.png?downloads=true&downloadRank=true&stars=true

[travis-badge]: https://img.shields.io/travis/rust-lang/rust.svg?style=flat-square
[appveyor-badge]: https://ci.appveyor.com/api/projects/status/g3n1hhl18w3crcrb?svg=true

[version-badge]: https://img.shields.io/npm/v/delvery.svg?style=flat-square
[downloads-badge]: https://img.shields.io/npm/dm/delvery.svg?style=flat-square
[mit-license-badge]: https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square
[nsp-badge]: https://nodesecurity.io/orgs/motss/projects/92a9a3b3-c0c8-4172-917d-f1c7e0d5ef9f/badge
[daviddm-badge]: https://img.shields.io/david/expressjs/express.svg?style=flat-square
[greenkeeper-badge]: https://badges.greenkeeper.io/motss/normalize-diacritics.svg

[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square

[coveralls-badge]: https://coveralls.io/repos/github/Zumata/normalize-diacritics/badge.svg?branch=master
[codecov-badge]: https://codecov.io/gh/Zumata/normalize-diacritics/branch/master/graph/badge.svg

[codacy-badge]: https://api.codacy.com/project/badge/Grade/c84a41b8422245058a8c1acd17fd7e23
[inch-badge]: http://inch-ci.org/github/zumata/normalize-diacritics.svg?branch=master
[codebeat-badge]: https://codebeat.co/badges/8a0eb7c1-b944-41b1-ad87-5f0bd392873b

[waffle-badge]: https://badge.waffle.io/Zumata/normalize-diacritics.png?label=ready&title=Ready



[nodei-image]: https://nodei.co/npm/normalize-diacritics.png?downloads=true&downloadRank=true&stars=true
[nodei-url]: https://nodei.co/npm/normalize-diacritics/
[npm-image]: https://badge.fury.io/js/normalize-diacritics.svg
[npm-url]: https://npmjs.org/package/normalize-diacritics
[travis-image]: https://travis-ci.org/motss/normalize-diacritics.svg?branch=master

[travis-url]: https://travis-ci.org/motss/normalize-diacritics
[appveyor-image]: https://ci.appveyor.com/api/projects/status/g3n1hhl18w3crcrb/branch/master?svg=true
[appveyor-url]: https://ci.appveyor.com/project/motss/normalize-diacritics/branch/master
[daviddm-image]: https://david-dm.org/motss/normalize-diacritics.svg?theme=shields.io
[version-url]: https://npmjs.org/package/normalize-diacritics
[downloads-url]: http://www.npmtrends.com/normalize-diacritics
[mit-license-url]: https://github.com/Zumata/normalize-diacritics/blob/master/LICENSE
[nsp-url]: https://nodesecurity.io/orgs/motss/projects/02e1b52b-3dc8-4fcf-aa91-8676541b4348
[daviddm-url]: https://david-dm.org/motss/normalize-diacritics
[coveralls-image]: https://coveralls.io/repos/github/motss/normalize-diacritics/badge.svg?branch=master
[greenkeeper-url]: https://greenkeeper.io/

[coc-url]: https://github.com/Zumata/normalize-diacritics/blob/master/CODE_OF_CONDUCT.md

[coveralls-url]: https://coveralls.io/github/motss/normalize-diacritics?branch=master
[codecov-image]: https://codecov.io/gh/motss/normalize-diacritics/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/motss/normalize-diacritics
[snyk-image]: https://snyk.io/test/github/motss/normalize-diacritics/badge.svg
[snyk-url]: https://snyk.io/test/github/motss/normalize-diacritics
[nsp-image]: https://nodesecurity.io/orgs/motss/projects/02e1b52b-3dc8-4fcf-aa91-8676541b4348/badge
[nsp-url]: https://nodesecurity.io/orgs/motss/projects/02e1b52b-3dc8-4fcf-aa91-8676541b4348
[inch-image]: http://inch-ci.org/github/motss/normalize-diacritics.svg?branch=master

[inch-url]: http://inch-ci.org/github/motss/normalize-diacritics
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg
[license-url]: https://motss.mit-license.org/
[greenkeeper-image]: https://badges.greenkeeper.io/motss/normalize-diacritics.svg
[greenkeeper-url]: https://greenkeeper.io/

[waffle-url]: https://waffle.io/motss/normalize-diacritics?utm_source=badge
25 changes: 17 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
max_jobs: 4

environment:
CODECOV_TOKEN:
secure: 5SygvlgfTewBB3CTmBxUfQ==
SNYK_TOKEN:
secure: IyV3vkSZTlBKOtJfcNFk3ZyRSwSRKZUg4YUulfphVR8FCMj94J7az6yIoqNALOPq
matrix:
- nodejs_version: 6
- nodejs_version: 7
- nodejs_version: 8
- nodejs_version: 9

platform:
- x86
Expand All @@ -15,13 +15,22 @@ platform:
install:
- ps: Install-Product node $env:nodejs_version $env:platform
- npm install -g npm
- node --version
- npm --version
- npm install

# Post-install test scripts.
# Build
build_script:
- npm run build

# Post-install test scripts
test_script:
- node --version
- npm --version
- npm test

# Don't actually build.
# Submit coverage reports
after_test:
- npm run coveralls
- npm run codecov

# Don't actually build
build: off
2 changes: 1 addition & 1 deletion clean-directories.sh → clean-dir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
clear; printf "Running %s script...\n" "$(basename "$0" .sh)"

has_unused_directories=false
directories="dist/ node_modules/ .nyc_output/ coverage/ npm-debug.log yarn-error.log out/ coverage.lcov"
directories="dist/ node_modules/ .nyc_output/ coverage/ npm-debug.log yarn-error.log out/ coverage.lcov gulpfile.js"

for directory in $directories; do
if [ -d "$directory" ] || [ -f "$directory" ]; then
Expand Down
Loading

0 comments on commit d94bc76

Please sign in to comment.