From ac1b81ad751b8f74364a975e428d360cf04cbb09 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 11 Aug 2017 13:25:41 +0200 Subject: [PATCH] lib: move deprecationWarned var MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variable deprecationWarned currently looks a little misplaced. It is used in emitWarning but declared after it. This commit suggest moving the var to the beginning of the function. PR-URL: https://github.com/nodejs/node/pull/14769 Reviewed-By: Colin Ihrig Reviewed-By: Alexey Orlenko Reviewed-By: Luigi Pinca Reviewed-By: Tobias Nießen Reviewed-By: Refael Ackermann Reviewed-By: Gibson Fahnestock Reviewed-By: James M Snell --- lib/internal/process/promises.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/internal/process/promises.js b/lib/internal/process/promises.js index 1ba4aa47f575bf..b4a4582c3095a7 100644 --- a/lib/internal/process/promises.js +++ b/lib/internal/process/promises.js @@ -14,6 +14,8 @@ function getAsynchronousRejectionWarningObject(uid) { } function setupPromises(scheduleMicrotasks) { + let deprecationWarned = false; + process._setupPromises(function(event, promise, reason) { if (event === promiseRejectEvent.unhandled) unhandledRejection(promise, reason); @@ -73,7 +75,7 @@ function setupPromises(scheduleMicrotasks) { 'DeprecationWarning', 'DEP0018'); } } - var deprecationWarned = false; + function emitPendingUnhandledRejections() { let hadListeners = false; while (pendingUnhandledRejections.length > 0) {