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
1313### Example
1414
1515``` 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'
1818
1919remark ()
2020 .use (function () {
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- 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'
2220
2321/**
2422 * Unist node finder utility.
@@ -32,7 +30,7 @@ module.exports = find
3230 * @returns {V | undefined }
3331 * The first node that matches condition, or `undefined` if no node matches.
3432 */
35- function find ( tree , condition ) {
33+ export function find ( tree , condition ) {
3634 if ( ! tree ) throw new Error ( 'unist-util-find requires a tree to search' )
3735 if ( ! condition ) throw new Error ( 'unist-util-find requires a condition' )
3836
Original file line number Diff line number Diff line change 33 "version" : " 1.0.4" ,
44 "description" : " Unist node finder utility. Useful for working with remark, rehype and retext." ,
55 "repository" : " https://github.com/blahah/unist-util-find" ,
6+ "sideEffects" : false ,
7+ "type" : " module" ,
68 "main" : " index.js" ,
79 "types" : " index.d.ts" ,
810 "files" : [
911 " index.d.ts" ,
1012 " index.js"
1113 ],
12- "sideEffects" : false ,
1314 "scripts" : {
1415 "prepack" : " npm run build && npm run format" ,
1516 "build" : " tsc --build --clean && tsc --build && type-coverage" ,
1617 "format" : " prettier . -w --loglevel warn && xo --fix" ,
1718 "test-api" : " node --conditions development test.js" ,
1819 "test" : " npm run build && npm run format && npm run test-api"
1920 },
20- "type" : " commonjs" ,
2121 "keywords" : [
2222 " unist" ,
2323 " remark" ,
6262 "strict" : true
6363 },
6464 "xo" : {
65- "rules" : {
66- "unicorn/prefer-module" : " off"
67- },
6865 "prettier" : true
6966 }
7067}
Original file line number Diff line number Diff line change 22 * @typedef {import('mdast').Root } Root
33 */
44
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'
99
1010test ( 'unist-find' , function ( t ) {
1111 const tree = /** @type {Root } */ (
You can’t perform that action at this time.
0 commit comments