Skip to content

Commit

Permalink
Fix arrayLike (#37)
Browse files Browse the repository at this point in the history
* Fix arrayLike

* Update src/BigNumber.ts

Co-authored-by: Marc Rousavy <me@mrousavy.com>
  • Loading branch information
Szymon20000 and mrousavy authored Apr 11, 2022
1 parent 045b529 commit ed5c96c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/BigNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ export class BN {
return native.toArray.call(this.internalBigNum, endian === 'le', len || -1);
}

// TODO(MARC ts magician )
// TODO(MARC ts magician - please check )
toArrayLike<T extends (len: number) => { buffer: ArrayBuffer }>(
arrayLike: T,
endian: 'le' | 'be',
len: number
endian?: 'le' | 'be',
len?: number
) {
if (typeof arrayLike !== 'function') {
console.log('toArrayLike exptects constructor');
Expand All @@ -240,7 +240,9 @@ export class BN {
return this.toArray(endian, len);
}

const res = new (arrayLike as any)(len);
const outLen = len != null ? len : this.byteLength();

const res = new (arrayLike as any)(outLen);

native.toArrayLike.call(
this.internalBigNum,
Expand Down

0 comments on commit ed5c96c

Please sign in to comment.