Skip to content

Commit 9867ff4

Browse files
committed
Use ESM
1 parent c64ba93 commit 9867ff4

File tree

6 files changed

+30
-34
lines changed

6 files changed

+30
-34
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.DS_Store
22
*.log
3-
.nyc_output/
43
coverage/
54
node_modules/
65
yarn.lock

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
coverage/
2-
*.json
32
*.md

index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
'use strict'
2-
3-
var Map = require('es6-map')
4-
var visit = require('unist-util-visit')
5-
6-
module.exports = Index
1+
import Map from 'es6-map'
2+
import {visit} from 'unist-util-visit'
73

84
Index.prototype.get = get
95
Index.prototype.add = add
106
Index.prototype.remove = remove
117

12-
function Index(tree, filter, prop) {
8+
export function Index(tree, filter, prop) {
139
var self
1410

1511
if (!(this instanceof Index)) {

package.json

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,32 @@
3232
"Eugene Sharygin <eush77@gmail.com>",
3333
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
3434
],
35+
"sideEffects": false,
36+
"type": "module",
37+
"main": "index.js",
3538
"files": [
3639
"index.js"
3740
],
3841
"dependencies": {
3942
"es6-map": "^0.1.0",
40-
"unist-util-visit": "^2.0.0"
43+
"unist-util-visit": "^3.0.0"
4144
},
4245
"devDependencies": {
43-
"nyc": "^15.0.0",
46+
"c8": "^7.0.0",
4447
"prettier": "^2.0.0",
4548
"remark-cli": "^9.0.0",
4649
"remark-preset-wooorm": "^8.0.0",
4750
"tape": "^5.0.0",
48-
"unist-builder": "^2.0.0",
49-
"unist-util-select": "^3.0.0",
51+
"unist-builder": "^3.0.0",
52+
"unist-util-select": "^4.0.0",
5053
"xo": "^0.38.0"
5154
},
5255
"scripts": {
5356
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
54-
"test-api": "node test",
55-
"test-coverage": "nyc --reporter lcov tape test.js",
57+
"test-api": "node test.js",
58+
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
5659
"test": "npm run format && npm run test-coverage"
5760
},
58-
"nyc": {
59-
"check-coverage": true,
60-
"lines": 100,
61-
"functions": 100,
62-
"branches": 100
63-
},
6461
"prettier": {
6562
"tabWidth": 2,
6663
"useTabs": false,
@@ -73,9 +70,10 @@
7370
"prettier": true,
7471
"rules": {
7572
"unicorn/no-this-assignment": "off",
76-
"unicorn/prefer-includes": "off"
77-
},
78-
"esnext": false
73+
"unicorn/prefer-includes": "off",
74+
"no-var": "off",
75+
"prefer-arrow-callback": "off"
76+
}
7977
},
8078
"remarkConfig": {
8179
"plugins": [

readme.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ computed keys back to nodes.
1313

1414
## Install
1515

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

1821
```sh
@@ -50,7 +53,10 @@ Yields:
5053

5154
## API
5255

53-
### `Index([tree[, test], ]prop|keyFn)`
56+
This package exports the following identifiers: `Index`.
57+
There is no default export.
58+
59+
### `class Index([tree[, test], ]prop|keyFn)`
5460

5561
Create an index data structure that maps keys (calculated by `keyFn` function or
5662
the values at `prop` in each node) to a list of nodes.
@@ -60,9 +66,9 @@ by `test`.
6066

6167
###### Signatures
6268

63-
* `Index(prop|keyFn)`
64-
* `Index(tree, prop|keyFn)`
65-
* `Index(tree, test, prop|keyFn)`
69+
* `new Index(prop|keyFn)`
70+
* `new Index(tree, prop|keyFn)`
71+
* `new Index(tree, test, prop|keyFn)`
6672

6773
###### Parameters
6874

test.js

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

86
var index = Index
97

0 commit comments

Comments
 (0)