UNPKG

helene

Version:
79 lines 1.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CustomModels = void 0; const _1 = require("."); class Address { city; state; constructor(city, state) { this.city = city; this.state = state; } typeName() { return 'Address'; } toJSONValue() { return { city: this.city, state: this.state, }; } equals(other) { return (other instanceof Address && this.city === other.city && this.state === other.state); } } class Person { name; birthDate; address; constructor(name, birthDate, address) { this.name = name; this.birthDate = birthDate; this.address = address; } typeName() { return 'Person'; } toJSONValue() { return { name: this.name, birthDate: _1.EJSON.toJSONValue(this.birthDate), address: _1.EJSON.toJSONValue(this.address), }; } equals(other) { return (other instanceof Person && this.name === other.name && _1.EJSON.equals(this.birthDate, other.birthDate) && _1.EJSON.equals(this.address, other.address)); } } class Holder { value; constructor(value) { this.value = value; } typeName() { return 'Holder'; } toJSONValue() { return this.value; } equals(other) { return other instanceof Holder && _1.EJSON.equals(this.value, other.value); } } const addTypes = () => { _1.EJSON.addType('Person', value => new Person(value.name, _1.EJSON.fromJSONValue(value.birthDate), _1.EJSON.fromJSONValue(value.address))); _1.EJSON.addType('Address', value => new Address(value.city, value.state)); _1.EJSON.addType('Holder', value => new Holder(value)); }; exports.CustomModels = { Address, Person, Holder, addTypes, }; //# sourceMappingURL=custom-models.js.map