From 04b42007d54b9ba30b2acd90bec00a2d5d3ef1d9 Mon Sep 17 00:00:00 2001 From: Max Fortun Date: Thu, 13 Aug 2020 12:47:56 -0400 Subject: [PATCH 1/3] Add support for defined but not implemented Symbol.for --- lib/bn.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/bn.js b/lib/bn.js index 896efa9d..ca0ab14a 100644 --- a/lib/bn.js +++ b/lib/bn.js @@ -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; } From cb893aea4970115932c3789af267758d52994851 Mon Sep 17 00:00:00 2001 From: Max Fortun Date: Thu, 13 Aug 2020 13:24:56 -0400 Subject: [PATCH 2/3] Add support for defined but not implemented Symbol.for --- lib/bn.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bn.js b/lib/bn.js index ca0ab14a..28e6cd35 100644 --- a/lib/bn.js +++ b/lib/bn.js @@ -371,9 +371,9 @@ // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') { try { - BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect; + BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect; } catch(e) { - BN.prototype.inspect = inspect; + BN.prototype.inspect = inspect; } } else { BN.prototype.inspect = inspect; From c20e6378b78795da4382cc266e6d7c5e4c9b9857 Mon Sep 17 00:00:00 2001 From: Max Fortun Date: Thu, 13 Aug 2020 13:26:15 -0400 Subject: [PATCH 3/3] Add support for defined but not implemented Symbol.for --- lib/bn.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bn.js b/lib/bn.js index 28e6cd35..982f6383 100644 --- a/lib/bn.js +++ b/lib/bn.js @@ -372,7 +372,7 @@ if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') { try { BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect; - } catch(e) { + } catch (e) { BN.prototype.inspect = inspect; } } else {