Mangler.getIterator() - DarthJDG/Mangler.js GitHub Wiki
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 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); // falseFor supported object types and to add support for other objects, see Mangler.registerType().