unist utility types
- What is this?
- Install
- Use
-
API
Ancestor<Tree, Child>
Children<T>
Decrement<[I]>
InclusiveDescendant<Tree[, Max][, Depth]>
Increment<[I]>
Index
IsAncestor<Tree, Child[, Max][, Depth]>
IsParent<Tree, Child>
Offset
Match<N, T>
MatchInclusiveDescendant<Tree, Check[, Max]>
Parents<Tree[, Child]>
PositionalInfo<[T]>
Test
-
TestFunction<[T][, P][, U]>
Type<[T]>
Uint
- Contribute
This package contains TypeScript definitions for working with unist and its ecosystem of utilities.
This package is ESM only.
In Node.js (version 18+) with yarn:
yarn add -D @flex-development/unist-util-types @types/unist
See Git - Protocols | Yarn for details regarding installing from Git.
import type {
Ancestor,
Children,
InclusiveDescendant,
Index,
Offset,
Match,
MatchInclusiveDescendant,
Parents,
PositionalInfo,
Test,
TestFunction,
Type
} from '@flex-development/unist-util-types'
Collect nodes in Tree
that can be ancestors of Child
.
source:
src/ancestor.ts
-
T
(Node
): tree to extract children from
source:
src/children.ts
Subtract 1
from I
while I
is in the range [1, 10]
.
-
I
(Uint
): number to subtract from-
default:
10
-
default:
source:
src/decrement.ts
Collect all inclusive descendants of Tree
.
-
Tree
(Node
): tree to collect descendants from -
Max
(Uint
): maximum search depth-
default:
10
-
default:
-
Depth
(Uint
): current search depth-
default:
0
-
default:
source:
src/descendant-inclusive.ts
Add 1
to I
while I
is in the range [0, 9]
.
-
I
(Uint
): number to add to-
default:
0
-
default:
source:
src/increment.ts
Number of preceding siblings of a child node.
source:
src/index-number.ts
Check if Tree
is an ancestor of Child
.
-
Tree
(Node
): tree to check -
Child
(Node
): expected child node -
Max
(Uint
): maximum search depth-
default:
10
-
default:
-
Depth
(Uint
): current search depth-
default:
0
-
default:
source:
src/is-ancestor.ts
Check if Tree
is the parent of Child
.
source:
src/is-parent.ts
Check if node N
passes a test.
source:
src/match.ts
Check if inclusive descendants of Tree
pass a test.
Index of a character in a source file.
source:
src/offset.ts
Collect nodes in Tree
that can be parents of Child
.
All parents will be included in the resulting union if Child
is any
.
source:
src/parents.ts
Object containing the positional information of tree T
.
source:
src/positional-info.ts
Union of test types for a Node
.
See unist-util-is
for more details.
source:
src/test.ts
Check if a node passes a test.
-
T
(Node
): node to check-
default:
Node
-
default:
-
P
(Parent
): parent(s) of nodeT
-
default:
Parent
-
default:
-
U
(any
):this
context-
default:
unknown
-
default:
Parameters:
-
node
(T
): node to check -
index
(Index
|undefined
): index ofnode
inparent.children
-
parent
(Parent
|undefined
): parent ofnode
Returns:
boolean | undefined | void
test result for node
source:
src/test-function.ts
source:
src/type.ts
Number used for iteration.
Range: [0, 10]
source:
src/uint.ts
See CONTRIBUTING.md
.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.