npm explorer

assert-is-function-x

v3.1.2

If isFunction(callbackfn) is false, throw a TypeError exception.

assertIsFunctionmodulejavascriptnodejsbrowser
1.0K/weekUpdated 3 years agoMITUnpacked: 189.3 KB
Published by Graham Fairweather
npm install assert-is-function-x
RepositoryHomepagenpm

href="https://travis-ci.org/Xotic750/assert-is-function-x"
title="Travis status">
src="https://travis-ci.org/Xotic750/assert-is-function-x.svg?branch=master"
alt="Travis status" height="18">

href="https://david-dm.org/Xotic750/assert-is-function-x"
title="Dependency status">
alt="Dependency status" height="18"/>

href="https://david-dm.org/Xotic750/assert-is-function-x?type=dev"
title="devDependency status">
alt="devDependency status" height="18"/>

href="https://badge.fury.io/js/assert-is-function-x"
title="npm version">
alt="npm version" height="18">

href="https://www.jsdelivr.com/package/npm/assert-is-function-x"
title="jsDelivr hits">
alt="jsDelivr hits" height="18">

href="https://bettercodehub.com/results/Xotic750/assert-is-function-x"
title="bettercodehub score">
alt="bettercodehub score" height="18">

href="https://coveralls.io/github/Xotic750/assert-is-function-x?branch=master"
title="Coverage Status">
alt="Coverage Status" height="18">

assert-is-function-x

If isFunction(callbackfn) is false, throw a TypeError exception.

$3

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.
``

assert-is-function-x - npm explorer