2018-02-26 20:10:06 +00:00
|
|
|
class TaskQueue {
|
|
|
|
constructor() {
|
|
|
|
this._chain = Promise.resolve();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-01-11 06:56:39 +00:00
|
|
|
* @param {Function} task
|
2018-02-26 20:10:06 +00:00
|
|
|
* @return {!Promise}
|
|
|
|
*/
|
|
|
|
postTask(task) {
|
|
|
|
const result = this._chain.then(task);
|
|
|
|
this._chain = result.catch(() => {});
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-06 18:31:33 +00:00
|
|
|
module.exports = {TaskQueue};
|