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