Skip to content

Commit

Permalink
Add improved jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jun 3, 2022
1 parent d262197 commit cc14892
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@

import {convert} from 'unist-util-is'

/**
* Find the first node in `parent` before another `node` or before an index,
* that passes `test`.
* @param parent
* Parent node.
* @param index
* Child of `parent`, or it’s index.
* @param [test]
* `unist-util-is`-compatible test.
* @returns
*
*/
export const findBefore =
/**
* @type {(
Expand All @@ -18,9 +31,9 @@ export const findBefore =
*/
(
/**
* @param {Parent} parent Parent node
* @param {Node|number} index Child of `parent`, or it’s index
* @param {null|undefined|Type|Props|TestFunctionAnything|Array<Type|Props|TestFunctionAnything>} [test] is-compatible test (such as a type)
* @param {Parent} parent
* @param {Node|number} index
* @param {null|undefined|Type|Props|TestFunctionAnything|Array<Type|Props|TestFunctionAnything>} [test]
* @returns {Node|null}
*/
function (parent, index, test) {
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ There is no default export.

### `findBefore(parent, node|index[, test])`

Find the first node in `parent` ([`Parent`][parent]) before another node
Find the first node in `parent` ([`Parent`][parent]) before another `node`
([`Node`][node]) or before an index, that passes `test` (`Test` from
[`unist-util-is`][test]).

Expand Down

0 comments on commit cc14892

Please sign in to comment.