From 5dd31bcf07850e1a34f2d9b439ba4cbf2fc9a007 Mon Sep 17 00:00:00 2001 From: Kazushi Kitaya Date: Fri, 21 Dec 2018 18:32:02 +0900 Subject: [PATCH] util: simplify code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplify code by using return value of Object.defineProperty directly. PR-URL: https://github.com/nodejs/node/pull/25162 Reviewed-By: Vladimir de Turckheim Reviewed-By: Masashi Hirano Reviewed-By: James M Snell Reviewed-By: Tobias Nießen Reviewed-By: Ruben Bridgewater --- lib/internal/util.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/internal/util.js b/lib/internal/util.js index b5e3bc7d74c70c..a9d8d12f9b499d 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -260,10 +260,9 @@ function promisify(original) { if (typeof fn !== 'function') { throw new ERR_INVALID_ARG_TYPE('util.promisify.custom', 'Function', fn); } - Object.defineProperty(fn, kCustomPromisifiedSymbol, { + return Object.defineProperty(fn, kCustomPromisifiedSymbol, { value: fn, enumerable: false, writable: false, configurable: true }); - return fn; } // Names to create an object from in case the callback receives multiple