https://github.com/xotic750/assert-is-function-x
If isFunction(callbackfn) is false, throw a TypeError exception.
https://github.com/xotic750/assert-is-function-x
browser ecmascript nodejs
Last synced: about 2 months ago
JSON representation
If isFunction(callbackfn) is false, throw a TypeError exception.
- Host: GitHub
- URL: https://github.com/xotic750/assert-is-function-x
- Owner: Xotic750
- License: mit
- Created: 2016-01-21T18:56:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T22:49:16.000Z (over 2 years ago)
- Last Synced: 2025-04-30T20:28:23.080Z (about 2 months ago)
- Topics: browser, ecmascript, nodejs
- Language: JavaScript
- Size: 1.99 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## assert-is-function-x
If isFunction(callbackfn) is false, throw a TypeError exception.
### `module.exports(callback)` ⇒
\*
⏏Tests `callback` to see if it is a function, throws a `TypeError` if it is
not. Otherwise returns the `callback`.**Kind**: Exported function
**Returns**:\*
- Returns `callback` if it is function.
**Throws**:-
TypeError
Throws if `callback` is not a function.| Param | Type | Description |
| --------- | ------------------- | ----------------------------- |
| callback |\*
| The argument to be tested. |
| [message] |string
| Optional alternative message. |**Example**
```js
import assertIsFunction from 'assert-is-function-x';const primitive = true;
const mySymbol = Symbol('mySymbol');
const symObj = Object(mySymbol);
const object = {};
const fn = function fn() {};assertIsFunction(primitive); // TypeError 'true is not a function'.
assertIsFunction(object); // TypeError '# is not a function'.
assertIsFunction(mySymbol); // TypeError 'Symbol(mySymbol) is not a function'.
assertIsFunction(symObj); // TypeError '# is not a function'.
console.log(assertIsFunction(fn)); // Returns fn.
```