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