Skip to content

Commit

Permalink
feat: use a global symbol for util.promisify.custom
Browse files Browse the repository at this point in the history
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: nodejs/node#31647
Refs: nodejs/node#31672
  • Loading branch information
ExE-Boss committed Jan 6, 2021
1 parent e68f500 commit 2b9f90e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ var $forEach = callBound('Array.prototype.forEach');

var hasSymbols = require('has-symbols')();

var kCustomPromisifiedSymbol = hasSymbols ? Symbol('util.promisify.custom') : null;
// eslint-disable-next-line no-restricted-properties
var kCustomPromisifiedSymbol = hasSymbols ? Symbol['for']('nodejs.util.promisify.custom') : null;
var kCustomPromisifyArgsSymbol = hasSymbols ? Symbol('customPromisifyArgs') : null;

module.exports = function promisify(orig) {
Expand Down

0 comments on commit 2b9f90e

Please sign in to comment.