Skip to content

Commit

Permalink
timers: refactor to use more primordials
Browse files Browse the repository at this point in the history
PR-URL: #36132
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
aduh95 authored and Trott committed Nov 18, 2020
1 parent 8938d37 commit bd12020
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/timers/promises.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const {
FunctionPrototypeBind,
Promise,
PromisePrototypeFinally,
PromiseReject,
Expand Down Expand Up @@ -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);
}
});
Expand Down Expand Up @@ -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);
}
});
Expand Down

0 comments on commit bd12020

Please sign in to comment.