timers: refactor to use more primordials

PR-URL: https://github.com/nodejs/node/pull/36132
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
pull/36132/head
Antoine du Hamel 2020-11-15 18:12:43 +01:00 committed by Rich Trott
parent 8938d37251
commit bd120207fb
1 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,7 @@
'use strict';
const {
FunctionPrototypeBind,
Promise,
PromisePrototypeFinally,
PromiseReject,
@ -72,8 +73,9 @@ function setTimeout(after, value, options = {}) {
if (!ref) timeout.unref();
insert(timeout, timeout._idleTimeout);
if (signal) {
// eslint-disable-next-line no-undef
oncancel = cancelListenerHandler.bind(timeout, clearTimeout, reject);
oncancel = FunctionPrototypeBind(cancelListenerHandler,
// eslint-disable-next-line no-undef
timeout, clearTimeout, reject);
signal.addEventListener('abort', oncancel);
}
});
@ -121,8 +123,9 @@ function setImmediate(value, options = {}) {
const immediate = new Immediate(resolve, [value]);
if (!ref) immediate.unref();
if (signal) {
// eslint-disable-next-line no-undef
oncancel = cancelListenerHandler.bind(immediate, clearImmediate, reject);
oncancel = FunctionPrototypeBind(cancelListenerHandler,
// eslint-disable-next-line no-undef
immediate, clearImmediate, reject);
signal.addEventListener('abort', oncancel);
}
});