We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
serialize
1 parent 994724b commit 1033984Copy full SHA for 1033984
packages/firebase-core/utils.ts
@@ -37,14 +37,15 @@ export function serialize(data: any, wrapPrimitives: boolean = false): any {
37
}
38
39
if (Array.isArray(data)) {
40
- return NSArray.arrayWithArray((<any>data).map(serialize));
+ return NSArray.arrayWithArray(data.map((el) => serialize(el, wrapPrimitives)).filter((el) => el !== null));
41
42
43
- let node = {} as any;
44
- Object.keys(data).forEach(function (key) {
45
- let value = data[key];
46
- node[key] = serialize(value, wrapPrimitives);
47
- });
+ const node = Object.fromEntries(
+ Object.entries(data)
+ .map(([key, value]) => [key, serialize(value, wrapPrimitives)])
+ .filter(([, value]) => value !== null)
+ );
48
+
49
return NSDictionary.dictionaryWithDictionary(node);
50
51
0 commit comments