Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "iter/strided-by/docs/types/index.d"

Index

Type aliases

Binary

Binary: (value: any, i: number) => number

Callback function which returns the next stride.

param

iterated value

param

input iteration index

returns

callback result

Type declaration

    • (value: any, i: number): number
    • Parameters

      • value: any
      • i: number

      Returns number

Callback

Callback function which returns the next stride.

param

iterated value

param

input iteration index

param

output (strided) iteration index

param

current stride

returns

callback result

Iterator

Iterator: Iter | IterableIterator

Nullary

Nullary: () => number

Callback function which returns the next stride.

returns

callback result

Type declaration

    • (): number
    • Returns number

Quaternary

Quaternary: (value: any, i: number, n: number, curr: number) => number

Callback function which returns the next stride.

param

iterated value

param

input iteration index

param

output (strided) iteration index

param

current stride

returns

callback result

Type declaration

    • (value: any, i: number, n: number, curr: number): number
    • Parameters

      • value: any
      • i: number
      • n: number
      • curr: number

      Returns number

Ternary

Ternary: (value: any, i: number, n: number) => number

Callback function which returns the next stride.

param

iterated value

param

input iteration index

param

output (strided) iteration index

returns

callback result

Type declaration

    • (value: any, i: number, n: number): number
    • Parameters

      • value: any
      • i: number
      • n: number

      Returns number

Unary

Unary: (value: any) => number

Callback function which returns the next stride.

param

iterated value

returns

callback result

Type declaration

    • (value: any): number
    • Parameters

      • value: any

      Returns number

Functions

Export assignment iterStridedBy

  • Returns an iterator which steps according to a callback function.

    Notes

    • When invoked, the callback function is provided four arguments:

      • value: iterated value
      • i: input iteration index (zero-based)
      • n: output (strided) iteration index (zero-based)
      • curr: current stride
    • If an environment supports Symbol.iterator and a provided iterator is iterable, the returned iterator is iterable.

    Parameters

    • iterator: Iterator

      input iterator

    • fcn: Callback

      callback function which returns the next stride

    • Optional offset: undefined | number

      offset

    • Optional eager: undefined | false | true

      boolean indicating whether to eagerly advance an input iterator when provided a non-zero offset (default: false)

    • Optional thisArg: any

      execution context

    Returns Iterator

    iterator

    Example

    var array2iterator = require( `@stdlib/array/to-iterator` );
    
    var arr = array2iterator( [ 0, 1, 2, 3, 4, 5, 6, 7 ] );
    
    function stride( v, i ) {
        return (i % 10) + 1;
    }
    
    var iter = iterStridedBy( arr, stride, 1, true );
    
    var r = iter.next().value;
    // returns 1
    
    r = iter.next().value;
    // returns 2
    
    r = iter.next().value;
    // returns 4
    
    // ...
  • Returns an iterator which steps according to a callback function.

    Notes

    • When invoked, the callback function is provided four arguments:

      • value: iterated value
      • i: input iteration index (zero-based)
      • n: output (strided) iteration index (zero-based)
      • curr: current stride
    • If an environment supports Symbol.iterator and a provided iterator is iterable, the returned iterator is iterable.

    Parameters

    • iterator: Iterator

      input iterator

    • fcn: Callback

      callback function which returns the next stride

    • Optional offset: undefined | number

      offset

    • Optional thisArg: any

      execution context

    Returns Iterator

    iterator

    Example

    var array2iterator = require( `@stdlib/array/to-iterator` );
    
    var arr = array2iterator( [ 0, 1, 2, 3, 4, 5, 6, 7 ] );
    
    function stride( v, i ) {
        return (i % 10) + 1;
    }
    
    var iter = iterStridedBy( arr, stride, 1 );
    
    var r = iter.next().value;
    // returns 1
    
    r = iter.next().value;
    // returns 2
    
    r = iter.next().value;
    // returns 4
    
    // ...
  • Returns an iterator which steps according to a callback function.

    Notes

    • When invoked, the callback function is provided four arguments:

      • value: iterated value
      • i: input iteration index (zero-based)
      • n: output (strided) iteration index (zero-based)
      • curr: current stride
    • If an environment supports Symbol.iterator and a provided iterator is iterable, the returned iterator is iterable.

    Parameters

    • iterator: Iterator

      input iterator

    • fcn: Callback

      callback function which returns the next stride

    • Optional thisArg: any

      execution context

    Returns Iterator

    iterator

    Example

    var array2iterator = require( `@stdlib/array/to-iterator` );
    
    var arr = array2iterator( [ 0, 1, 2, 3, 4, 5, 6, 7 ] );
    
    function stride( v, i ) {
        return (i % 10) + 1;
    }
    
    var iter = iterStridedBy( arr, stride, null );
    
    var r = iter.next().value;
    // returns 0
    
    r = iter.next().value;
    // returns 1
    
    r = iter.next().value;
    // returns 2
    
    // ...