Skip to content

Instantly share code, notes, and snippets.

@ogostos

ogostos/four.js Secret

Last active March 25, 2023 19:03
Show Gist options
  • Save ogostos/5bfabd50fded007d73cda2ca336766b8 to your computer and use it in GitHub Desktop.
Save ogostos/5bfabd50fded007d73cda2ca336766b8 to your computer and use it in GitHub Desktop.
dequeue() {
if (this.workingOnPromise) {
return false;
}
const item = this.queue.shift();
if (!item) {
return false;
}
try {
this.workingOnPromise = true;
item.promise()
.then((value) => {
this.workingOnPromise = false;
item.resolve(value);
this.dequeue();
})
.catch(err => {
this.workingOnPromise = false;
item.reject(err);
this.dequeue();
})
} catch (err) {
this.workingOnPromise = false;
item.reject(err);
this.dequeue();
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment