Skip to content

Commit 2e4b854

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

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

lib/index.js

Lines changed: 9 additions & 12 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'
@@ -16,25 +13,25 @@ import {convert} from 'unist-util-is'
1613
* @param parent
1714
* Parent node.
1815
* @param index
19-
* Child of `parent`, or it’s index.
20-
* @param [test]
16+
* Child of `parent` or it’s index.
17+
* @param test
2118
* `unist-util-is`-compatible test.
2219
* @returns
23-
* Child of `parent` that passes `test`, if found.
20+
* Child of `parent` or `null`.
2421
*/
2522
export const findAfter =
2623
/**
2724
* @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)
25+
* (<T extends Node>(node: Parent, index: Node | number, test: import('unist-util-is').PredicateTest<T>) => T | null) &
26+
* ((node: Parent, index: Node | number, test?: Test) => Node | null)
3027
* )}
3128
*/
3229
(
3330
/**
3431
* @param {Parent} parent
35-
* @param {Node|number} index
36-
* @param {null|undefined|Type|Props|TestFunctionAnything|Array<Type|Props|TestFunctionAnything>} [test]
37-
* @returns {Node|null}
32+
* @param {Node | number} index
33+
* @param {Test} [test]
34+
* @returns {Node | null}
3835
*/
3936
function (parent, index, test) {
4037
const is = convert(test)

0 commit comments

Comments
 (0)