Skip to content

Commit dec3610

Browse files
aduh95targos
authored andcommitted
timers: refactor to use more primordials
PR-URL: #36132 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent b3e22e1 commit dec3610

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/internal/timers/promises.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const {
4+
FunctionPrototypeBind,
45
Promise,
56
PromisePrototypeFinally,
67
PromiseReject,
@@ -69,8 +70,9 @@ function setTimeout(after, value, options = {}) {
6970
if (!ref) timeout.unref();
7071
insert(timeout, timeout._idleTimeout);
7172
if (signal) {
72-
// eslint-disable-next-line no-undef
73-
oncancel = cancelListenerHandler.bind(timeout, clearTimeout, reject);
73+
oncancel = FunctionPrototypeBind(cancelListenerHandler,
74+
// eslint-disable-next-line no-undef
75+
timeout, clearTimeout, reject);
7476
signal.addEventListener('abort', oncancel);
7577
}
7678
});
@@ -113,8 +115,9 @@ function setImmediate(value, options = {}) {
113115
const immediate = new Immediate(resolve, [value]);
114116
if (!ref) immediate.unref();
115117
if (signal) {
116-
// eslint-disable-next-line no-undef
117-
oncancel = cancelListenerHandler.bind(immediate, clearImmediate, reject);
118+
oncancel = FunctionPrototypeBind(cancelListenerHandler,
119+
// eslint-disable-next-line no-undef
120+
immediate, clearImmediate, reject);
118121
signal.addEventListener('abort', oncancel);
119122
}
120123
});

0 commit comments

Comments
 (0)