File tree Expand file tree Collapse file tree 6 files changed +25
-43
lines changed Expand file tree Collapse file tree 6 files changed +25
-43
lines changed Original file line number Diff line number Diff line change 1
1
.DS_Store
2
2
* .log
3
- .nyc_output /
4
3
coverage /
5
4
node_modules /
6
- unist-util-find-after.js
7
- unist-util-find-after.min.js
8
5
yarn.lock
Original file line number Diff line number Diff line change 1
- .nyc_output /
2
1
coverage /
3
- unist-util-find-after.js
4
- unist-util-find-after.min.js
5
- * .json
6
2
* .md
Original file line number Diff line number Diff line change 1
- 'use strict '
1
+ import { convert } from 'unist-util-is '
2
2
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 ) {
8
4
var is = convert ( test )
9
5
10
6
if ( ! parent || ! parent . type || ! parent . children ) {
11
7
throw new Error ( 'Expected parent node' )
12
8
}
13
9
14
10
if ( typeof index === 'number' ) {
15
- if ( index < 0 || index === Infinity ) {
11
+ if ( index < 0 || index === Number . POSITIVE_INFINITY ) {
16
12
throw new Error ( 'Expected positive finite number as index' )
17
13
}
18
14
} else {
Original file line number Diff line number Diff line change 22
22
"contributors" : [
23
23
" Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
24
24
],
25
+ "sideEffects" : false ,
26
+ "type" : " module" ,
27
+ "main" : " index.js" ,
25
28
"files" : [
26
29
" index.js"
27
30
],
28
31
"dependencies" : {
29
- "unist-util-is" : " ^4 .0.0"
32
+ "unist-util-is" : " ^5 .0.0"
30
33
},
31
34
"devDependencies" : {
32
- "browserify" : " ^17.0.0" ,
33
- "nyc" : " ^15.0.0" ,
35
+ "c8" : " ^7.0.0" ,
34
36
"prettier" : " ^2.0.0" ,
35
37
"remark" : " ^13.0.0" ,
36
38
"remark-cli" : " ^9.0.0" ,
37
39
"remark-preset-wooorm" : " ^8.0.0" ,
38
40
"tape" : " ^5.0.0" ,
39
- "tinyify" : " ^3.0.0" ,
40
41
"xo" : " ^0.38.0"
41
42
},
42
43
"scripts" : {
43
44
"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"
56
48
},
57
49
"prettier" : {
58
50
"tabWidth" : 2 ,
64
56
},
65
57
"xo" : {
66
58
"prettier" : true ,
67
- "esnext" : false ,
68
59
"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
+ }
74
63
},
75
64
"remarkConfig" : {
76
65
"plugins" : [
Original file line number Diff line number Diff line change 12
12
13
13
## Install
14
14
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
+
15
18
[ npm] [ ] :
16
19
17
20
``` sh
@@ -21,8 +24,8 @@ npm install unist-util-find-after
21
24
## Use
22
25
23
26
``` 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'
26
29
27
30
var tree = u (' tree' , [
28
31
u (' leaf' , ' leaf 1' ),
@@ -45,6 +48,9 @@ Yields:
45
48
46
49
## API
47
50
51
+ This package exports the following identifiers: ` findAfter ` .
52
+ There is no default export.
53
+
48
54
### ` findAfter(parent, node|index[, test]) `
49
55
50
56
Find the first [ child] [ ] after ` index ` (or ` node ` ) in ` parent ` , that passes
Original file line number Diff line number Diff line change 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'
6
4
7
5
var tree = remark ( ) . parse ( 'Some _emphasis_, **importance**, and `code`.' )
8
6
var paragraph = tree . children [ 0 ]
You can’t perform that action at this time.
0 commit comments