Created
May 18, 2016 01:43
-
-
Save griffinmichl/03cf3eb59ef3990d8e85be74192f6181 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function map(collection, iteratee, callback) { | |
let running = collection.length | |
const results = [] | |
collection.forEach((value, index) => | |
iteratee(value, (err, data) => { | |
if (err) { | |
callback(err) | |
return | |
} | |
results[index] = data | |
running-- | |
if (running === 0) { | |
callback(null, results) | |
} | |
}) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment