protoobject
Version:
A universal class for creating any JSON objects and simple manipulations with them.
35 lines • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.protoObjectFactory = protoObjectFactory;
const proto_object_1 = require("../classes/proto-object");
/**
* A factory for creating classes based on the ProtoObject class
*
* @param methods - Methods that should be updated in the class being created.
* @returns - an ProtoObject's heir
*/
function protoObjectFactory(methods) {
class CProtoObject extends proto_object_1.ProtoObject {
constructor(data) {
super(data);
if (methods) {
Object.keys(methods)
.filter((key) => typeof this[key] === "function")
.map((key) => key)
.forEach((key) => {
this[key] = methods[key];
});
}
}
}
if (methods) {
Object.keys(methods)
.filter((key) => typeof CProtoObject[key] === "function")
.map((key) => key)
.forEach((key) => {
CProtoObject[key] = methods[key];
});
}
return CProtoObject;
}
//# sourceMappingURL=protoobject-factory.js.map