Iterate and map recursively into an object. Return a promise object with a standard then interface created by Q. The depth and data types can be controlled by the iterator.
When encounters an array object, the returned value is an object use the indices of the array as its keys in String.
Note, that module q is required to handle the async quenue and create promises.
Arguments
object- An array to iterate over.iterator(item, route, parent)- A function to apply to each item in the array. Should return an array of results or a thenable promise.item- A value of the current item.route- An array represents the route of the current item in the object.route[0]is the current item's name, and last one the the root's name.parent- An object contains the current item if the current item is iterated from a parent object. Otherwise it'sundefined.- return value - A valid promise which when success, an array
[newItem, newKey, stepIn]is resolved, wherenewItemis the transformed item to replace the original item;newKeyis the new key name of the current item, which is often aString; andstepInis aBooleanvalue as a switch of whether to iterate into the current item or not. Otherwise the resolved array can be directly returned without a wrapper of fulfilled promise.
routePrefix- An array acts like therouteargument passed to the iterator, but is a root of all route created and passed to the iterator.
Helper
deepMap.typefor(object)- Call onObject.prototype.toString.call()and get the type name in lower case. For example,deepMap.typefor([])returns"array".