YouTube.js
Guide
Discord
❤️ Sponsor
GitHub
Guide
Discord
❤️ Sponsor
GitHub

youtubei.js / Helpers / Maybe

Class: Maybe

Defined in: src/parser/helpers.ts:64

A wrapper class that provides type-safe access to a value.

Constructors

Constructor

new Maybe(value): Maybe

Defined in: src/parser/helpers.ts:67

Parameters

value

any

Returns

Maybe

Accessors

typeof

Get Signature

get typeof(): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"

Defined in: src/parser/helpers.ts:82

Returns

"string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"

Methods

any()

any(): any

Defined in: src/parser/helpers.ts:278

Returns

any

Deprecated

This call is not meant to be used outside of debugging. Please use the specific type getter instead.


array()

array(): any[]

Defined in: src/parser/helpers.ts:166

Get the value as an array.

Returns

any[]

the value as any[].

Throws

If the value is not an array.


arrayOfMaybe()

arrayOfMaybe(): Maybe[]

Defined in: src/parser/helpers.ts:178

More typesafe variant of Maybe#array.

Returns

Maybe[]

a proxied array which returns all the values as Maybe.

Throws

If the value is not an array


bigint()

bigint(): bigint

Defined in: src/parser/helpers.ts:102

Returns

bigint


boolean()

boolean(): boolean

Defined in: src/parser/helpers.ts:110

Returns

boolean


function()

function(): Function

Defined in: src/parser/helpers.ts:153

Returns

Function


instanceof()

instanceof<T>(type): T

Defined in: src/parser/helpers.ts:289

Get the node as an instance of the given class.

Type Parameters

T

T extends object

Parameters

type

Constructor<T>

The type to check.

Returns

T

the value as the given type.

Throws

If the node is not of the given type.


isArray()

isArray(): boolean

Defined in: src/parser/helpers.ts:194

Check whether the value is an array.

Returns

boolean

whether the value is an array.


isBigint()

isBigint(): boolean

Defined in: src/parser/helpers.ts:106

Returns

boolean


isBoolean()

isBoolean(): boolean

Defined in: src/parser/helpers.ts:114

Returns

boolean


isFunction()

isFunction(): boolean

Defined in: src/parser/helpers.ts:157

Returns

boolean


isInstanceof()

isInstanceof<T>(type): this is Maybe & T

Defined in: src/parser/helpers.ts:301

Check if the node is an instance of the given class.

Type Parameters

T

T extends object

Parameters

type

Constructor<T>

The type to check.

Returns

this is Maybe & T

Whether the node is an instance of the given type.


isNode()

isNode(): boolean

Defined in: src/parser/helpers.ts:214

Check if the value is a YTNode.

Returns

boolean

Whether the value is a YTNode.


isNodeOfType()

isNodeOfType<T, K>(...types): boolean

Defined in: src/parser/helpers.ts:233

Check if the value is a YTNode of the given type.

Type Parameters

T

T extends YTNode

K

K extends YTNodeConstructor<T>[]

Parameters

types

...K

the type(s) to check.

Returns

boolean

Whether the value is a YTNode of the given type.


isNull()

isNull(): boolean

Defined in: src/parser/helpers.ts:140

Returns

boolean


isNumber()

isNumber(): boolean

Defined in: src/parser/helpers.ts:98

Returns

boolean


isObject()

isObject(): boolean

Defined in: src/parser/helpers.ts:148

Returns

boolean


isObserved()

isObserved(): any

Defined in: src/parser/helpers.ts:251

Check if the value is an ObservedArray.

Returns

any


isParsed()

isParsed(): boolean

Defined in: src/parser/helpers.ts:270

Is the result a SuperParsedResult?

Returns

boolean


isString()

isString(): boolean

Defined in: src/parser/helpers.ts:90

Returns

boolean


isSymbol()

isSymbol(): boolean

Defined in: src/parser/helpers.ts:122

Returns

boolean


isUndefined()

isUndefined(): boolean

Defined in: src/parser/helpers.ts:130

Returns

boolean


node()

node(): YTNode

Defined in: src/parser/helpers.ts:203

Get the value as a YTNode.

Returns

YTNode

the value as a YTNode.

Throws

If the value is not a YTNode.


nodeOfType()

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

Defined in: src/parser/helpers.ts:224

Get the value as a YTNode of the given type.

Type Parameters

T

T extends YTNode

K

K extends YTNodeConstructor<T>[]

Parameters

types

...K

The type(s) to cast to.

Returns

InstanceType<K[number]>

The node cast to the given type.

Throws

If the node is not of the given type.


null()

null(): null

Defined in: src/parser/helpers.ts:134

Returns

null


number()

number(): number

Defined in: src/parser/helpers.ts:94

Returns

number


object()

object(): object

Defined in: src/parser/helpers.ts:144

Returns

object


observed()

observed(): ObservedArray<YTNode>

Defined in: src/parser/helpers.ts:241

Get the value as an ObservedArray.

Returns

ObservedArray<YTNode>

the value of the Maybe as a ObservedArray.


parsed()

parsed(): SuperParsedResult

Defined in: src/parser/helpers.ts:260

Get the value of the Maybe as a SuperParsedResult.

Returns

SuperParsedResult

the value as a SuperParsedResult.

Throws

If the value is not a SuperParsedResult.


string()

string(): string

Defined in: src/parser/helpers.ts:86

Returns

string


symbol()

symbol(): symbol

Defined in: src/parser/helpers.ts:118

Returns

symbol


undefined()

undefined(): undefined

Defined in: src/parser/helpers.ts:126

Returns

undefined

Edit this page
Last Updated: 10/12/25, 3:23 PM