Skip to content

Commit

Permalink
add little endian conversion (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelienFT authored Nov 18, 2022
1 parent a527958 commit 86d79a7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/utils/arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class Args {
nextU32(): BigInt {
const buffer = this.serialized.buffer;
const view = new DataView(buffer);
const value = view.getUint32(this.offset);
const value = view.getUint32(this.offset, true);
this.offset += 4;
return BigInt(value);
}
Expand All @@ -64,7 +64,7 @@ export default class Args {
nextU64(): BigInt {
const buffer = this.serialized.buffer;
const view = new DataView(buffer);
const value = view.getBigUint64(this.offset);
const value = view.getBigUint64(this.offset, true);
this.offset += 8;
return BigInt(value);
}
Expand All @@ -77,7 +77,7 @@ export default class Args {
nextI32(): BigInt {
const buffer = this.serialized.buffer;
const view = new DataView(buffer);
const value = view.getInt32(this.offset);
const value = view.getInt32(this.offset, true);
this.offset += 4;
return BigInt(value);
}
Expand All @@ -90,7 +90,7 @@ export default class Args {
nextI64(): BigInt {
const buffer = this.serialized.buffer;
const view = new DataView(buffer);
const value = view.getBigInt64(this.offset);
const value = view.getBigInt64(this.offset, true);
this.offset += 8;
return BigInt(value);
}
Expand All @@ -103,7 +103,7 @@ export default class Args {
nextF32(): number {
const buffer = this.serialized.buffer;
const view = new DataView(buffer);
const value = view.getFloat32(this.offset);
const value = view.getFloat32(this.offset, true);
this.offset += 4;
return value;
}
Expand All @@ -116,7 +116,7 @@ export default class Args {
nextF64(): number {
const buffer = this.serialized.buffer;
const view = new DataView(buffer);
const value = view.getFloat64(this.offset);
const value = view.getFloat64(this.offset, true);
this.offset += 8;
return value;
}
Expand Down Expand Up @@ -144,7 +144,7 @@ export default class Args {
addU32(bigInt: bigint): Args {
const buffer = new ArrayBuffer(4);
const view = new DataView(buffer);
view.setUint32(0, Number(bigInt));
view.setUint32(0, Number(bigInt), true);
this.serialized = this.concatArrays(this.serialized, new Uint8Array(view.buffer));

this.offset += 4;
Expand All @@ -160,7 +160,7 @@ export default class Args {
addU64(bigInt: bigint): Args {
const buffer = new ArrayBuffer(8);
const view = new DataView(buffer);
view.setBigUint64(0, bigInt);
view.setBigUint64(0, bigInt, true);
this.serialized = this.concatArrays(this.serialized, new Uint8Array(view.buffer));

this.offset += 8;
Expand All @@ -176,7 +176,7 @@ export default class Args {
addI32(bigInt: bigint): Args {
const buffer = new ArrayBuffer(4);
const view = new DataView(buffer);
view.setInt32(0, Number(bigInt));
view.setInt32(0, Number(bigInt), true);
this.serialized = this.concatArrays(this.serialized, new Uint8Array(view.buffer));

this.offset += 4;
Expand All @@ -192,7 +192,7 @@ export default class Args {
addI64(bigInt: bigint): Args {
const buffer = new ArrayBuffer(8);
const view = new DataView(buffer);
view.setBigInt64(0, bigInt);
view.setBigInt64(0, bigInt, true);
this.serialized = this.concatArrays(this.serialized, new Uint8Array(view.buffer));

this.offset += 8;
Expand All @@ -208,7 +208,7 @@ export default class Args {
addF32(number: number): Args {
const buffer = new ArrayBuffer(4);
const view = new DataView(buffer);
view.setFloat32(0, number);
view.setFloat32(0, number, true);
this.serialized = this.concatArrays(this.serialized, new Uint8Array(view.buffer));

this.offset += 4;
Expand All @@ -225,7 +225,7 @@ export default class Args {
addF64(number: number): Args {
const buffer = new ArrayBuffer(8);
const view = new DataView(buffer);
view.setFloat64(0, number);
view.setFloat64(0, number, true);
this.serialized = this.concatArrays(this.serialized, new Uint8Array(view.buffer));

this.offset += 8;
Expand Down

0 comments on commit 86d79a7

Please sign in to comment.