feat: remove toBuffer from number

This commit is contained in:
nanov
2019-11-07 10:30:03 +02:00
parent 0efc46b014
commit 4496cbf560
3 changed files with 12 additions and 12 deletions

View File

@@ -25,17 +25,18 @@ class BigNumber {
throw new TypeError('Unsupported value type.');
}
toBEBuffer(length = undefined) {
toBEBuffer(length) {
const arr = this._n.toByteArray();
if (length && arr.length > length)
throw new Error('Number out of range.');
while (length && arr.length < length)
arr.unshift(0);
return Buffer.from(arr);
}
if (length === undefined)
return Buffer.from(arr);
toBuffer() {
return Buffer.from(this._n.toByteArray());
if (arr.length > length)
throw new Error('Number out of range.');
while (arr.length < length)
arr.unshift(0);
return Buffer.from(arr);
}
toString(radix = 10) {