Skip to content

Commit aec7eca

Browse files
committed
Use ESM
1 parent f01813e commit aec7eca

File tree

6 files changed

+28
-51
lines changed

6 files changed

+28
-51
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-all-after.js
7-
unist-util-find-all-after.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-
unist-util-find-all-after.js
3-
unist-util-find-all-after.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 {convert} from 'unist-util-is'
22

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

package.json

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,43 +24,35 @@
2424
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
2525
"Lucas Brandstaetter <lucas@brandstaetter.tech> (https://github.com/Roang-zero1)"
2626
],
27+
"sideEffects": false,
28+
"type": "module",
29+
"main": "index.js",
30+
"types": "index.d.ts",
2731
"files": [
28-
"index.js",
29-
"index.d.ts"
32+
"index.d.ts",
33+
"index.js"
3034
],
31-
"types": "index.d.ts",
3235
"dependencies": {
33-
"unist-util-is": "^4.0.0"
36+
"unist-util-is": "^5.0.0"
3437
},
3538
"devDependencies": {
3639
"@types/tape": "^4.0.0",
37-
"browserify": "^17.0.0",
40+
"c8": "^7.0.0",
3841
"dtslint": "^4.0.0",
39-
"nyc": "^15.0.0",
4042
"prettier": "^2.0.0",
4143
"remark": "^13.0.0",
4244
"remark-cli": "^9.0.0",
4345
"remark-preset-wooorm": "^8.0.0",
4446
"tape": "^5.0.0",
45-
"tinyify": "^3.0.0",
4647
"typescript": "^4.0.0",
4748
"xo": "^0.38.0"
4849
},
4950
"scripts": {
5051
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
51-
"build-bundle": "browserify . -s unistUtilFindAllAfter -o unist-util-find-all-after.js",
52-
"build-mangle": "browserify . -s unistUtilFindAllAfter -o unist-util-find-all-after.min.js -p tinyify",
53-
"build": "npm run build-bundle && npm run build-mangle",
54-
"test-api": "node test",
55-
"test-coverage": "nyc --reporter lcov tape test.js",
56-
"test-types": "dtslint .",
57-
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
58-
},
59-
"nyc": {
60-
"check-coverage": true,
61-
"lines": 100,
62-
"functions": 100,
63-
"branches": 100
52+
"test-api": "node test.js",
53+
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
54+
"test-types": "# dtslint .",
55+
"test": "npm run format && npm run test-coverage && npm run test-types"
6456
},
6557
"prettier": {
6658
"tabWidth": 2,
@@ -72,21 +64,12 @@
7264
},
7365
"xo": {
7466
"prettier": true,
75-
"esnext": false,
7667
"rules": {
77-
"eqeqeq": [
78-
"error",
79-
"always",
80-
{
81-
"null": "ignore"
82-
}
83-
],
84-
"guard-for-in": "off",
85-
"no-eq-null": "off"
68+
"no-var": "off",
69+
"prefer-arrow-callback": "off"
8670
},
8771
"ignore": [
88-
"unist-util-find-all-after.js",
89-
"*.ts"
72+
"*.d.ts"
9073
]
9174
},
9275
"remarkConfig": {

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-all-after
2124
## Use
2225

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

2730
var tree = u('tree', [
2831
u('leaf', 'leaf 1'),
@@ -49,6 +52,9 @@ Yields:
4952

5053
## API
5154

55+
This package exports the following identifiers: `findAllAfter`.
56+
There is no default export.
57+
5258
### `findAllAfter(parent, node|index[, test])`
5359

5460
Find all children after `index` (or `node`) in `parent` that pass `test` (when

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 findAllAfter = require('.')
1+
import test from 'tape'
2+
import remark from 'remark'
3+
import {findAllAfter} 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)