1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-25 05:23:13 +03:00

Handle missing params

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner
2021-07-28 19:06:24 +02:00
parent 606aa29381
commit b3c66848e2

View File

@@ -703,6 +703,9 @@ export function compare(a: string, b: string): number {
* @returns the target object
*/
export function recursivelyAssign<T extends Object, S extends Object>(target: T, source: S, ignoreNullish = false): T {
if (!target) target = Object({});
if (!source) source = Object({});
for (const [sourceKey, sourceValue] of Object.entries(source)) {
if (target[sourceKey] instanceof Object && sourceValue) {
recursivelyAssign(target[sourceKey], sourceValue);