Skip to content

Commit 2f449e3

Browse files
committed
Update dependencies
1 parent 04eb187 commit 2f449e3

File tree

4 files changed

+47
-54
lines changed

4 files changed

+47
-54
lines changed

README.md

+37-37
Original file line numberDiff line numberDiff line change
@@ -13,57 +13,57 @@ npm install --save unist-util-find
1313
### Example
1414

1515
```js
16-
import {remark} from 'remark'
17-
import {find} from 'unist-util-find'
18-
19-
remark()
20-
.use(function () {
21-
return function (tree) {
22-
// string condition
23-
console.log(find(tree, 'value'))
24-
25-
// object condition
26-
console.log(find(tree, { value: 'emphasis' }))
27-
28-
// function condition
29-
console.log(find(tree, function (node) {
30-
return node.type === 'inlineCode'
31-
}))
32-
}
33-
})
34-
.processSync('Some _emphasis_, **strongness**, and `code`.')
16+
import {fromMarkdown} from 'mdast-util-from-markdown'
17+
import {find} from './index.js'
18+
19+
const tree = fromMarkdown('Some _emphasis_, **strongness**, and `code`.')
20+
21+
// String condition
22+
console.log(find(tree, 'value'))
3523

24+
// Object condition
25+
console.log(find(tree, {value: 'emphasis'}))
26+
27+
// Function condition
28+
console.log(
29+
find(tree, function (node) {
30+
return node.type === 'inlineCode'
31+
})
32+
)
3633
```
3734

3835
Result:
3936

4037
```
4138
// string condition: 'value'
42-
{ type: 'text',
39+
{
40+
type: 'text',
4341
value: 'Some ',
44-
position:
45-
Position {
46-
start: { line: 1, column: 1, offset: 0 },
47-
end: { line: 1, column: 6, offset: 5 },
48-
indent: [] } }
42+
position: {
43+
start: { line: 1, column: 1, offset: 0 },
44+
end: { line: 1, column: 6, offset: 5 }
45+
}
46+
}
4947
5048
// object condition: { value: 'emphasis' }
51-
{ type: 'text',
49+
{
50+
type: 'text',
5251
value: 'emphasis',
53-
position:
54-
Position {
55-
start: { line: 1, column: 7, offset: 6 },
56-
end: { line: 1, column: 15, offset: 14 },
57-
indent: [] } }
52+
position: {
53+
start: { line: 1, column: 7, offset: 6 },
54+
end: { line: 1, column: 15, offset: 14 }
55+
}
56+
}
5857
5958
// function condition: function (node) { return node.type === 'inlineCode' }
60-
{ type: 'inlineCode',
59+
{
60+
type: 'inlineCode',
6161
value: 'code',
62-
position:
63-
Position {
64-
start: { line: 1, column: 38, offset: 37 },
65-
end: { line: 1, column: 44, offset: 43 },
66-
indent: [] } }
62+
position: {
63+
start: { line: 1, column: 38, offset: 37 },
64+
end: { line: 1, column: 44, offset: 43 }
65+
}
66+
}
6767
```
6868

6969
### API

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Finds first node for which function returns true when passed node as argument.
1616
*/
1717

18-
import visit from 'unist-util-visit'
18+
import {visit} from 'unist-util-visit'
1919
import iteratee from 'lodash.iteratee'
2020

2121
/**

package.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,21 @@
3131
],
3232
"author": "Richard Smith-Unna <[email protected]> @blahah",
3333
"license": "MIT",
34+
"dependencies": {
35+
"lodash.iteratee": "^4.0.0",
36+
"unist-util-visit": "^4.0.0"
37+
},
3438
"devDependencies": {
35-
"@types/lodash.iteratee": "^4.7.7",
36-
"@types/mdast": "^3.0.0",
39+
"@types/lodash.iteratee": "^4.0.0",
3740
"@types/tape": "^5.0.0",
3841
"@types/unist": "^2.0.6",
42+
"mdast-util-from-markdown": "^1.0.0",
3943
"prettier": "^2.0.0",
40-
"remark": "^13.0.0",
41-
"tape": "^5.3.1",
44+
"tape": "^5.0.0",
4245
"type-coverage": "^2.0.0",
4346
"typescript": "^5.0.0",
4447
"xo": "^0.54.0"
4548
},
46-
"dependencies": {
47-
"lodash.iteratee": "^4.7.0",
48-
"unist-util-visit": "^2.0.0"
49-
},
5049
"prettier": {
5150
"bracketSpacing": false,
5251
"semi": false,

test.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
/**
2-
* @typedef {import('mdast').Root} Root
3-
*/
4-
51
import assert from 'node:assert/strict'
62
import test from 'tape'
7-
import remark from 'remark'
3+
import {fromMarkdown} from 'mdast-util-from-markdown'
84
import {find} from './index.js'
95

106
test('unist-find', function (t) {
11-
const tree = /** @type {Root} */ (
12-
remark().parse('Some _emphasis_, **strongness**, and `code`.')
13-
)
7+
const tree = fromMarkdown('Some _emphasis_, **strongness**, and `code`.')
148
assert(tree.type === 'root')
159
const paragraph = tree.children[0]
1610
assert(paragraph.type === 'paragraph')

0 commit comments

Comments
 (0)