From 1a6eec86e79f3ff639b2db3e95915644eb646191 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Thu, 30 Nov 2017 09:26:20 +1100 Subject: [PATCH 1/2] only define toBuffer if Buffer is defined --- lib/bn.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/bn.js b/lib/bn.js index 0c41a1b..914382f 100644 --- a/lib/bn.js +++ b/lib/bn.js @@ -520,11 +520,12 @@ return this.toString(16, 2); }; - BN.prototype.toBuffer = function toBuffer (endian, length) { - assert(typeof Buffer !== 'undefined'); - return this.toArrayLike(Buffer, endian, length); - }; - + if (Buffer) { + BN.prototype.toBuffer = function toBuffer (endian, length) { + return this.toArrayLike(Buffer, endian, length); + }; + } + BN.prototype.toArray = function toArray (endian, length) { return this.toArrayLike(Array, endian, length); }; From 8c0b9e8f2bc6caed68877b83d40cff43a20c269c Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Thu, 30 Nov 2017 09:36:04 +1100 Subject: [PATCH 2/2] remove trailing spaces --- lib/bn.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bn.js b/lib/bn.js index 914382f..57c5bb9 100644 --- a/lib/bn.js +++ b/lib/bn.js @@ -525,7 +525,7 @@ return this.toArrayLike(Buffer, endian, length); }; } - + BN.prototype.toArray = function toArray (endian, length) { return this.toArrayLike(Array, endian, length); };