From f89af7de3250ee8a5da72fe6965bc17e7e743b45 Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Sat, 8 Feb 2020 15:00:00 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20use=C2=A0a=C2=A0global=C2=A0symbol=20fo?= =?UTF-8?q?r=C2=A0`util.promisify.custom`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Define `util.promisify.custom` as `Symbol.for("nodejs.util.inspect.custom")`, rather than as `Symbol("util.inspect.custom")`. This allows custom `promisify` wrappers to easily/safely be defined in non‑Node.js environments. Refs: https://github.com/nodejs/node/issues/31647 Refs: https://github.com/nodejs/node/pull/31672 --- util.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util.js b/util.js index 6eea657..d8d0706 100644 --- a/util.js +++ b/util.js @@ -607,7 +607,10 @@ function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } -var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined; +var kCustomPromisifiedSymbol = + typeof Symbol === 'function' && typeof Symbol['for'] === 'function' + ? Symbol['for']('nodejs.util.promisify.custom') + : undefined; exports.promisify = function promisify(original) { if (typeof original !== 'function')