assert-is-callable-x
If IsCallable(callbackfn) is false, throw a TypeError exception.
module.exports(value)
⇒ *
⏏
Tests callback
to see if it is callable, throws a TypeError
if it is
not. Otherwise returns the callback
.
Kind: Exported function
Returns: *
- Returns callback
if it is callable.
Throws:
TypeError
Throws ifcallback
is not a callable.
Param | Type | Description |
---|---|---|
value | * |
The argument to be tested. |
[message] | string |
Optional alternative message. |
Example
; const primitive = true;const mySymbol = Symbol'mySymbol';const symObj = ObjectmySymbol;const object = {};const fn = {}; ; // TypeError 'true is not callable'.; // TypeError '#<Object> is not callable'.; // TypeError 'Symbol(mySymbol) is not callable'.; // TypeError '#<Object> is not callable'.console; // Returns fn.