abstract-state-router
Version:
The basics of a client-side state router ala the AngularJS ui-router, but without any DOM interactions
17 lines (12 loc) • 474 B
JavaScript
// Pulled from https://github.com/joliss/promise-map-series and prettied up a bit
var Promise = require('native-promise-only/npo')
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)
}