Home Manual Reference Source

Function

Static Public Summary
public

drop(iterable: Iterable, n: Number): IterableIterator

Drops the first n values of the input iterable.

public

* dropwhile(predicate: Function, iterable: Iterable): Iterator

Drop elements of the input iterable while the current element satisfies the input predicate.

public

* slice(iterable: Iterable, start: Number, stop: Number, step: Number): IterableIterator

Same as map( [ i , x ] => x , filter( [ i , x ] => (new Set( range( start , stop , step ) ) ).has( i ) , enumerate( iterable ) ) );.

public

tail(iterable: Iterable, n: Number): IterableIterator

Returns the last n values of the input iterable in an array.

public

take(iterable: Iterable, n: Number): IterableIterator

Yields the first n elements of the input iterable.

public

* takewhile(predicate: Function, iterable: Iterable): Iterator

Output elements of the input iterable while the current element satisfies the input predicate.

public

trunc(iterable: Iterable, n: Number): IterableIterator

Yields all elements of the iterable except the last n ones.

Static Private Summary
private

* _drop(iterable: Iterable, n: Number): IterableIterator

Drops the first n values of the input iterable.

private

* _tail(iterable: Iterable, n: Number): IterableIterator

Returns the last n values of the input iterable in an array.

private

* _take(iterable: Iterable, n: Number): IterableIterator

Yields the first n elements of the input iterable.

private

* _trunc(iterable: Iterable, n: Number): IterableIterator

Yields all elements of the iterable except the last n ones.

Static Public

public drop(iterable: Iterable, n: Number): IterableIterator source

Drops the first n values of the input iterable. If n is negative, behaves like tail( iterable, -n).

Params:

NameTypeAttributeDescription
iterable Iterable

The input iterable.

n Number

The number of values to drop.

Return:

IterableIterator

The remaining values of the input iterable.

Example:

// returns [ 3 , 4 ]
list( drop( range( 5 ) , 3 ) ) ;

public * dropwhile(predicate: Function, iterable: Iterable): Iterator source

Drop elements of the input iterable while the current element satisfies the input predicate.

Params:

NameTypeAttributeDescription
predicate Function

The input predicate.

iterable Iterable

The input iterable.

Return:

Iterator

public * slice(iterable: Iterable, start: Number, stop: Number, step: Number): IterableIterator source

Same as map( [ i , x ] => x , filter( [ i , x ] => (new Set( range( start , stop , step ) ) ).has( i ) , enumerate( iterable ) ) );.

Params:

NameTypeAttributeDescription
iterable Iterable

The input iterable.

start Number

Where to start the slice.

stop Number

Where to stop the slice.

step Number

The step of the slice.

Return:

IterableIterator

public tail(iterable: Iterable, n: Number): IterableIterator source

Returns the last n values of the input iterable in an array. If n is negative, behaves like drop( iterable, -n).

Params:

NameTypeAttributeDescription
iterable Iterable

The input iterable.

n Number

The number of values to include in the output.

Return:

IterableIterator

The last n values of the input iterable.

Example:

// returns [ 3 , 4 ]
list( tail( range( 5 ) , 2 ) ) ;

public take(iterable: Iterable, n: Number): IterableIterator source

Yields the first n elements of the input iterable. If n is negative, behaves like trunc( iterable, -n).

Params:

NameTypeAttributeDescription
iterable Iterable

The input iterable.

n Number

The number of elements to include in the output.

Return:

IterableIterator

The first n elements of the input iterable.

Example:

// returns [ 0 , 1 , 2 ]
list( take( range( 5 ) , 3 ) ) ;

public * takewhile(predicate: Function, iterable: Iterable): Iterator source

Output elements of the input iterable while the current element satisfies the input predicate.

Params:

NameTypeAttributeDescription
predicate Function

The input predicate.

iterable Iterable

The input iterable.

Return:

Iterator

public trunc(iterable: Iterable, n: Number): IterableIterator source

Yields all elements of the iterable except the last n ones. If n is negative, behaves like take( iterable, -n ).

Params:

NameTypeAttributeDescription
iterable Iterable

The input iterable.

n Number

The number of elements to exclude from the output.

Return:

IterableIterator

Example:

// returns [ 0 , 1 , 2 ]
list( trunc( range( 5 ) , 2 ) ) ;

Static Private

private * _drop(iterable: Iterable, n: Number): IterableIterator source

Drops the first n values of the input iterable.

Params:

NameTypeAttributeDescription
iterable Iterable

The input iterable.

n Number

The nonnegative number of values to drop.

Return:

IterableIterator

The remaining values of the input iterable.

Example:

// returns [ 3 , 4 ]
list( _drop( range( 5 ) , 3 ) ) ;

private * _tail(iterable: Iterable, n: Number): IterableIterator source

Returns the last n values of the input iterable in an array.

Params:

NameTypeAttributeDescription
iterable Iterable

The input iterable.

n Number

The nonnegative number of values to include in the output.

Return:

IterableIterator

The last n values of the input iterable.

Example:

// returns [ 3 , 4 ]
list( _tail( range( 5 ) , 2 ) ) ;

private * _take(iterable: Iterable, n: Number): IterableIterator source

Yields the first n elements of the input iterable.

Params:

NameTypeAttributeDescription
iterable Iterable

The input iterable.

n Number

The nonnegative number of elements to include in the output.

Return:

IterableIterator

The first n elements of the input iterable.

Example:

// returns [ 0 , 1 , 2 ]
list( _take( range( 5 ) , 3 ) ) ;

private * _trunc(iterable: Iterable, n: Number): IterableIterator source

Yields all elements of the iterable except the last n ones.

Params:

NameTypeAttributeDescription
iterable Iterable

The input iterable.

n Number

The nonnegative number of elements to exclude from the output.

Return:

IterableIterator

Example:

// returns [ 0 , 1 , 2 ]
list( _trunc( range( 5 ) , 2 ) ) ;