Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (Array.isArray(object)) {
return object.filter(value => {
if (isObject(value)) {
return filterAllEmpty(value);
}
return true;
}) as T;
}
const result = {} as T;
const keys = Object.keys(object);
for (const key of keys) {
const k = key as keyof T;
const value = object[k];
result[k] = isObject(value) ? filterAllEmpty(value) : object[k];
}
return result;
}
return object.filter(value => {
if (isObject(value)) {
return filterAllEmpty(value);
}
return true;
}) as T;
}
): boolean {
if (objA === objB) return true;
if (!objA || !objB) return false;
const aKeys = Object.keys(objA);
const bKeys = Object.keys(objB);
const { length } = aKeys;
if (bKeys.length !== length) return false;
for (const key of aKeys) {
if (objA[key] !== objB[key]) {
if (
!depth ||
!isObject(objA[key]) ||
!isObject(objB[key]) ||
!deepEqual(objA[key], objB[key], depth - 1)
) {
return false;
}
}
}
return true;
}
result[key] = val.map(v => {
if (isObject(v)) {
return unstable_setAllIn(v, value);
}
return value;
});
} else if (isObject(val)) {
export function unstable_setAllIn(object: T, value: V) {
const typedObject = object as Record;
const result = {} as Record;
const keys = Object.keys(object);
for (const key of keys) {
const val = typedObject[key];
if (Array.isArray(val)) {
result[key] = val.map(v => {
if (isObject(v)) {
return unstable_setAllIn(v, value);
}
return value;
});
} else if (isObject(val)) {
result[key] = unstable_setAllIn(val, value);
} else {
result[key] = value;
}
}
return result as DeepMap;
}