Files
CtrlCash/node_modules/is-what/dist/isInstanceOf.js
2025-10-29 19:56:41 -03:00

20 lines
557 B
JavaScript

import { getType } from './getType.js';
import { isType } from './isType.js';
export function isInstanceOf(value, classOrClassName) {
if (typeof classOrClassName === 'function') {
for (let p = value; p; p = Object.getPrototypeOf(p)) {
if (isType(p, classOrClassName)) {
return true;
}
}
}
else {
for (let p = value; p; p = Object.getPrototypeOf(p)) {
if (getType(p) === classOrClassName) {
return true;
}
}
}
return false;
}