@platform/cell.schema
Version:
URI and database schemas for the `cell.os`.
38 lines (37 loc) • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var common_1 = require("../common");
exports.squash = {
props: function (props) {
return exports.squash.object(props);
},
cell: function (cell, options) {
if (options === void 0) { options = {}; }
var empty = common_1.defaultValue(options.empty, undefined);
if (!cell) {
return empty;
}
else {
var res_1 = tslib_1.__assign({}, cell);
Object.keys(res_1)
.filter(function (key) { return common_1.isUndefinedOrEmptyObject(res_1[key]); })
.forEach(function (key) { return delete res_1[key]; });
return exports.squash.object(res_1, options);
}
},
object: function (obj, options) {
if (options === void 0) { options = {}; }
var empty = common_1.defaultValue(options.empty, undefined);
if (!obj) {
return empty;
}
else {
var res_2 = tslib_1.__assign({}, obj);
Object.keys(res_2)
.filter(function (key) { return common_1.isUndefinedOrEmptyObject(res_2[key]); })
.forEach(function (key) { return delete res_2[key]; });
return common_1.isUndefinedOrEmptyObject(res_2, { ignoreHash: true }) ? empty : res_2;
}
},
};