@ayanaware/bento
Version:
Modular runtime framework designed to solve complex tasks
25 lines • 730 B
JavaScript
;
/**
* Check if fn is indeed a class
*
* @param fn Function to check
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.isClass = void 0;
// Function type is intended
// eslint-disable-next-line @typescript-eslint/ban-types
function isClass(fn) {
// Classes are a Function
if (typeof fn !== 'function')
return false;
// Classes have both prototype & constructor
if (!fn.prototype || !fn.constructor)
return false;
// Credit: https://github.com/miguelmota/is-class
const sig = Function.prototype.toString.call(fn);
if (/^class[\s{]/.test(sig))
return true;
return false;
}
exports.isClass = isClass;
//# sourceMappingURL=isClass.js.map