Skip to content

Commit

Permalink
pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JairusSW committed Jan 17, 2025
1 parent 5111abd commit 6003b7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions assembly/deserialize/simple/bool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CHAR_F, CHAR_T } from "../../custom/chars";
export function deserializeBoolean(srcStart: usize, srcEnd: usize): boolean {
const srcSize = srcEnd - srcStart;
const firstChar = load<u16>(srcStart);
if (srcSize == 4 && firstChar == CHAR_T && load<u64>(srcStart) == 28429475166421108) return true;
else if (srcSize == 5 && firstChar == CHAR_F && load<u64>(srcSize, 2) == 28429466576093281) return false;
if (firstChar == CHAR_T && load<u64>(srcStart) == 28429475166421108) return true;
else if (firstChar == CHAR_F && load<u64>(srcSize, 2) == 28429466576093281) return false;
return false; //ERROR(`Expected to find boolean, but found "${data.slice(0, 100)}" instead!`);
}
}
4 changes: 2 additions & 2 deletions assembly/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export namespace JSON {
* @returns string
*/
export function stringify<T>(data: T, out: string | null = null): string {
if (isBoolean<T>(data)) {
if (isBoolean<T>()) {
if (out) {
if (<bool>data == true) {
out = changetype<string>(__renew(changetype<usize>(out), 8));
Expand All @@ -60,7 +60,7 @@ export namespace JSON {
}
return out;
}
return out ? "true" : "false";
return data ? "true" : "false";
} else if (isInteger<T>() && nameof<T>() == "usize" && data == 0) {
if (out) {
out = changetype<string>(__renew(changetype<usize>(out), 8));
Expand Down

0 comments on commit 6003b7d

Please sign in to comment.