Skip to content

Commit 04eb187

Browse files
committed
Change to use ESM
1 parent e81e650 commit 04eb187

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

1919
remark()
2020
.use(function () {

index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
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

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
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",
@@ -62,9 +62,6 @@
6262
"strict": true
6363
},
6464
"xo": {
65-
"rules": {
66-
"unicorn/prefer-module": "off"
67-
},
6865
"prettier": true
6966
}
7067
}

test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
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

1010
test('unist-find', function (t) {
1111
const tree = /** @type {Root} */ (

0 commit comments

Comments
 (0)