File tree Expand file tree Collapse file tree 4 files changed +11
-16
lines changed Expand file tree Collapse file tree 4 files changed +11
-16
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ npm install --save unist-util-find
13
13
### Example
14
14
15
15
``` js
16
- var remark = require ( ' remark' )
17
- var find = require ( ' unist-util-find' )
16
+ import { remark } from ' remark'
17
+ import { find } from ' unist-util-find'
18
18
19
19
remark ()
20
20
.use (function () {
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
- const visit = require ( 'unist-util-visit' )
19
- const iteratee = require ( 'lodash.iteratee' )
20
-
21
- module . exports = find
18
+ import visit from 'unist-util-visit'
19
+ import iteratee from 'lodash.iteratee'
22
20
23
21
/**
24
22
* Unist node finder utility.
@@ -32,7 +30,7 @@ module.exports = find
32
30
* @returns {V | undefined }
33
31
* The first node that matches condition, or `undefined` if no node matches.
34
32
*/
35
- function find ( tree , condition ) {
33
+ export function find ( tree , condition ) {
36
34
if ( ! tree ) throw new Error ( 'unist-util-find requires a tree to search' )
37
35
if ( ! condition ) throw new Error ( 'unist-util-find requires a condition' )
38
36
Original file line number Diff line number Diff line change 3
3
"version" : " 1.0.4" ,
4
4
"description" : " Unist node finder utility. Useful for working with remark, rehype and retext." ,
5
5
"repository" : " https://github.com/blahah/unist-util-find" ,
6
+ "sideEffects" : false ,
7
+ "type" : " module" ,
6
8
"main" : " index.js" ,
7
9
"types" : " index.d.ts" ,
8
10
"files" : [
9
11
" index.d.ts" ,
10
12
" index.js"
11
13
],
12
- "sideEffects" : false ,
13
14
"scripts" : {
14
15
"prepack" : " npm run build && npm run format" ,
15
16
"build" : " tsc --build --clean && tsc --build && type-coverage" ,
16
17
"format" : " prettier . -w --loglevel warn && xo --fix" ,
17
18
"test-api" : " node --conditions development test.js" ,
18
19
"test" : " npm run build && npm run format && npm run test-api"
19
20
},
20
- "type" : " commonjs" ,
21
21
"keywords" : [
22
22
" unist" ,
23
23
" remark" ,
62
62
"strict" : true
63
63
},
64
64
"xo" : {
65
- "rules" : {
66
- "unicorn/prefer-module" : " off"
67
- },
68
65
"prettier" : true
69
66
}
70
67
}
Original file line number Diff line number Diff line change 2
2
* @typedef {import('mdast').Root } Root
3
3
*/
4
4
5
- const assert = require ( 'node:assert/strict' )
6
- const test = require ( 'tape' )
7
- const remark = require ( 'remark' )
8
- const find = require ( './index.js' )
5
+ import assert from 'node:assert/strict'
6
+ import test from 'tape'
7
+ import remark from 'remark'
8
+ import { find } from './index.js'
9
9
10
10
test ( 'unist-find' , function ( t ) {
11
11
const tree = /** @type {Root } */ (
You can’t perform that action at this time.
0 commit comments