Function
Static Public Summary | ||
public |
Drops the first |
|
public |
Drop elements of the input iterable while the current element satisfies the input predicate. |
|
public |
Same as
|
|
public |
Returns the last |
|
public |
Yields the first |
|
public |
Output elements of the input iterable while the current element satisfies the input predicate. |
|
public |
Yields all elements of the iterable except the last |
Static Private Summary | ||
private |
Drops the first |
|
private |
Returns the last |
|
private |
Yields the first |
|
private |
Yields all elements of the iterable except the last |
Static Public
public drop(iterable: Iterable, n: Number): IterableIterator source
import drop from '@iterable-iterator/slice/src/drop.js'
Drops the first n
values of the input iterable.
If n
is negative, behaves like tail( iterable,
-n)
.
Params:
Name | Type | Attribute | Description |
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
import dropwhile from '@iterable-iterator/slice/src/dropwhile.js'
Drop elements of the input iterable while the current element satisfies the input predicate.
Params:
Name | Type | Attribute | Description |
predicate | Function | The input predicate. |
|
iterable | Iterable | The input iterable. |
Return:
Iterator |
public * slice(iterable: Iterable, start: Number, stop: Number, step: Number): IterableIterator source
import slice from '@iterable-iterator/slice/src/slice.js'
Same as
map( [ i , x ] => x , filter( [ i , x ] => (new Set( range( start ,
stop , step ) ) ).has( i ) , enumerate( iterable ) ) );
.
Return:
IterableIterator |
public tail(iterable: Iterable, n: Number): IterableIterator source
import tail from '@iterable-iterator/slice/src/tail.js'
Returns the last n
values of the input iterable in an array.
If n
is negative, behaves like drop( iterable,
-n)
.
Params:
Name | Type | Attribute | Description |
iterable | Iterable | The input iterable. |
|
n | Number | The number of values to include in the output. |
Return:
IterableIterator | The last |
Example:
// returns [ 3 , 4 ]
list( tail( range( 5 ) , 2 ) ) ;
public take(iterable: Iterable, n: Number): IterableIterator source
import take from '@iterable-iterator/slice/src/take.js'
Yields the first n
elements of the input iterable. If
n
is negative, behaves like trunc( iterable,
-n)
.
Params:
Name | Type | Attribute | Description |
iterable | Iterable | The input iterable. |
|
n | Number | The number of elements to include in the output. |
Return:
IterableIterator | The first |
Example:
// returns [ 0 , 1 , 2 ]
list( take( range( 5 ) , 3 ) ) ;
public * takewhile(predicate: Function, iterable: Iterable): Iterator source
import takewhile from '@iterable-iterator/slice/src/takewhile.js'
Output elements of the input iterable while the current element satisfies the input predicate.
Params:
Name | Type | Attribute | Description |
predicate | Function | The input predicate. |
|
iterable | Iterable | The input iterable. |
Return:
Iterator |
public trunc(iterable: Iterable, n: Number): IterableIterator source
import trunc from '@iterable-iterator/slice/src/trunc.js'
Yields all elements of the iterable except the last n
ones. If
n
is negative, behaves like take( iterable, -n
)
.
Params:
Name | Type | Attribute | Description |
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
import _drop from '@iterable-iterator/slice/src/_drop.js'
Drops the first n
values of the input iterable.
Params:
Name | Type | Attribute | Description |
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
import _tail from '@iterable-iterator/slice/src/_tail.js'
Returns the last n
values of the input iterable in an array.
Params:
Name | Type | Attribute | Description |
iterable | Iterable | The input iterable. |
|
n | Number | The nonnegative number of values to include in the output. |
Return:
IterableIterator | The last |
Example:
// returns [ 3 , 4 ]
list( _tail( range( 5 ) , 2 ) ) ;
private * _take(iterable: Iterable, n: Number): IterableIterator source
import _take from '@iterable-iterator/slice/src/_take.js'
Yields the first n
elements of the input iterable.
Params:
Name | Type | Attribute | Description |
iterable | Iterable | The input iterable. |
|
n | Number | The nonnegative number of elements to include in the output. |
Return:
IterableIterator | The first |
Example:
// returns [ 0 , 1 , 2 ]
list( _take( range( 5 ) , 3 ) ) ;
private * _trunc(iterable: Iterable, n: Number): IterableIterator source
import _trunc from '@iterable-iterator/slice/src/_trunc.js'
Yields all elements of the iterable except the last n
ones.
Params:
Name | Type | Attribute | Description |
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 ) ) ;