From 8c743cab511764886a75c3a0d8a0b3da93fef2eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sun, 16 May 2021 16:03:24 +0200 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/internal/timers/promises.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/internal/timers/promises.js b/lib/internal/timers/promises.js index f1912642a8faeb..e58756edac0e46 100644 --- a/lib/internal/timers/promises.js +++ b/lib/internal/timers/promises.js @@ -1,6 +1,7 @@ 'use strict'; const { + FunctionPrototypeBind, Promise, PromisePrototypeFinally, PromiseReject, @@ -69,8 +70,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); } }); @@ -113,8 +115,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); } });