You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I bumped into just-flush which was very close a function I needed. I wonder if you’d be open to accept a PR with a recursive version of the function, WDYT?
/** * Recursively removes null and undefined values from an object * https://stackoverflow.com/a/54707141/1818285 * TODO: consider refactoring (avoid conversion to string) */exportconstdeepClean=<T>(obj: T): OmitNullable<T> =>JSON.parse(JSON.stringify(obj,(key,value: unknown)=>value===null||value===undefined ? undefined : value,),)asOmitNullable<T>;
It works well for relatively small objects, but obviously does not scale if a JSON is very large. I’m looking for some third-party package that would save me from copying this small helper function between repos.
Hi @kachkaev, thanks for the nice words!
Yes I think this would be a useful util. I think a new function just-flush-recursive would be the best way, to keep the old one clean.
Hi @angus-c, great repo! 💯
I bumped into just-flush which was very close a function I needed. I wonder if you’d be open to accept a PR with a recursive version of the function, WDYT?
It might be also useful to consider a mode when nullish items are not removed from arrays, but not 100% sure about this 🤔
The text was updated successfully, but these errors were encountered: