Skip to content

Latest commit

 

History

History
executable file
·
391 lines (236 loc) · 9.49 KB

README.md

File metadata and controls

executable file
·
391 lines (236 loc) · 9.49 KB

Note This repository is automatically generated from the main parser monorepo. Please submit any issues or pull requests there.

xast-util-is-element

npm version npm downloads

Port of hast-util-is-element for xast

Contents

What is this?

When should I use this?

Install

This package is ESM only. In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install as

pnpm add xast-util-is-element
# or with yarn
# yarn add xast-util-is-element
# or with npm
# npm install xast-util-is-element

Use

API


convertElement()

Signature

convertElement<T>(test: T["name"] | TestFunctionPredicate<T>): AssertPredicate<T>;

Type parameters

  • T extends Element<T>

Parameters

Name Type
test T["name"]

Returns

AssertPredicate<T>

Defined in: lib/xast-util-is-element.ts:174

Signature

convertElement(test?: Test): AssertAnything;

Parameters

Name Type
test? Test

Returns

AssertAnything

Defined in: lib/xast-util-is-element.ts:177


isElement()

Signature

isElement(): false;

Returns

false

Defined in: lib/xast-util-is-element.ts:123

Signature

isElement<T>(
  node: unknown, 
  test?: PredicateTest<T>, 
  index?: number, 
  parent?: Parent<Node<Data>, Data>, 
  context?: unknown): node is T;

Type parameters

  • T extends Element<T> = Element

Parameters

Name Type
node unknown
test? PredicateTest<T>
index? number
parent? Parent<Node<Data>, Data>
context? unknown

Returns

node is T

Defined in: lib/xast-util-is-element.ts:124

Signature

isElement(
  node: unknown, 
  test: Test, 
  index?: number, 
  parent?: Parent<Node<Data>, Data>, 
  context?: unknown): boolean;

Parameters

Name Type
node unknown
test Test
index? number
parent? Parent<Node<Data>, Data>
context? unknown

Returns

boolean

Defined in: lib/xast-util-is-element.ts:131


AssertAnything

Function

Type declaration

Check if a node is an element and passes a certain node test

Signature
(node?: unknown, index?: number | null, parent?: Parent | null): boolean;
Parameters
Name Type
node? unknown
index? number
parent? Parent
Returns

boolean

Defined in: lib/xast-util-is-element.ts:40


AssertPredicate

<Y> Function

Type parameters

  • Y extends Element

Type declaration

Check if a node is an element and passes a certain node test

Signature
(node?: unknown, index?: number | null, parent?: Parent | null): node is Y;
Parameters
Name Type
node? unknown
index? number
parent? Parent
Returns

node is Y

Defined in: lib/xast-util-is-element.ts:50


Name

string

Defined in: lib/xast-util-is-element.ts:4


PredicateTest

<T> null | undefined | T["name"] | TestFunctionPredicate<T> | (T["name"] | TestFunctionPredicate<T>)[]

Type parameters

  • T extends Element

Defined in: lib/xast-util-is-element.ts:12


Test

null | undefined | Name | TestFunctionAnything | (Name | TestFunctionAnything)[]

Defined in: lib/xast-util-is-element.ts:5


TestFunctionAnything

Function

Type declaration

Check if an element passes a test

Signature
(element: Element, index?: number | null, parent?: Parent | null): boolean | void;
Parameters
Name Type
element Element
index? number
parent? Parent
Returns

boolean | void

Defined in: lib/xast-util-is-element.ts:22


TestFunctionPredicate

<X> Function

Type parameters

  • X extends Element

Type declaration

Check if an element passes a certain node test

Signature
(element: Element, index?: number | null, parent?: Parent | null): element is X;
Parameters
Name Type
element Element
index? number
parent? Parent
Returns

element is X

Defined in: lib/xast-util-is-element.ts:31

Syntax tree

Types

Compatibility

Security

Related

Contribute

License

MIT © Thomas F. K. Jorna