mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
17 lines
301 B
JavaScript
17 lines
301 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;
|