Skip to content

Commit 8372200

Browse files
committed
Refactor code-style
* Add more docs to JSDoc * Add support for `null` in input of API types
1 parent 337a25e commit 8372200

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lib/index.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
/**
22
* @typedef {import('unist').Node} Node
33
* @typedef {import('unist').Parent} Parent
4-
*
5-
* @typedef {string} Type
6-
* @typedef {Record<string, unknown>} Props
7-
* @typedef {import('unist-util-is').TestFunctionAnything} TestFunctionAnything
4+
* @typedef {import('unist-util-is').Test} Test
85
*/
96

107
import {convert} from 'unist-util-is'
@@ -17,24 +14,25 @@ import {convert} from 'unist-util-is'
1714
* Parent node.
1815
* @param index
1916
* Child of `parent`, or it’s index.
20-
* @param [test]
17+
* @param test
2118
* `unist-util-is`-compatible test.
2219
* @returns
20+
* Child of `parent` or `null`.
2321
*
2422
*/
2523
export const findBefore =
2624
/**
2725
* @type {(
28-
* (<T extends Node>(node: Parent, index: Node|number, test: T['type']|Partial<T>|import('unist-util-is').TestFunctionPredicate<T>|Array<T['type']|Partial<T>|import('unist-util-is').TestFunctionPredicate<T>>) => T|null) &
29-
* ((node: Parent, index: Node|number, test?: null|undefined|Type|Props|TestFunctionAnything|Array<Type|Props|TestFunctionAnything>) => Node|null)
26+
* (<T extends Node>(node: Parent, index: Node | number, test: import('unist-util-is').PredicateTest<T>) => T | null) &
27+
* ((node: Parent, index: Node | number, test?: Test) => Node | null)
3028
* )}
3129
*/
3230
(
3331
/**
3432
* @param {Parent} parent
35-
* @param {Node|number} index
36-
* @param {null|undefined|Type|Props|TestFunctionAnything|Array<Type|Props|TestFunctionAnything>} [test]
37-
* @returns {Node|null}
33+
* @param {Node | number} index
34+
* @param {Test} [test]
35+
* @returns {Node | null}
3836
*/
3937
function (parent, index, test) {
4038
const is = convert(test)

0 commit comments

Comments
 (0)