Skip to content

Instantly share code, notes, and snippets.

@idandagan1
Last active July 16, 2021 05:58
Show Gist options
  • Save idandagan1/070ca02e22ad621dbb42296f8afe2d93 to your computer and use it in GitHub Desktop.
Save idandagan1/070ca02e22ad621dbb42296f8afe2d93 to your computer and use it in GitHub Desktop.
function processTicksAndRejections() {
let tock;
do {
while (tock = queue.shift()) {
...
try {
const callback = tock.callback;
if (tock.args === undefined) {
callback();
} else {
const args = tock.args;
switch (args.length) {
case 1: callback(args[0]); break;
case 2: callback(args[0], args[1]); break;
...
default: callback(...args);
}
}
} finally {
...
}
...
}
runMicrotasks();
} while (!queue.isEmpty() || processPromiseRejections());
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment