1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
{{alias}}( iterator, fcn[, offset[, eager]][, thisArg] )
Returns an iterator which steps according to a provided callback function.
When invoked, the input function is provided four arguments:
- value: iterated value
- i: input iteration index (zero-based)
- n: output (strided) iteration index (zero-based)
- curr: current stride
The return value of the input function specifies the next stride.
If an environment supports Symbol.iterator and a provided iterator is
iterable, the returned iterator is iterable.
Parameters
----------
iterator: Object
Input iterator.
fcn: Function
Stride function (i.e., a function which returns the step amount).
offset: integer (optional)
Index of the first iterated value. Default: 0.
eager: boolean (optional)
Boolean indicating whether to eagerly advance the input iterator when
provided a non-zero offset. Default: false.
thisArg: any (optional)
Stride function execution context.
Returns
-------
iterator: Object
Iterator.
iterator.next(): Function
Returns an iterator protocol-compliant object containing the next
iterated value (if one exists) and a boolean flag indicating whether the
iterator is finished.
iterator.return( [value] ): Function
Finishes an iterator and returns a provided value.
Examples
--------
> var arr = {{alias:@stdlib/array/to-iterator}}( [ 0, 1, 2, 3, 4, 5, 6 ] );
> function stride( v, i ) { return (i % 10)+1; };
> var it = {{alias}}( arr, stride );
> var r = it.next().value
0
> r = it.next().value
1
> r = it.next().value
3
See Also
--------
|