iterEmpty
Create an empty iterator.
Usage
var iterEmpty = require( '@stdlib/iter/empty' );
iterEmpty()
Returns an "empty" iterator (i.e., an iterator which never returns an iterated value).
var it = iterEmpty();
// returns <Object>
var bool = it.next().done;
// returns true
The returned iterator protocol-compliant object has the following properties:
- next: function which returns an iterator protocol-compliant object containing the next iterated value (if one exists) assigned to a
value
property and adone
property having aboolean
value indicating whether the iterator is finished. - return: function which closes an iterator and returns a single (optional) argument in an iterator protocol-compliant object.
Notes
- If an environment supports
Symbol.iterator
, the returned iterator is iterable.
Examples
var iterEmpty = require( '@stdlib/iter/empty' );
// Create an iterator:
var it = iterEmpty();
// Perform manual iteration...
var v;
while ( true ) {
v = it.next();
if ( v.done ) {
console.log( 'done' );
break;
}
// The following should never run...
console.log( v.value );
}