chore: Merge master to develop (#3653)

This commit is contained in:
Oliver Windall Juhl
2023-03-31 13:09:57 +02:00
committed by GitHub
parent b2e2eddcea
commit 809ab2e0eb
120 changed files with 2240 additions and 585 deletions
+34
View File
@@ -0,0 +1,34 @@
import { isObject } from "./is-object"
export function omitDeep<T extends object = object>(
input: object,
excludes: Array<number | string>
): T {
if (!input) {
return input
}
return Object.entries(input).reduce((nextInput, [key, value]) => {
const shouldExclude = excludes.includes(key)
if (shouldExclude) {
return nextInput
}
if (Array.isArray(value)) {
nextInput[key] = value.map((arrItem) => {
if (isObject(arrItem)) {
return omitDeep(arrItem, excludes)
}
return arrItem
})
return nextInput
} else if (isObject(value)) {
nextInput[key] = omitDeep(value, excludes)
return nextInput
}
nextInput[key] = value
return nextInput
}, {} as T)
}