1 import { isDefined } from "./is-defined"
2
3 export function removeNullish<T = unknown>(
4 obj: Record<string, T>
5 ): Record<string, T> {
6 return Object.entries(obj).reduce(
7 (resultObject, [currentKey, currentValue]) => {
8 if (!isDefined(currentValue) || currentValue === null) {
9 return resultObject
10 }
11
12 resultObject[currentKey] = currentValue
13
14 return resultObject
15 },
16 {}
17 )
18 }