$ npm install --save pop-iterate
The iterate operator accepts an array, or object that implements iterate, and returns an iterator, as described by the iterator protocol, with some extensions. The iterations have an index property with the index corresponding to the value.
var iterator = ;;;;;
Iterating on an array, the iterate method accepts optional start, stop, and step arguments.
var array = 1 2 3 4 5 6 7 8;var iterator = ;;;;;
The iterate operator also iterates the owned properties of an object.
var object = a: 10 b: 20 c: 30;var iterator = ;;;;;
A well-planned system of objects is beautiful: a system where every meaningful method for an object has been anticipated in the design. Inevitably, another layer of architecture introduces a new concept and with it the temptation to monkey-patch, dunk-punch, or otherwise cover-up the omission. But reaching backward in time, up through the layers of architecture doesn't always compose well, when different levels introduce concepts of the same name but distinct behavior.
A polymorphic operator is a function that accepts as its first argument an object and varies its behavior depending on its type. Such an operator has the benefit of covering for the types from higher layers of architecture, but defers to the eponymous method name of types yet to be defined.
The iterate operator works for arrays and objects.
Any other object can be iterable by implementing the
iterate method, and the
iterate operator will defer to it.
This package also exports the individual parts form which it makes iterators.
var Iteration = ;var ArrayIterator = ;var ObjectIterator = ;