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' )
33
44remark ( )
55 . use ( function ( ) {
66 return function ( tree ) {
7- // string condition
7+ // String condition
88 console . log ( find ( tree , 'value' ) )
99
10- // object condition
11- console . log ( find ( tree , { value : 'emphasis' } ) )
10+ // Object condition
11+ console . log ( find ( tree , { value : 'emphasis' } ) )
1212
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+ )
1719 }
1820 } )
1921 . processSync ( 'Some _emphasis_, **strongness**, and `code`.' )
Original file line number Diff line number Diff line change 1515 * Finds first node for which function returns true when passed node as argument.
1616 */
1717
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
2022
2123/**
2224 * Unist node finder utility.
@@ -29,7 +31,7 @@ var iteratee = require('lodash.iteratee')
2931 * The first node that matches condition, or undefined if no node matches.
3032 * @type {<V extends Node>(tree: Node, condition: TestStr | TestObj | TestFn) => V | undefined }
3133 */
32- module . exports = function find ( tree , condition ) {
34+ function find ( tree , condition ) {
3335 if ( ! tree ) throw new Error ( 'unist-util-find requires a tree to search' )
3436 if ( ! condition ) throw new Error ( 'unist-util-find requires a condition' )
3537
Original file line number Diff line number Diff line change 1212 "sideEffects" : false ,
1313 "scripts" : {
1414 "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" ,
1618 "build" : " tsc"
1719 },
1820 "type" : " commonjs" ,
3234 "devDependencies" : {
3335 "@types/lodash.iteratee" : " ^4.7.7" ,
3436 "@types/unist" : " ^2.0.6" ,
37+ "prettier" : " ^2.0.0" ,
3538 "remark" : " ^13.0.0" ,
36- "standard" : " ^8.0.0" ,
3739 "tape" : " ^5.3.1" ,
38- "typescript" : " ^4.6.4"
40+ "typescript" : " ^4.6.4" ,
41+ "xo" : " ^0.54.0"
3942 },
4043 "dependencies" : {
4144 "lodash.iteratee" : " ^4.7.0" ,
4245 "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
4360 }
4461}
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' )
44
55test ( 'unist-find' , function ( t ) {
66 const tree = remark ( ) . parse ( 'Some _emphasis_, **strongness**, and `code`.' )
@@ -22,7 +22,7 @@ test('unist-find', function (t) {
2222 } )
2323
2424 t . test ( 'should find with object condition' , function ( st ) {
25- const result = find ( tree , { type : 'emphasis' } )
25+ const result = find ( tree , { type : 'emphasis' } )
2626
2727 st . equal ( result , tree . children [ 0 ] . children [ 1 ] )
2828
Original file line number Diff line number Diff line change 11{
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" ]
1515}
You can’t perform that action at this time.
0 commit comments