Home Manual Reference Source

Function

Static Public Summary
public

first(iterable: Iterable): any

Returns the first value of the input iterable.

public

last(iterable: Iterable): any

Returns the last value of the input iterable.

public

nth(iterable: Iterable, n: number): any

Returns the nth value of the input iterable (n is a 0-based index).

Static Public

public first(iterable: Iterable): any source

Returns the first value of the input iterable. If the iterable is exhausted, throws a StopIteration.

Params:

NameTypeAttributeDescription
iterable Iterable

The input iterable.

Return:

any

The first value of the input iterable.

public last(iterable: Iterable): any source

Returns the last value of the input iterable. If the iterable is exhausted, throws a StopIteration.

Params:

NameTypeAttributeDescription
iterable Iterable

The input iterable.

Return:

any

The last value of the input iterable.

public nth(iterable: Iterable, n: number): any source

Returns the nth value of the input iterable (n is a 0-based index). If n is negative, returns the nth value from the end. If no such value exists, throws a StopIteration.

Params:

NameTypeAttributeDescription
iterable Iterable

The input iterable.

n number

The index of the value to output.

Return:

any

The nth value of the input iterable.

Example:

// returns 3
nth( range( 5 ) , 3 ) ;