You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
557 B
19 lines
557 B
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;
|
|
}
|