MCPcopy Create free account
hub / github.com/LevelUpWeb3/app / removeNullish

Function removeNullish

src/utils/common.ts:108–126  ·  view source on GitHub ↗
(obj: any)

Source from the content-addressed store, hash-verified

106
107 // Then recursively remove nullish values
108 const removeNullish = (obj: any): any => {
109 if (!isPlainObject(obj)) {
110 return isNil(obj) ? undefined : obj;
111 }
112
113 if (Array.isArray(obj)) {
114 return obj
115 .filter((item) => !isNil(item))
116 .map((item) => removeNullish(item));
117 }
118
119 return Object.entries(obj).reduce((acc, [key, value]) => {
120 const cleanValue = removeNullish(value);
121 if (!isNil(cleanValue)) {
122 acc[key] = cleanValue;
123 }
124 return acc;
125 }, {} as any);
126 };
127
128 return removeNullish(merged) as T;
129}

Callers 1

mergeNoNullishFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected