an object mapping method names to iterator functions
constructor
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
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:
where
iterator
is an input iterator andargs
are additional iterator function arguments (if any).object property values must be functions