Skip to content

Commit a033804

Browse files
committed
Use ESM
1 parent 39756c6 commit a033804

File tree

6 files changed

+24
-38
lines changed

6 files changed

+24
-38
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
.DS_Store
22
*.log
3-
.nyc_output/
43
coverage/
54
node_modules/
6-
nlcst-normalize.js
7-
nlcst-normalize.min.js
85
yarn.lock

.prettierignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
coverage/
2-
nlcst-normalize.js
3-
nlcst-normalize.min.js
4-
*.json
52
*.md

index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
'use strict'
1+
import {toString} from 'nlcst-to-string'
22

3-
var toString = require('nlcst-to-string')
4-
5-
module.exports = normalize
6-
7-
function normalize(node, options) {
3+
export function normalize(node, options) {
84
var value = (typeof node === 'string' ? node : toString(node))
95
.toLowerCase()
106
.replace(//g, "'")

package.json

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,28 @@
2121
"contributors": [
2222
"Titus Wormer <[email protected]> (https://wooorm.com)"
2323
],
24+
"sideEffects": false,
25+
"type": "module",
26+
"main": "index.js",
2427
"files": [
2528
"index.js"
2629
],
2730
"dependencies": {
28-
"nlcst-to-string": "^2.0.0"
31+
"nlcst-to-string": "^3.0.0"
2932
},
3033
"devDependencies": {
31-
"browserify": "^17.0.0",
32-
"nyc": "^15.0.0",
34+
"c8": "^7.0.0",
3335
"prettier": "^2.0.0",
3436
"remark-cli": "^9.0.0",
3537
"remark-preset-wooorm": "^8.0.0",
3638
"tape": "^5.0.0",
37-
"tinyify": "^3.0.0",
38-
"xo": "^0.38.0"
39+
"xo": "^0.39.0"
3940
},
4041
"scripts": {
4142
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
42-
"build-bundle": "browserify . -s nlcstNormalize -o nlcst-normalize.js",
43-
"build-mangle": "browserify . -s nlcstNormalize -o nlcst-normalize.min.js -p tinyify",
44-
"build": "npm run build-bundle && npm run build-mangle",
45-
"test-api": "node test",
46-
"test-coverage": "nyc --reporter lcov tape test.js",
47-
"test": "npm run format && npm run build && npm run test-coverage"
48-
},
49-
"nyc": {
50-
"check-coverage": true,
51-
"lines": 100,
52-
"functions": 100,
53-
"branches": 100
43+
"test-api": "node test.js",
44+
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
45+
"test": "npm run format && npm run test-coverage"
5446
},
5547
"prettier": {
5648
"tabWidth": 2,
@@ -62,10 +54,10 @@
6254
},
6355
"xo": {
6456
"prettier": true,
65-
"esnext": false,
66-
"ignore": [
67-
"nlcst-normalize.js"
68-
]
57+
"rules": {
58+
"no-var": "off",
59+
"prefer-arrow-callback": "off"
60+
}
6961
},
7062
"remarkConfig": {
7163
"plugins": [

readme.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
## Install
1414

15+
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
16+
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
17+
1518
[npm][]:
1619

1720
```sh
@@ -21,7 +24,7 @@ npm install nlcst-normalize
2124
## Use
2225

2326
```js
24-
var normalize = require('nlcst-normalize')
27+
import {normalize} from 'nlcst-normalize'
2528

2629
normalize("Don't") // => 'dont'
2730
normalize('Don’t') // => 'dont'
@@ -41,6 +44,9 @@ normalize({
4144

4245
## API
4346

47+
This package exports the following identifiers: `normalize`.
48+
There is no default export.
49+
4450
### `normalize(value[, options])`
4551

4652
Normalize a word (`string`, [`Node`][node], `Array.<Node>`) for easier

test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
'use strict'
2-
3-
var test = require('tape')
4-
var normalize = require('.')
1+
import test from 'tape'
2+
import {normalize} from './index.js'
53

64
test('Basic', function (t) {
75
t.throws(function () {

0 commit comments

Comments
 (0)