JSMicro - Iterator
foreach(object, handler, reversed)
Iterate Array, Object, String, Number, and Arguments (and NodeList on browser), using direct mode.
object
- Array, Object, String, Number, or Arguments to iterate.handler
- Function to handle the each items. Will get (key, value) for object, and (i, value) for non-object.reversed
- Boolean does the iteration should be reversed. Default is no.
foreach(object).run(handler, reversed)[.then(handler)][.catch(handler)]
Iterate Array, Object, String, Number, and Arguments (and NodeList on browser), using waiting mode.
object
- Array, Object, String, Number, or Arguments to iterate.handler
- Function to handle the each items. Will get (key, value) for object, and (i, value) for non-object.reversed
- Boolean does the iteration should be reversed. Default is no.
.then(handler)
Add function that will be called when the iteration done.
.catch(handler)
Add function that will be called when the iteration is stopped.
Browser Usage
bower install --save jsmicro-foreach
NodeJS Usage
npm install --save jsmicro-foreach
; // Iterating array.; // Iterating object.; // Iterating number.; // Iterating string using waiting mode.; // Iterating number using waiting mode.; // Iterating number and break the iteration.;
Changelogs
v1.0.1 - May 21, 2016
- Added .npmignore
v1.0.0 - May 20, 2016
- Initial release.