fix: undef handling

This commit is contained in:
TrèsAbhi committed 2024-02-21 10:12:19 -06:00
1 parent c16a5f1701
commit bcda936585
1 file changed
+3 -2
+3 -2
View File
@@ -27,6 +27,7 @@ enum FastStringFormat {
}
export type CdonValue =
| undefined
| null
| boolean
| number
@@ -212,7 +213,7 @@ export class CdonWriteStream extends WriteStream {
object: CdonValue,
stringTable: Map<string, number>,
) {
if (object === null) {
if (object === null || object === undefined) {
this.uint8(ValueType.Null);
} else if (typeof object === 'boolean') {
this.uint8(ValueType.Boolean);
@@ -289,7 +290,7 @@ export class CdonWriteStream extends WriteStream {
object.forEach((value) =>
this.value(fastStringFormat, value, stringTable),
);
} else if (object !== undefined) {
} else {
const entries = Object.entries(object).filter(
([, value]) => value !== undefined,
);