@chix/flow
Version:
51 lines • 1.87 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var common_1 = require("../common");
var util_1 = require("../util");
function $ToJSON(Base) {
return (function (_super) {
__extends(ToJSON$, _super);
function ToJSON$() {
return _super !== null && _super.apply(this, arguments) || this;
}
ToJSON$.prototype.toJSON = function () {
var _this = this;
var json = {
id: this.id,
name: this.name,
ns: this.ns,
};
['title', 'description', 'metadata', 'provider'].forEach(function (prop) {
var value = _this[prop];
if (value) {
if (typeof value !== 'object' || Object.keys(value).length > 0) {
json[prop] = value;
}
}
});
return json;
};
return ToJSON$;
}(Base));
}
exports.$ToJSON = $ToJSON;
(function ($ToJSON) {
function create(Base) {
return util_1.mixin($ToJSON, common_1.$Identity.create, common_1.$Meta.create)(Base);
}
$ToJSON.create = create;
})($ToJSON = exports.$ToJSON || (exports.$ToJSON = {}));
//# sourceMappingURL=toJSON.js.map