Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
31 lines
867 B
Plaintext
31 lines
867 B
Plaintext
const entityKind = Symbol.for("drizzle:entityKind");
|
|
const hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
|
|
function is(value, type) {
|
|
if (!value || typeof value !== "object") {
|
|
return false;
|
|
}
|
|
if (value instanceof type) {
|
|
return true;
|
|
}
|
|
if (!Object.prototype.hasOwnProperty.call(type, entityKind)) {
|
|
throw new Error(
|
|
`Class "${type.name ?? "<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`
|
|
);
|
|
}
|
|
let cls = Object.getPrototypeOf(value).constructor;
|
|
if (cls) {
|
|
while (cls) {
|
|
if (entityKind in cls && cls[entityKind] === type[entityKind]) {
|
|
return true;
|
|
}
|
|
cls = Object.getPrototypeOf(cls);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
export {
|
|
entityKind,
|
|
hasOwnEntityKind,
|
|
is
|
|
};
|
|
//# sourceMappingURL=entity.js.map |