Skip to content

Instantly share code, notes, and snippets.

@griffinmichl
Created May 18, 2016 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save griffinmichl/03cf3eb59ef3990d8e85be74192f6181 to your computer and use it in GitHub Desktop.
Save griffinmichl/03cf3eb59ef3990d8e85be74192f6181 to your computer and use it in GitHub Desktop.
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