From eba911f62cf68df409ddf52f002e0f2d60e3eb53 Mon Sep 17 00:00:00 2001 From: LiviaMedeiros Date: Wed, 18 May 2022 16:34:49 +0800 Subject: [PATCH] squash: avoid creating throwaway object --- lib/internal/util.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/internal/util.js b/lib/internal/util.js index 1719c8a57ee1e2..5591426aeee69b 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -335,14 +335,10 @@ function promisify(original, options = undefined) { validateFunction(original, 'original'); // No validateObject so .map(util.promisify) can work - if (options == null || typeof options !== 'object') { - options = ObjectCreate(null); - } - const { - resolveArray = false, - resolveObject = null, - callbackPosition = null, - } = options; + const useDefaultOptions = options == null || typeof options !== 'object'; + const resolveArray = useDefaultOptions ? false : options.resolveArray; + const resolveObject = useDefaultOptions ? null : options.resolveObject; + const callbackPosition = useDefaultOptions ? null : options.callbackPosition; if (original[kCustomPromisifiedSymbol]) { const fn = original[kCustomPromisifiedSymbol];