YouTube.js
Guide
Discord
GitHub
Guide
Discord
GitHub

youtubei.js / YTNodes / Element

Class: Element

Extends

  • YTNode

Constructors

new Element()

new Element(data): Element

Parameters

• data: RawNode

Returns

Element

Overrides

YTNode.constructor

Defined in

src/parser/classes/Element.ts:11

Properties

child_elements?

optional child_elements: ObservedArray<ChildElement>

Defined in

src/parser/classes/Element.ts:9


model?

optional model: YTNode

Defined in

src/parser/classes/Element.ts:8


type

readonly type: string

Inherited from

YTNode.type

Defined in

src/parser/helpers.ts:8


type

static type: string = 'Element'

Overrides

YTNode.type

Defined in

src/parser/classes/Element.ts:6

Methods

as()

as<T, K>(...types): InstanceType<K[number]>

Cast to one of the given types.

Type Parameters

• T extends YTNode

• K extends YTNodeConstructor<T>[]

Parameters

• ...types: K

The types to cast to

Returns

InstanceType<K[number]>

The node cast to one of the given types

Throws

If the node is not of the given type

Inherited from

YTNode.as

Defined in

src/parser/helpers.ts:38


hasKey()

hasKey<T, R>(key): this is Element & { [k in string]: R }

Check for a key without asserting the type.

Type Parameters

• T extends string

• R = any

Parameters

• key: T

The key to check

Returns

this is Element & { [k in string]: R }

Whether the node has the key

Inherited from

YTNode.hasKey

Defined in

src/parser/helpers.ts:50


is()

is<T, K>(...types): this is InstanceType<K[number]>

Check if the node is of the given type.

Type Parameters

• T extends YTNode

• K extends YTNodeConstructor<T>[]

Parameters

• ...types: K

The type to check

Returns

this is InstanceType<K[number]>

whether the node is of the given type

Inherited from

YTNode.is

Defined in

src/parser/helpers.ts:28


key()

key<T, R>(key): Maybe

Assert that the node has the given key and return it.

Type Parameters

• T extends string

• R = any

Parameters

• key: T

The key to check

Returns

Maybe

The value of the key wrapped in a Maybe

Throws

If the node does not have the key

Inherited from

YTNode.key

Defined in

src/parser/helpers.ts:60

Edit this page
Last Updated:: 3/25/25, 8:08 PM
Contributors: EdamAme-x