UNPKG

@wordpress/block-editor

Version:
30 lines (24 loc) 711 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cleanEmptyObject = void 0; var _lodash = require("lodash"); /** * External dependencies */ /** * Removed undefined values from nested object. * * @param {*} object * @return {*} Object cleaned from undefined values */ const cleanEmptyObject = object => { if (!(0, _lodash.isObject)(object)) { return object; } const cleanedNestedObjects = (0, _lodash.pickBy)((0, _lodash.mapValues)(object, cleanEmptyObject), _lodash.identity); return (0, _lodash.isEqual)(cleanedNestedObjects, {}) ? undefined : cleanedNestedObjects; }; exports.cleanEmptyObject = cleanEmptyObject; //# sourceMappingURL=utils.js.map