Skip to content
Is this JS value callable? Works with Functions and GeneratorFunctions, despite ES6 @@toStringTag.
JavaScript Makefile HCL
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github [meta] add FUNDING.yml Jul 11, 2019
.editorconfig [Fix] class detection: Remove useless comment stripping Jul 2, 2018
.eslintrc [Fix] fix class detection Jul 2, 2018
.gitignore Only apps should have lockfiles. Jun 14, 2017
.istanbul.yml
.npmrc [Tests] use `npm audit` instead of `nsp` Dec 26, 2018
.travis.yml [Tests] on `node` `v12.8` Aug 7, 2019
CHANGELOG.md v1.1.4 Jul 2, 2018
LICENSE Initial commit Jan 29, 2015
Makefile [Tests] fix eccheck Jul 5, 2019
README.md Switch from vb.teelaun.ch to versionbadg.es for the npm version badge… Aug 12, 2015
index.js [Fix] class detection: Remove useless comment stripping Jul 2, 2018
package.json [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `rimraf`, `semve… Aug 17, 2019
test.js [Fix] class detection: Remove useless comment stripping Jul 2, 2018

README.md

is-callable Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

browser support

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));

Tests

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

You can’t perform that action at this time.