diff --git a/lib/bn.js b/lib/bn.js index 0c41a1b..57c5bb9 100644 --- a/lib/bn.js +++ b/lib/bn.js @@ -520,10 +520,11 @@ 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);