domain-objects
Version:
A simple, convenient way to represent domain objects, leverage domain knowledge, and add runtime validation in your code base.
23 lines • 851 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isOfDomainEvent = void 0;
const DomainEvent_1 = require("../../instantiation/DomainEvent");
/**
* .what = checks if an object is an instance of DomainEvent
* .why = supports cross version compatability evaluation
*/
const isOfDomainEvent = (obj) => {
// Check direct instanceof first (fast path for same-version)
if (obj instanceof DomainEvent_1.DomainEvent)
return true;
// Check for the marker symbol in the prototype chain (cross-version support)
let proto = obj?.constructor;
while (proto) {
if (proto[DomainEvent_1.MARK_AS_DOMAIN_EVENT])
return true;
proto = Object.getPrototypeOf(proto);
}
return false;
};
exports.isOfDomainEvent = isOfDomainEvent;
//# sourceMappingURL=isOfDomainEvent.js.map