Skip to content

Commit

Permalink
fix(ios/core): filter out nil values from serialize method (#142)
Browse files Browse the repository at this point in the history
* filter out null event params

* remove NSNull check
  • Loading branch information
mukaschultze committed Oct 31, 2022
1 parent 994724b commit 1033984
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/firebase-core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ export function serialize(data: any, wrapPrimitives: boolean = false): any {
}

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

let node = {} as any;
Object.keys(data).forEach(function (key) {
let value = data[key];
node[key] = serialize(value, wrapPrimitives);
});
const node = Object.fromEntries(
Object.entries(data)
.map(([key, value]) => [key, serialize(value, wrapPrimitives)])
.filter(([, value]) => value !== null)
);

return NSDictionary.dictionaryWithDictionary(node);
}

Expand Down

0 comments on commit 1033984

Please sign in to comment.