UNPKG

303 BJavaScriptView Raw
1class TaskQueue {
2 constructor() {
3 this._chain = Promise.resolve();
4 }
5
6 /**
7 * @param {function()} task
8 * @return {!Promise}
9 */
10 postTask(task) {
11 const result = this._chain.then(task);
12 this._chain = result.catch(() => {});
13 return result;
14 }
15}
16
17module.exports = {TaskQueue};
\No newline at end of file