is-callable
Is this JS value callable? Works with Functions and GeneratorFunctions, despite ES6 @@toStringTag.
Last updated 4 years ago by ljharb .
MIT · Repository · Bugs · Original npm
$ cnpm install is-callable 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.2.7                                ...           latest (3 years ago)

5 Versions

  • 1.2.7                                ...           3 years ago
  • 1.2.4                                ...           4 years ago
  • 1.2.3                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.5                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (16)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org