@wordpress/block-library
Version:
Block library for the WordPress editor.
33 lines (26 loc) • 787 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _lodash = require("lodash");
/**
* External dependencies
*/
const identity = x => x;
/**
* Removed empty nodes from nested objects.
*
* @param {Object} object
* @return {Object} Object cleaned from empty nodes.
*/
const cleanEmptyObject = object => {
if (object === null || typeof object !== 'object' || Array.isArray(object)) {
return object;
}
const cleanedNestedObjects = (0, _lodash.pickBy)((0, _lodash.mapValues)(object, cleanEmptyObject), identity);
return (0, _lodash.isEmpty)(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
};
var _default = cleanEmptyObject;
exports.default = _default;
//# sourceMappingURL=clean-empty-object.js.map