@gechiui/block-editor
Version:
30 lines (24 loc) • 724 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.cleanEmptyObject = void 0;
var _lodash = require("lodash");
/**
* External dependencies
*/
/**
* Removed falsy values from nested object.
*
* @param {*} object
* @return {*} Object cleaned from falsy values
*/
const cleanEmptyObject = object => {
if (!(0, _lodash.isObject)(object) || Array.isArray(object)) {
return object;
}
const cleanedNestedObjects = (0, _lodash.pickBy)((0, _lodash.mapValues)(object, cleanEmptyObject), _lodash.identity);
return (0, _lodash.isEmpty)(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
};
exports.cleanEmptyObject = cleanEmptyObject;
//# sourceMappingURL=utils.js.map