UNPKG

@gechiui/block-editor

Version:
20 lines (18 loc) 548 B
/** * External dependencies */ import { pickBy, isEmpty, isObject, identity, mapValues } from 'lodash'; /** * Removed falsy values from nested object. * * @param {*} object * @return {*} Object cleaned from falsy values */ export const cleanEmptyObject = object => { if (!isObject(object) || Array.isArray(object)) { return object; } const cleanedNestedObjects = pickBy(mapValues(object, cleanEmptyObject), identity); return isEmpty(cleanedNestedObjects) ? undefined : cleanedNestedObjects; }; //# sourceMappingURL=utils.js.map