fumadocs-core
Version:
The library for building a documentation website in Next.js
22 lines (20 loc) • 493 B
JavaScript
// src/utils/remove-undefined.ts
function removeUndefined(value, deep = false) {
const obj = value;
for (const key in obj) {
if (obj[key] === void 0) delete obj[key];
if (!deep) continue;
const entry = obj[key];
if (typeof entry === "object" && entry !== null) {
removeUndefined(entry, deep);
continue;
}
if (Array.isArray(entry)) {
for (const item of entry) removeUndefined(item, deep);
}
}
return value;
}
export {
removeUndefined
};