domain-objects
Version:
A simple, convenient way to represent domain objects, leverage domain knowledge, and add runtime validation in your code base.
20 lines • 839 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isOfDomainObject = void 0;
const markers_1 = require("../../instantiation/markers");
/**
* .what = checks if input is a DomainObject (class or instance)
* .why = supports cross version compatibility evaluation
* .note = uses marker symbol for cycle-free detection
* .note = static property lookup follows prototype chain automatically in JS
*/
const isOfDomainObject = (input) => {
if (typeof input === 'function') {
// class: check marker directly
return input?.[markers_1.MARK_AS_DOMAIN_OBJECT] !== undefined;
}
// instance: check via constructor
return input?.constructor?.[markers_1.MARK_AS_DOMAIN_OBJECT] !== undefined;
};
exports.isOfDomainObject = isOfDomainObject;
//# sourceMappingURL=isOfDomainObject.js.map