d26db06f74
NPM Installation / build (16.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (16.x, windows-latest) (push) Has been cancelled
NPM Installation / build (17.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (17.x, windows-latest) (push) Has been cancelled
NPM Installation / build (18.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (18.x, windows-latest) (push) Has been cancelled
20 lines
557 B
JavaScript
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;
|
|
}
|