A Function instance that's a constructor (either regular function or class)
Confirms if given object is a constructor function_
const isConstructor = require("type/constructor/is");
isConstructor(function () {}); // true
isConstructor(() => {}); // false
isConstructor(class {}); // true
isConstructor("foo"); // false
If given argument is a constructor function, it is returned back. Otherwise TypeError
is thrown.
const ensureConstructor = require("type/constructor/ensure");
const fn = function () {};
ensureConstructor(fn); // fn
ensureConstructor(() => {}); // Thrown TypeError: () => {} is not a constructor function