@roots/bud-extensions
Version:
bud.js core module
18 lines (17 loc) • 368 B
JavaScript
/**
* isConstructor
*
* This function checks if the given subject is a constructor.
*
* @param subject Any JavaScript entity
* @returns true if subject is a constructor, false otherwise
*/
export const isConstructor = (subject) => {
try {
Reflect.construct(String, [], subject);
}
catch (e) {
return false;
}
return true;
};