Skip to content

Commit 90c3158

Browse files
committed
Use ESM
1 parent 47538d5 commit 90c3158

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-to-string.js
7-
nlcst-to-string.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-to-string.js
3-
nlcst-to-string.min.js
4-
*.json
52
*.md

index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
'use strict'
2-
3-
module.exports = nlcstToString
4-
51
// Stringify one nlcst node or list of nodes.
6-
function nlcstToString(node, separator = '') {
2+
export function toString(node, separator = '') {
73
var values
84
var length
95
var children
@@ -27,7 +23,7 @@ function nlcstToString(node, separator = '') {
2723
values = []
2824

2925
while (length--) {
30-
values[length] = nlcstToString(children[length], separator)
26+
values[length] = toString(children[length], separator)
3127
}
3228

3329
return values.join(separator)

package.json

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,26 @@
2424
"Titus Wormer <[email protected]> (https://wooorm.com)",
2525
"Kenichiro Murata <[email protected]>"
2626
],
27+
"sideEffects": false,
28+
"type": "module",
29+
"main": "index.js",
2730
"files": [
2831
"index.js"
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-
"unist-builder": "^2.0.0",
39+
"unist-builder": "^3.0.0",
3940
"xo": "^0.38.0"
4041
},
4142
"scripts": {
4243
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
43-
"build-bundle": "browserify . -s nlcstToString -o nlcst-to-string.js",
44-
"build-mangle": "browserify . -s nlcstToString -p tinyify -o nlcst-to-string.min.js",
45-
"build": "npm run build-bundle && npm run build-mangle",
46-
"test-api": "node test",
47-
"test-coverage": "nyc --reporter lcov tape test.js",
48-
"test": "npm run format && npm run build && npm run test-coverage"
49-
},
50-
"nyc": {
51-
"check-coverage": true,
52-
"lines": 100,
53-
"functions": 100,
54-
"branches": 100
44+
"test-api": "node test.js",
45+
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
46+
"test": "npm run format && npm run test-coverage"
5547
},
5648
"prettier": {
5749
"tabWidth": 2,
@@ -63,10 +55,10 @@
6355
},
6456
"xo": {
6557
"prettier": true,
66-
"esnext": false,
67-
"ignore": [
68-
"nlcst-to-string.js"
69-
]
58+
"rules": {
59+
"no-var": "off",
60+
"prefer-arrow-callback": "off"
61+
}
7062
},
7163
"remarkConfig": {
7264
"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-to-string
2124
## Use
2225

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

2629
console.log(
2730
toString({
@@ -37,6 +40,9 @@ console.log(
3740

3841
## API
3942

43+
This package exports the following identifiers: `toString`.
44+
There is no default export.
45+
4046
### `toString(node[, separator])`
4147

4248
Stringify the given [nlcst][] node (or list of nodes).

test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
'use strict'
2-
3-
var test = require('tape')
4-
var u = require('unist-builder')
5-
var toString = require('.')
1+
import test from 'tape'
2+
import {u} from 'unist-builder'
3+
import {toString} from './index.js'
64

75
test('toString()', function (t) {
86
t.throws(

0 commit comments

Comments
 (0)