Instantiate a new wasm string to convert JSON value to BigInt

This commit is contained in:
Prathamesh Musale 2023-11-21 17:39:33 +05:30
parent e6b957e921
commit d455a95c9f
2 changed files with 5 additions and 5 deletions

View File

@ -778,9 +778,9 @@ export const instantiate = async (
'json.toF64': async (decimal: number) => { 'json.toF64': async (decimal: number) => {
return BigInt(__getString(decimal)); return BigInt(__getString(decimal));
}, },
// TODO: Debug toBigInt not working.
'json.toBigInt': async (decimal: number) => { 'json.toBigInt': async (decimal: number) => {
return ASBigInt.fromString(decimal); const ptr = await __newString(__getString(decimal));
return ASBigInt.fromString(ptr);
} }
} }
}; };

View File

@ -581,9 +581,9 @@ export function testJsonFromBytes (): void {
// const i64Value = numberValue.toI64(); // const i64Value = numberValue.toI64();
// assert(i64Value == 123, 'values are not equal'); // assert(i64Value == 123, 'values are not equal');
// TODO: Debug json toBigInt failing test case. const bigIntValue = numberValue.toBigInt();
// const bigIntValue = numberValue.toBigInt(); const expectedBigInt = BigInt.fromString('123');
// assert(bigIntValue.toString() == '123', 'values are not equal'); assert(bigIntValue.equals(expectedBigInt), 'BigInt values are not equal');
} }
export function testJsonTryFromBytes (): void { export function testJsonTryFromBytes (): void {