File tree Expand file tree Collapse file tree 6 files changed +30
-34
lines changed Expand file tree Collapse file tree 6 files changed +30
-34
lines changed Original file line number Diff line number Diff line change 11.DS_Store
22* .log
3- .nyc_output /
43coverage /
54node_modules /
65yarn.lock
Original file line number Diff line number Diff line change 11coverage /
2- * .json
32* .md
Original file line number Diff line number Diff line change 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
84Index . prototype . get = get
95Index . prototype . add = add
106Index . 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 ) ) {
Original file line number Diff line number Diff line change 3232 " Eugene Sharygin <[email protected] >" ,
3333 " Titus Wormer <[email protected] > (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 ,
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" : [
Original file line number Diff line number Diff 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
5561Create an index data structure that maps keys (calculated by ` keyFn ` function or
5662the 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
Original file line number Diff line number Diff line change 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
86var index = Index
97
You can’t perform that action at this time.
0 commit comments