assert-is-function-x

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

MIT 38 个版本
安装
npm install assert-is-function-x
yarn add assert-is-function-x
pnpm add assert-is-function-x
bun add assert-is-function-x
README

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

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

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 '#<Object> is not a function'.
assertIsFunction(mySymbol); // TypeError 'Symbol(mySymbol) is not a function'.
assertIsFunction(symObj); // TypeError '#<Object> is not a function'.
console.log(assertIsFunction(fn)); // Returns fn.
版本列表
3.1.2 2019-08-28
3.1.1 2019-08-20
3.1.0 2019-08-14
3.0.19 2019-07-31
3.0.18 2019-07-27
3.0.17 2019-07-27
3.0.16 2019-07-26
3.0.15 2019-07-25
3.0.14 2019-07-24
3.0.13 2019-07-24
3.0.12 2019-07-22
3.0.11 2019-07-21
3.0.10 2019-07-19
3.0.9 2019-07-18
3.0.8 2019-07-17
3.0.7 2019-07-17
3.0.6 2019-07-17
3.0.5 2019-07-17
3.0.4 2019-07-16
3.0.3 2019-07-16
3.0.2 2019-07-16
3.0.1 2019-07-15
3.0.0 2019-07-15
2.1.0 2017-10-18
2.0.1 2017-09-01
2.0.0 2017-08-30
1.5.0 2017-08-11
1.4.0 2017-08-11
1.3.0 2017-07-11
1.2.0 2017-03-29
1.1.1 2017-03-27
1.1.0 2017-03-10
1.0.5 2016-02-15
1.0.4 2016-02-13
1.0.3 2016-02-03
1.0.2 2016-01-25
1.0.1 2016-01-25
1.0.0 2016-01-21