From bcda936585717af82c1a04c57da7f1542e3e4fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Wed, 21 Feb 2024 10:12:19 -0600 Subject: [PATCH] fix: undef handling --- src/core/streams/cdon.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/streams/cdon.ts b/src/core/streams/cdon.ts index 0c293df0f..478b72638 100644 --- a/src/core/streams/cdon.ts +++ b/src/core/streams/cdon.ts @@ -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, ) { - 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, );