Skip to content

Commit

Permalink
Add support for defined but not implemented Symbol.for (#252)
Browse files Browse the repository at this point in the history
* Add support for defined but not implemented Symbol.for
  • Loading branch information
maxfortun authored Aug 14, 2020
1 parent 5707aed commit 90573ef
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/bn.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,11 @@
// 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;
try {
BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect;
} catch (e) {
BN.prototype.inspect = inspect;
}
} else {
BN.prototype.inspect = inspect;
}
Expand Down

0 comments on commit 90573ef

Please sign in to comment.