From bd120207fbfffd4b6571c6d7c149c9bae5c46e01 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 15 Nov 2020 18:12:43 +0100 Subject: [PATCH] timers: refactor to use more primordials PR-URL: https://github.com/nodejs/node/pull/36132 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca --- lib/timers/promises.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/timers/promises.js b/lib/timers/promises.js index eba8c1e5036210..7c98ba35ec4351 100644 --- a/lib/timers/promises.js +++ b/lib/timers/promises.js @@ -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); } });