frontend/.pnpm-store/v3/files/17/b87dfafc5e03028fcb866a02c61694ad4cffba994da2de7d69742bf81da35bfba0b66b0e595d3d863c50751afd24772e88d65fafd2bbf104840088947bd58d

29 lines
737 B
Plaintext

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