line_push/node_modules/is-callable
2022-07-18 02:50:52 +00:00
..
.github add file 2022-07-17 13:16:16 +08:00
test update 2022-07-18 02:50:52 +00:00
.editorconfig update 2022-07-18 02:50:52 +00:00
.eslintignore update 2022-07-18 02:50:52 +00:00
.eslintrc update 2022-07-18 02:50:52 +00:00
.istanbul.yml add file 2022-07-17 13:16:16 +08:00
.nycrc update 2022-07-18 02:50:52 +00:00
.travis.yml add file 2022-07-17 13:16:16 +08:00
CHANGELOG.md update 2022-07-18 02:50:52 +00:00
index.js update 2022-07-18 02:50:52 +00:00
LICENSE add file 2022-07-17 13:16:16 +08:00
package.json update 2022-07-18 02:50:52 +00:00
README.md update 2022-07-18 02:50:52 +00:00

is-callable Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Is this JS value callable? Works with Functions and GeneratorFunctions, despite ES6 @@toStringTag.

Example

var isCallable = require('is-callable');
var assert = require('assert');

assert.notOk(isCallable(undefined));
assert.notOk(isCallable(null));
assert.notOk(isCallable(false));
assert.notOk(isCallable(true));
assert.notOk(isCallable([]));
assert.notOk(isCallable({}));
assert.notOk(isCallable(/a/g));
assert.notOk(isCallable(new RegExp('a', 'g')));
assert.notOk(isCallable(new Date()));
assert.notOk(isCallable(42));
assert.notOk(isCallable(NaN));
assert.notOk(isCallable(Infinity));
assert.notOk(isCallable(new Number(42)));
assert.notOk(isCallable('foo'));
assert.notOk(isCallable(Object('foo')));

assert.ok(isCallable(function () {}));
assert.ok(isCallable(function* () {}));
assert.ok(isCallable(x => x * x));

Install

Install with

npm install is-callable

Tests

Simply clone the repo, npm install, and run npm test