Home Reference Source Test
public class | source

Tuple

Tuple implementation.

Example:

let tuple = new Tuple(1, 3);

Test:

Constructor Summary

Public Constructor
public

constructor(values: ...any)

Member Summary

Public Members
public

Method Summary

Public Methods
public

get(index: number): any

Returns value from tuple by index.

public

Returns all values.

public

Returns string representation of tuple.

public

Returns string representation of tuple.

public

Invokes callback with all values.

Public Constructors

public constructor(values: ...any) source

Params:

NameTypeAttributeDescription
values ...any

Tuple values.

Public Members

public [`_${index + 1}`]: * source

Public Methods

public get(index: number): any source

Returns value from tuple by index.

Params:

NameTypeAttributeDescription
index number

Index of tuple argument.

Return:

any

Value by index from tuple.

Example:

const expected = ['Barkley', 'Rosser']
    , name = new Tuple(...expected);

name.get(0); // Barkley
name.get(1); // Rosser

Test:

public getAll(): Array<any> source

Returns all values.

Return:

Array<any>

All values.

Example:

const expected = ['Barkley', 'Rosser']
    , name = new Tuple(...expected)
    , [first, last] = name.getAll();

first // Barkley
last // Rosser

Test:

public inspect(): string source

Returns string representation of tuple. NodeJS analog.

Return:

string

String representation.

Example:

const expected = ['Barkley', 'Rosser']
    , name = new Tuple(...expected);

name // (Barkley, Rosser)

public toString(): string source

Returns string representation of tuple.

Return:

string

String representation.

Example:

const expected = ['Barkley', 'Rosser']
    , name = new Tuple(...expected);

name // (Barkley, Rosser)

public unpack(cb: Function) source

Invokes callback with all values.

Params:

NameTypeAttributeDescription
cb Function

Callback which accepts all arguments from current tuple.

Example:

const expected = ['Barkley', 'Rosser']
    , name = new Tuple(...expected);

name.unpack((first, last) => {
   first // Barkley
   last // Rosser
});

Test: