JSPM

@flex-development/unist-util-types

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 24
  • Score
    100M100P100Q56829F
  • License BSD-3-Clause

unist utility types

Package Exports

  • @flex-development/unist-util-types
  • @flex-development/unist-util-types/package.json

Readme

unist-util-types

github release npm module type: esm license conventional commits typescript vitest yarn

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>

Extract children from tree T.

  • T (Node): tree to try extracting children from

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

source: src/decrement.ts

InclusiveDescendant<Tree[, Max][, Depth]>

Collect all inclusive descendants of Tree.

  • Tree (Node): tree to collect descendants from
  • Max (Uint): maximum search depth
    • default: 10
  • Depth (Uint): current search depth
    • default: 0

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

source: src/increment.ts

IsAncestor<Tree, Child[, Max][, Depth]>

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
  • Depth (Uint): current search depth
    • default: 0

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.

  • Tree (Node): tree to collect parents from
  • Child (Node): expected child node
    • default: any

source: src/parents.ts

PositionalInfo<[T]>

Object containing the positional information of node T.

  • T (Node): node to get positional information from

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.