@httpc/kit
Version:
httpc toolbox for building function-based API with minimal code and end-to-end type safety
12 lines (11 loc) • 360 B
JavaScript
export function cleanUndefined(obj) {
return cleanObject(obj, [undefined]);
}
export function cleanNotDefined(obj) {
return cleanObject(obj, [undefined, null]);
}
export function cleanObject(obj, values) {
if (!obj)
return obj;
return Object.fromEntries(Object.entries(obj).filter(([, value]) => !values.includes(value)));
}