Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Classes

Interfaces

Type aliases

Functions

Type aliases

Iterator

Iterator: Iter | IterableIterator

Functions

Export assignment iterFlow

  • Returns a constructor for creating a fluent interface for chaining together iterator methods.

    Notes

    • We assume that each provided iterator function has the following function signature:

      function iterFcn( iterator[, ...args] ) {...}

      where iterator is an input iterator and args are additional iterator function arguments (if any).

    throws

    object property values must be functions

    Parameters

    • methods: any

      an object mapping method names to iterator functions

    Returns typeof FluentIterator

    constructor

    Example

    var array2iterator = require( `@stdlib/array/to-iterator` );
    var iterHead = require( `@stdlib/iter/head` );
    var iterSome = require( `@stdlib/iter/some` );
    
    // Create a "fluent" interface:
    var FluentIterator = iterFlow({
        'head': iterHead,
        'some': iterSome
    });
    
    // Create a source iterator:
    var arr = array2iterator( [ 0, 0, 1, 1, 1, 0, 0, 1, 0, 1 ] );
    
    // Create a new iterator:
    var it = new FluentIterator( arr );
    
    var bool = it.head( 5 ).some( 3 );
    // returns true
    
    // Create another source iterator:
    arr = array2iterator( [ 0, 0, 1, 0, 1, 0, 0, 1, 0, 1 ] );
    
    // Create a new iterator:
    it = new FluentIterator( arr );
    
    bool = it.head( 5 ).some( 3 );
    // returns false