diff --git a/lib/bn.js b/lib/bn.js index 2be2c25..bba8981 100644 --- a/lib/bn.js +++ b/lib/bn.js @@ -363,9 +363,17 @@ return this; }; - BN.prototype.inspect = function inspect () { + // Check Symbol.for because not everywhere where Symbol defined + // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility + if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') { + BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect; + } else { + BN.prototype.inspect = inspect; + } + + function inspect () { return (this.red ? ''; - }; + } /*