Skip to content

Commit 2f188b3

Browse files
committed
Use ESM
1 parent 1936a55 commit 2f188b3

File tree

6 files changed

+25
-43
lines changed

6 files changed

+25
-43
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-
unist-util-find-after.js
7-
unist-util-find-after.min.js
85
yarn.lock

.prettierignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
.nyc_output/
21
coverage/
3-
unist-util-find-after.js
4-
unist-util-find-after.min.js
5-
*.json
62
*.md

index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
'use strict'
1+
import {convert} from 'unist-util-is'
22

3-
var convert = require('unist-util-is/convert')
4-
5-
module.exports = findAfter
6-
7-
function findAfter(parent, index, test) {
3+
export function findAfter(parent, index, test) {
84
var is = convert(test)
95

106
if (!parent || !parent.type || !parent.children) {
117
throw new Error('Expected parent node')
128
}
139

1410
if (typeof index === 'number') {
15-
if (index < 0 || index === Infinity) {
11+
if (index < 0 || index === Number.POSITIVE_INFINITY) {
1612
throw new Error('Expected positive finite number as index')
1713
}
1814
} else {

package.json

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,29 @@
2222
"contributors": [
2323
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
2424
],
25+
"sideEffects": false,
26+
"type": "module",
27+
"main": "index.js",
2528
"files": [
2629
"index.js"
2730
],
2831
"dependencies": {
29-
"unist-util-is": "^4.0.0"
32+
"unist-util-is": "^5.0.0"
3033
},
3134
"devDependencies": {
32-
"browserify": "^17.0.0",
33-
"nyc": "^15.0.0",
35+
"c8": "^7.0.0",
3436
"prettier": "^2.0.0",
3537
"remark": "^13.0.0",
3638
"remark-cli": "^9.0.0",
3739
"remark-preset-wooorm": "^8.0.0",
3840
"tape": "^5.0.0",
39-
"tinyify": "^3.0.0",
4041
"xo": "^0.38.0"
4142
},
4243
"scripts": {
4344
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
44-
"build-bundle": "browserify . -s unistUtilFindAfter -o unist-util-find-after.js",
45-
"build-mangle": "browserify . -s unistUtilFindAfter -o unist-util-find-after.min.js -p tinyify",
46-
"build": "npm run build-bundle && npm run build-mangle",
47-
"test-api": "node test",
48-
"test-coverage": "nyc --reporter lcov tape test.js",
49-
"test": "npm run format && npm run build && npm run test-coverage"
50-
},
51-
"nyc": {
52-
"check-coverage": true,
53-
"lines": 100,
54-
"functions": 100,
55-
"branches": 100
45+
"test-api": "node test.js",
46+
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
47+
"test": "npm run format && npm run test-coverage"
5648
},
5749
"prettier": {
5850
"tabWidth": 2,
@@ -64,13 +56,10 @@
6456
},
6557
"xo": {
6658
"prettier": true,
67-
"esnext": false,
6859
"rules": {
69-
"unicorn/prefer-number-properties": "off"
70-
},
71-
"ignore": [
72-
"unist-util-find-after.js"
73-
]
60+
"no-var": "off",
61+
"prefer-arrow-callback": "off"
62+
}
7463
},
7564
"remarkConfig": {
7665
"plugins": [

readme.md

Lines changed: 8 additions & 2 deletions
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,8 +24,8 @@ npm install unist-util-find-after
2124
## Use
2225

2326
```js
24-
var u = require('unist-builder')
25-
var findAfter = require('unist-util-find-after')
27+
import {u} from 'unist-builder'
28+
import {findAfter} from 'unist-util-find-after'
2629

2730
var tree = u('tree', [
2831
u('leaf', 'leaf 1'),
@@ -45,6 +48,9 @@ Yields:
4548

4649
## API
4750

51+
This package exports the following identifiers: `findAfter`.
52+
There is no default export.
53+
4854
### `findAfter(parent, node|index[, test])`
4955

5056
Find the first [child][] after `index` (or `node`) in `parent`, that passes

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 remark = require('remark')
5-
var findAfter = require('.')
1+
import test from 'tape'
2+
import remark from 'remark'
3+
import {findAfter} from './index.js'
64

75
var tree = remark().parse('Some _emphasis_, **importance**, and `code`.')
86
var paragraph = tree.children[0]

0 commit comments

Comments
 (0)