Package Exports
- @flex-development/unist-util-types
- @flex-development/unist-util-types/package.json
Readme
unist-util-types
unist utility types
Contents
What is this?
This package contains TypeScript definitions for working with unist and its ecosystem of utilities.
Install
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.
Use
import type {
Ancestor,
Children,
InclusiveDescendant,
Parents,
PositionalInfo
} from '@flex-development/unist-util-types'
API
Ancestor<Tree, Child>
Collect nodes in Tree
that can be ancestors of Child
.
source:
src/ancestor.ts
Children<T>
source:
src/children.ts
Decrement<[N]>
Subtract 1
from N
while N
is in the range [1, 10]
.
N
(Uint
): number to subtract from- default:
10
- default:
source:
src/decrement.ts
InclusiveDescendant<Tree[, Max][, Depth]>
Collect all inclusive descendants of Tree
.
Tree
(Node
): tree to collect descendants fromMax
(Uint
): maximum search depth- default:
10
- default:
Depth
(Uint
): current search depth- default:
0
- default:
source:
src/descendant-inclusive.ts
Increment<[N]>
Add 1
to N
while N
is in the range [0, 9]
.
N
(Uint
): number to add to- default:
0
- default:
source:
src/increment.ts
IsAncestor<Tree, Child[, Max][, Depth]>
Check if Tree
is an ancestor of Child
.
Tree
(Node
): tree to checkChild
(Node
): expected child nodeMax
(Uint
): maximum search depth- default:
10
- default:
Depth
(Uint
): current search depth- default:
0
- default:
source:
src/is-ancestor.ts
IsParent<Tree, Child>
Check if Tree
is the parent of Child
.
source:
src/is-parent.ts
Parents<Tree[, Child]>
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
PositionalInfo<[T]>
Object containing the positional information of node T
.
source:
src/positional-info.ts
Uint
Number used for iteration.
Range: [0, 10]
source:
src/uint.ts
Contribute
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.