Skip to content

Mangler.getIterator()

Robert Biro edited this page Sep 21, 2016 · 5 revisions

Returns the iterator function for an object.

Mangler.getIterator(object)
Parameter Type Default Description
object Instance An object instance or its contructor to get the iterator function for.

Returns

Returns an iterator function in the form of function(object, callback), or null if object is non-iterable.


Gets an iterator function for any object that's supported by Mangler.js:

a = Mangler([1, 2, 3]);

each = Mangler.getIterator(a);
if(each) each(a, function(key, value) { /* Do something */ });

The above example is identical to:

a = Mangler([1, 2, 3]);

Mangler.each(a, function(key, value) { /* Do something */ });

To check whether an object type is iterable:

isIterable = !!Mangler.getIterator(Date);     // false

For supported object types and to add support for other objects, see Mangler.registerType().

Learning Mangler.js

Optional Modules

Reference

Clone this wiki locally