Skip to content

Commit 1033984

Browse files
authored
fix(ios/core): filter out nil values from serialize method (#142)
* filter out null event params * remove NSNull check
1 parent 994724b commit 1033984

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/firebase-core/utils.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ export function serialize(data: any, wrapPrimitives: boolean = false): any {
3737
}
3838

3939
if (Array.isArray(data)) {
40-
return NSArray.arrayWithArray((<any>data).map(serialize));
40+
return NSArray.arrayWithArray(data.map((el) => serialize(el, wrapPrimitives)).filter((el) => el !== null));
4141
}
4242

43-
let node = {} as any;
44-
Object.keys(data).forEach(function (key) {
45-
let value = data[key];
46-
node[key] = serialize(value, wrapPrimitives);
47-
});
43+
const node = Object.fromEntries(
44+
Object.entries(data)
45+
.map(([key, value]) => [key, serialize(value, wrapPrimitives)])
46+
.filter(([, value]) => value !== null)
47+
);
48+
4849
return NSDictionary.dictionaryWithDictionary(node);
4950
}
5051

0 commit comments

Comments
 (0)