mirror of https://gitee.com/antv-l7/antv-l7
11 lines
294 B
JavaScript
11 lines
294 B
JavaScript
'use strict'
|
|
|
|
module.exports = function (tasks, initial) {
|
|
if (!Array.isArray(tasks)) {
|
|
return Promise.reject(new TypeError('promise.series only accepts an array of functions'))
|
|
}
|
|
return tasks.reduce((current, next) => {
|
|
return current.then(next)
|
|
}, Promise.resolve(initial))
|
|
}
|