Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "iter/mapn/docs/types/index.d"

Index

Type aliases

Functions

Type aliases

Callback

Callback: (...args: Array<any>) => any

Callback function which transforms iterated values.

param

iterated values and the iteration index

returns

callback result

Type declaration

    • (...args: Array<any>): any
    • Parameters

      • Rest ...args: Array<any>

      Returns any

Iterator

Iterator: Iter | IterableIterator

Functions

Export assignment iterMapN

  • Returns an iterator which transforms iterated values from two iterators by applying the iterated values as arguments to a provided function.

    Notes

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

      • value0: iterated value from first iterator
      • value1: iterated value from second iterator
      • index: iteration index (zero-based)
    • The length of the returned iterator is equal to the length of the shortest provided iterator. In other words, the returned iterator ends once one of the provided iterators ends.

    • If an environment supports Symbol.iterator and all provided iterators are iterable, the returned iterator is iterable.

    Parameters

    • iter0: Iterator

      first iterator

    • iter1: Iterator

      second iterator

    • fcn: Callback

      callback function which transforms an iterated value

    • Optional thisArg: any

      execution context

    Returns Iterator

    iterator

    Example

    var array2iterator = require( `@stdlib/array/to-iterator` );
    
    function transform( x, y ) {
        return x + y;
    }
    
    var it1 = array2iterator( [ 1.0, 2.0 ] );
    var it2 = array2iterator( [ 3.0, 4.0 ] );
    
    var iter = iterMapN( it1, it2, transform );
    
    var v = iter.next().value;
    // returns 4.0
    
    v = iter.next().value;
    // returns 6.0
    
    var bool = iter.next().done;
    // returns true
  • Returns an iterator which transforms iterated values from three iterators by applying the iterated values as arguments to a provided function.

    Notes

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

      • value0: iterated value from first iterator
      • value1: iterated value from second iterator
      • value2: iterated value from third iterator
      • index: iteration index (zero-based)
    • The length of the returned iterator is equal to the length of the shortest provided iterator. In other words, the returned iterator ends once one of the provided iterators ends.

    • If an environment supports Symbol.iterator and all provided iterators are iterable, the returned iterator is iterable.

    Parameters

    • iter0: Iterator

      first iterator

    • iter1: Iterator

      second iterator

    • iter2: Iterator

      third iterator

    • fcn: Callback

      callback function which transforms an iterated value

    • Optional thisArg: any

      execution context

    Returns Iterator

    iterator

    Example

    var array2iterator = require( `@stdlib/array/to-iterator` );
    
    function transform( x, y, z ) {
        return x + y + z;
    }
    
    var it1 = array2iterator( [ 1.0, 2.0 ] );
    var it2 = array2iterator( [ 3.0, 4.0 ] );
    var it3 = array2iterator( [ 5.0, 6.0 ] );
    
    var iter = iterMapN( it1, it2, it3, transform );
    
    var v = iter.next().value;
    // returns 9.0
    
    v = iter.next().value;
    // returns 12.0
    
    var bool = iter.next().done;
    // returns true
  • Returns an iterator which transforms iterated values from four iterators by applying the iterated values as arguments to a provided function.

    Notes

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

      • value0: iterated value from first iterator
      • value1: iterated value from second iterator
      • value2: iterated value from third iterator
      • value3: iterated value from fourth iterator
      • index: iteration index (zero-based)
    • The length of the returned iterator is equal to the length of the shortest provided iterator. In other words, the returned iterator ends once one of the provided iterators ends.

    • If an environment supports Symbol.iterator and all provided iterators are iterable, the returned iterator is iterable.

    Parameters

    • iter0: Iterator

      first iterator

    • iter1: Iterator

      second iterator

    • iter2: Iterator

      third iterator

    • iter3: Iterator

      fourth iterator

    • fcn: Callback

      callback function which transforms an iterated value

    • Optional thisArg: any

      execution context

    Returns Iterator

    iterator

    Example

    var array2iterator = require( `@stdlib/array/to-iterator` );
    
    function transform( x, y, z, w ) {
        return x + y + z + w;
    }
    
    var it1 = array2iterator( [ 1.0, 2.0 ] );
    var it2 = array2iterator( [ 3.0, 4.0 ] );
    var it3 = array2iterator( [ 5.0, 6.0 ] );
    var it4 = array2iterator( [ 7.0, 8.0 ] );
    
    var iter = iterMapN( it1, it2, it3, it4, transform );
    
    var v = iter.next().value;
    // returns 16.0
    
    v = iter.next().value;
    // returns 20.0
    
    var bool = iter.next().done;
    // returns true
  • Returns an iterator which transforms iterated values from five iterators by applying the iterated values as arguments to a provided function.

    Notes

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

      • value0: iterated value from first iterator
      • value1: iterated value from second iterator
      • value2: iterated value from third iterator
      • value3: iterated value from fourth iterator
      • value4: iterated value from fifth iterator
      • index: iteration index (zero-based)
    • The length of the returned iterator is equal to the length of the shortest provided iterator. In other words, the returned iterator ends once one of the provided iterators ends.

    • If an environment supports Symbol.iterator and all provided iterators are iterable, the returned iterator is iterable.

    Parameters

    • iter0: Iterator

      first iterator

    • iter1: Iterator

      second iterator

    • iter2: Iterator

      third iterator

    • iter3: Iterator

      fourth iterator

    • iter4: Iterator

      fifth iterator

    • fcn: Callback

      callback function which transforms an iterated value

    • Optional thisArg: any

      execution context

    Returns Iterator

    iterator

    Example

    var array2iterator = require( `@stdlib/array/to-iterator` );
    
    function transform( x, y, z, w, v ) {
        return x + y + z + w + v;
    }
    
    var it1 = array2iterator( [ 1.0, 2.0 ] );
    var it2 = array2iterator( [ 3.0, 4.0 ] );
    var it3 = array2iterator( [ 5.0, 6.0 ] );
    var it4 = array2iterator( [ 7.0, 8.0 ] );
    var it5 = array2iterator( [ 9.0, 10.0 ] );
    
    var iter = iterMapN( it1, it2, it3, it4, it5, transform );
    
    var v = iter.next().value;
    // returns 25.0
    
    v = iter.next().value;
    // returns 30.0
    
    var bool = iter.next().done;
    // returns true
  • Returns an iterator which transforms iterated values from two or more iterators by applying the iterated values as arguments to a provided function.

    Notes

    • When invoked, the callback function is provided N+1 arguments, where N is the number of provided iterators and the last argument is the iteration index:

      • ...value: iterated values
      • index: iteration index (zero-based)
    • The length of the returned iterator is equal to the length of the shortest provided iterator. In other words, the returned iterator ends once one of the provided iterators ends.

    • If an environment supports Symbol.iterator and all provided iterators are iterable, the returned iterator is iterable.

    throws

    callback argument must be a function

    throws

    arguments preceding the callback argument must be iterators

    Parameters

    • iter0: Iterator

      first iterator

    • iter1: Iterator

      second iterator

    • Rest ...args: Array<any>

      subsequent iterators, a callback function which transforms an iterated value, and an optional execution context

    Returns Iterator

    iterator

    Example

    var array2iterator = require( `@stdlib/array/to-iterator` );
    
    function transform( x, y ) {
        return x + y;
    }
    
    var it1 = array2iterator( [ 1.0, 2.0 ] );
    var it2 = array2iterator( [ 3.0, 4.0 ] );
    
    var iter = iterMapN( it1, it2, transform );
    
    var v = iter.next().value;
    // returns 4.0
    
    v = iter.next().value;
    // returns 6.0
    
    var bool = iter.next().done;
    // returns true