-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-function.ts
More file actions
38 lines (35 loc) · 857 Bytes
/
test-function.ts
File metadata and controls
38 lines (35 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @file TestFunction
* @module unist-util-types/TestFunction
*/
import type { Node, Parent } from 'unist'
import type Index from './index-number'
/**
* Check if `node` passes a test.
*
* @see {@linkcode Index}
* @see {@linkcode Node}
* @see {@linkcode Parent}
*
* @template {Node} [T=Node] - Node to check
* @template {Parent} [P=Parent] - Parent of node
* @template {any} [U=unknown] - `this` context
*
* @this {U}
*
* @param {T} node - Node to check
* @param {Index?} [index] - Index of `node` in `parent.children`
* @param {P?} [parent] - Parent of `node`
* @return {boolean | undefined | void} Test result
*/
type TestFunction<
T extends Node = Node,
P extends Parent = Parent,
U = unknown
> = (
this: U,
node: T,
index?: Index,
parent?: P
) => boolean | undefined | void
export type { TestFunction as default }