YouTube.js
Guide
Discord
GitHub
Guide
Discord
GitHub

youtubei.js / Helpers / Maybe

Class: Maybe

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

Constructors

new Maybe()

new Maybe(value): Maybe

Parameters

• value: any

Returns

Maybe

Defined in

src/parser/helpers.ts:76

Accessors

typeof

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

Returns

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

Defined in

src/parser/helpers.ts:91

Methods

any()

any(): any

Returns

any

Deprecated

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

Defined in

src/parser/helpers.ts:287


array()

array(): any[]

Get the value as an array.

Returns

any[]

the value as any[].

Throws

If the value is not an array.

Defined in

src/parser/helpers.ts:175


arrayOfMaybe()

arrayOfMaybe(): Maybe[]

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

Defined in

src/parser/helpers.ts:187


bigint()

bigint(): bigint

Returns

bigint

Defined in

src/parser/helpers.ts:111


boolean()

boolean(): boolean

Returns

boolean

Defined in

src/parser/helpers.ts:119


function()

function(): Function

Returns

Function

Defined in

src/parser/helpers.ts:162


instanceof()

instanceof<T>(type): T

Get the node as an instance of the given class.

Type Parameters

• 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.

Defined in

src/parser/helpers.ts:298


isArray()

isArray(): boolean

Check whether the value is an array.

Returns

boolean

whether the value is an array.

Defined in

src/parser/helpers.ts:203


isBigint()

isBigint(): boolean

Returns

boolean

Defined in

src/parser/helpers.ts:115


isBoolean()

isBoolean(): boolean

Returns

boolean

Defined in

src/parser/helpers.ts:123


isFunction()

isFunction(): boolean

Returns

boolean

Defined in

src/parser/helpers.ts:166


isInstanceof()

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

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

Type Parameters

• 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.

Defined in

src/parser/helpers.ts:310


isNode()

isNode(): boolean

Check if the value is a YTNode.

Returns

boolean

Whether the value is a YTNode.

Defined in

src/parser/helpers.ts:223


isNodeOfType()

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

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

Type Parameters

• T extends YTNode

• K extends YTNodeConstructor<T>[]

Parameters

• ...types: K

the type(s) to check.

Returns

boolean

Whether the value is a YTNode of the given type.

Defined in

src/parser/helpers.ts:242


isNull()

isNull(): boolean

Returns

boolean

Defined in

src/parser/helpers.ts:149


isNumber()

isNumber(): boolean

Returns

boolean

Defined in

src/parser/helpers.ts:107


isObject()

isObject(): boolean

Returns

boolean

Defined in

src/parser/helpers.ts:157


isObserved()

isObserved(): any

Check if the value is an ObservedArray.

Returns

any

Defined in

src/parser/helpers.ts:260


isParsed()

isParsed(): boolean

Is the result a SuperParsedResult?

Returns

boolean

Defined in

src/parser/helpers.ts:279


isString()

isString(): boolean

Returns

boolean

Defined in

src/parser/helpers.ts:99


isSymbol()

isSymbol(): boolean

Returns

boolean

Defined in

src/parser/helpers.ts:131


isUndefined()

isUndefined(): boolean

Returns

boolean

Defined in

src/parser/helpers.ts:139


node()

node(): YTNode

Get the value as a YTNode.

Returns

YTNode

the value as a YTNode.

Throws

If the value is not a YTNode.

Defined in

src/parser/helpers.ts:212


nodeOfType()

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

Get the value as a YTNode of the given type.

Type Parameters

• T extends YTNode

• 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.

Defined in

src/parser/helpers.ts:233


null()

null(): null

Returns

null

Defined in

src/parser/helpers.ts:143


number()

number(): number

Returns

number

Defined in

src/parser/helpers.ts:103


object()

object(): object

Returns

object

Defined in

src/parser/helpers.ts:153


observed()

observed(): ObservedArray<YTNode>

Get the value as an ObservedArray.

Returns

ObservedArray<YTNode>

the value of the Maybe as a ObservedArray.

Defined in

src/parser/helpers.ts:250


parsed()

parsed(): SuperParsedResult<YTNode>

Get the value of the Maybe as a SuperParsedResult.

Returns

SuperParsedResult<YTNode>

the value as a SuperParsedResult.

Throws

If the value is not a SuperParsedResult.

Defined in

src/parser/helpers.ts:269


string()

string(): string

Returns

string

Defined in

src/parser/helpers.ts:95


symbol()

symbol(): symbol

Returns

symbol

Defined in

src/parser/helpers.ts:127


undefined()

undefined(): undefined

Returns

undefined

Defined in

src/parser/helpers.ts:135

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