puppeteer/lib/TaskQueue.js
2018-08-06 11:31:33 -07:00

17 lines
303 B
JavaScript

class TaskQueue {
constructor() {
this._chain = Promise.resolve();
}
/**
* @param {function()} task
* @return {!Promise}
*/
postTask(task) {
const result = this._chain.then(task);
this._chain = result.catch(() => {});
return result;
}
}
module.exports = {TaskQueue};