diff --git a/index.js b/index.js index 1394e53..de59ae2 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,12 @@ var match = String.prototype.match; var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null; var inspectCustom = require('./util.inspect').custom; +/* eslint-disable no-restricted-properties */ +if (!inspectCustom && typeof Symbol === 'function' && typeof Symbol['for'] === 'function') { + inspectCustom = Symbol['for']('nodejs.util.inspect.custom'); +} +/* eslint-enable no-restricted-properties */ + var inspectSymbol = inspectCustom && isSymbol(inspectCustom) ? inspectCustom : null; module.exports = function inspect_(obj, options, depth, seen) { @@ -143,6 +149,10 @@ module.exports = function inspect_(obj, options, depth, seen) { return String(obj); }; +if (inspectSymbol) { + module.exports.custom = inspectSymbol; +} + function wrapQuotes(s, defaultStyle, opts) { var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'"; return quoteChar + s + quoteChar;