Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function sequence(array, iterator, thisArg) {
var current = Promise.resolve()
var cb = arguments.length > 2 ? iterator.bind(thisArg) : iterator
var results = array.map(function(value, i) {
return current = current.then(function(j) {
return cb(value, j, array)
}.bind(null, i))
})
return Promise.all(results)
}