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 Feb 8, 2020
1 parent 40a839a commit e4a1d5b
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 @@ -23,7 +23,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 e4a1d5b

Please sign in to comment.