File tree Expand file tree Collapse file tree 6 files changed +55
-32
lines changed Expand file tree Collapse file tree 6 files changed +55
-32
lines changed Original file line number Diff line number Diff line change
1
+ coverage /
2
+ * .md
Original file line number Diff line number Diff line change 1
- var remark = require ( 'remark' )
2
- var find = require ( './index.js' )
1
+ const remark = require ( 'remark' )
2
+ const find = require ( './index.js' )
3
3
4
4
remark ( )
5
5
. use ( function ( ) {
6
6
return function ( tree ) {
7
- // string condition
7
+ // String condition
8
8
console . log ( find ( tree , 'value' ) )
9
9
10
- // object condition
11
- console . log ( find ( tree , { value : 'emphasis' } ) )
10
+ // Object condition
11
+ console . log ( find ( tree , { value : 'emphasis' } ) )
12
12
13
- // function condition
14
- console . log ( find ( tree , function ( node ) {
15
- return node . type === 'inlineCode'
16
- } ) )
13
+ // Function condition
14
+ console . log (
15
+ find ( tree , function ( node ) {
16
+ return node . type === 'inlineCode'
17
+ } )
18
+ )
17
19
}
18
20
} )
19
21
. processSync ( 'Some _emphasis_, **strongness**, and `code`.' )
Original file line number Diff line number Diff line change 15
15
* Finds first node for which function returns true when passed node as argument.
16
16
*/
17
17
18
- var visit = require ( 'unist-util-visit' )
19
- var iteratee = require ( 'lodash.iteratee' )
18
+ const visit = require ( 'unist-util-visit' )
19
+ const iteratee = require ( 'lodash.iteratee' )
20
+
21
+ module . exports = find
20
22
21
23
/**
22
24
* Unist node finder utility.
@@ -29,7 +31,7 @@ var iteratee = require('lodash.iteratee')
29
31
* The first node that matches condition, or undefined if no node matches.
30
32
* @type {<V extends Node>(tree: Node, condition: TestStr | TestObj | TestFn) => V | undefined }
31
33
*/
32
- module . exports = function find ( tree , condition ) {
34
+ function find ( tree , condition ) {
33
35
if ( ! tree ) throw new Error ( 'unist-util-find requires a tree to search' )
34
36
if ( ! condition ) throw new Error ( 'unist-util-find requires a condition' )
35
37
Original file line number Diff line number Diff line change 12
12
"sideEffects" : false ,
13
13
"scripts" : {
14
14
"prepack" : " npm run build" ,
15
- "test" : " standard && node test.js" ,
15
+ "format" : " prettier . -w --loglevel warn && xo --fix" ,
16
+ "test-api" : " node --conditions development test.js" ,
17
+ "test" : " npm run format && npm run test-api" ,
16
18
"build" : " tsc"
17
19
},
18
20
"type" : " commonjs" ,
32
34
"devDependencies" : {
33
35
"@types/lodash.iteratee" : " ^4.7.7" ,
34
36
"@types/unist" : " ^2.0.6" ,
37
+ "prettier" : " ^2.0.0" ,
35
38
"remark" : " ^13.0.0" ,
36
- "standard" : " ^8.0.0" ,
37
39
"tape" : " ^5.3.1" ,
38
- "typescript" : " ^4.6.4"
40
+ "typescript" : " ^4.6.4" ,
41
+ "xo" : " ^0.54.0"
39
42
},
40
43
"dependencies" : {
41
44
"lodash.iteratee" : " ^4.7.0" ,
42
45
"unist-util-visit" : " ^2.0.0"
46
+ },
47
+ "prettier" : {
48
+ "bracketSpacing" : false ,
49
+ "semi" : false ,
50
+ "singleQuote" : true ,
51
+ "tabWidth" : 2 ,
52
+ "trailingComma" : " none" ,
53
+ "useTabs" : false
54
+ },
55
+ "xo" : {
56
+ "rules" : {
57
+ "unicorn/prefer-module" : " off"
58
+ },
59
+ "prettier" : true
43
60
}
44
61
}
Original file line number Diff line number Diff line change 1
- var test = require ( 'tape' )
2
- var remark = require ( 'remark' )
3
- var find = require ( './index.js' )
1
+ const test = require ( 'tape' )
2
+ const remark = require ( 'remark' )
3
+ const find = require ( './index.js' )
4
4
5
5
test ( 'unist-find' , function ( t ) {
6
6
const tree = remark ( ) . parse ( 'Some _emphasis_, **strongness**, and `code`.' )
@@ -22,7 +22,7 @@ test('unist-find', function (t) {
22
22
} )
23
23
24
24
t . test ( 'should find with object condition' , function ( st ) {
25
- const result = find ( tree , { type : 'emphasis' } )
25
+ const result = find ( tree , { type : 'emphasis' } )
26
26
27
27
st . equal ( result , tree . children [ 0 ] . children [ 1 ] )
28
28
Original file line number Diff line number Diff line change 1
1
{
2
- "compilerOptions" : {
3
- "target" : " ES2020" ,
4
- "module" : " ES2020" ,
5
- "moduleResolution" : " node" ,
6
- "strict" : true ,
7
- "allowJs" : true ,
8
- "checkJs" : true ,
9
- "allowSyntheticDefaultImports" : true ,
10
- "declaration" : true ,
11
- "emitDeclarationOnly" : true ,
12
- "skipLibCheck" : true
13
- },
14
- "include" : [" index.js" ]
2
+ "compilerOptions" : {
3
+ "target" : " ES2020" ,
4
+ "module" : " ES2020" ,
5
+ "moduleResolution" : " node" ,
6
+ "strict" : true ,
7
+ "allowJs" : true ,
8
+ "checkJs" : true ,
9
+ "allowSyntheticDefaultImports" : true ,
10
+ "declaration" : true ,
11
+ "emitDeclarationOnly" : true ,
12
+ "skipLibCheck" : true
13
+ },
14
+ "include" : [" index.js" ]
15
15
}
You can’t perform that action at this time.
0 commit comments