1 | # is-callable <sup>[![Version Badge][2]][1]</sup>
|
2 |
|
3 | [![github actions][actions-image]][actions-url]
|
4 | [![coverage][codecov-image]][codecov-url]
|
5 | [![dependency status][5]][6]
|
6 | [![dev dependency status][7]][8]
|
7 | [![License][license-image]][license-url]
|
8 | [![Downloads][downloads-image]][downloads-url]
|
9 |
|
10 | [![npm badge][11]][1]
|
11 |
|
12 | Is this JS value callable? Works with Functions and GeneratorFunctions, despite ES6 @@toStringTag.
|
13 |
|
14 | ## Example
|
15 |
|
16 | ```js
|
17 | var isCallable = require('is-callable');
|
18 | var assert = require('assert');
|
19 |
|
20 | assert.notOk(isCallable(undefined));
|
21 | assert.notOk(isCallable(null));
|
22 | assert.notOk(isCallable(false));
|
23 | assert.notOk(isCallable(true));
|
24 | assert.notOk(isCallable([]));
|
25 | assert.notOk(isCallable({}));
|
26 | assert.notOk(isCallable(/a/g));
|
27 | assert.notOk(isCallable(new RegExp('a', 'g')));
|
28 | assert.notOk(isCallable(new Date()));
|
29 | assert.notOk(isCallable(42));
|
30 | assert.notOk(isCallable(NaN));
|
31 | assert.notOk(isCallable(Infinity));
|
32 | assert.notOk(isCallable(new Number(42)));
|
33 | assert.notOk(isCallable('foo'));
|
34 | assert.notOk(isCallable(Object('foo')));
|
35 |
|
36 | assert.ok(isCallable(function () {}));
|
37 | assert.ok(isCallable(function* () {}));
|
38 | assert.ok(isCallable(x => x * x));
|
39 | ```
|
40 |
|
41 | ## Install
|
42 |
|
43 | Install with
|
44 |
|
45 | ```
|
46 | npm install is-callable
|
47 | ```
|
48 |
|
49 | ## Tests
|
50 |
|
51 | Simply clone the repo, `npm install`, and run `npm test`
|
52 |
|
53 | [1]: https://npmjs.org/package/is-callable
|
54 | [2]: https://versionbadg.es/inspect-js/is-callable.svg
|
55 | [5]: https://david-dm.org/inspect-js/is-callable.svg
|
56 | [6]: https://david-dm.org/inspect-js/is-callable
|
57 | [7]: https://david-dm.org/inspect-js/is-callable/dev-status.svg
|
58 | [8]: https://david-dm.org/inspect-js/is-callable#info=devDependencies
|
59 | [11]: https://nodei.co/npm/is-callable.png?downloads=true&stars=true
|
60 | [license-image]: https://img.shields.io/npm/l/is-callable.svg
|
61 | [license-url]: LICENSE
|
62 | [downloads-image]: https://img.shields.io/npm/dm/is-callable.svg
|
63 | [downloads-url]: https://npm-stat.com/charts.html?package=is-callable
|
64 | [codecov-image]: https://codecov.io/gh/inspect-js/is-callable/branch/main/graphs/badge.svg
|
65 | [codecov-url]: https://app.codecov.io/gh/inspect-js/is-callable/
|
66 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-callable
|
67 | [actions-url]: https://github.com/inspect-js/is-callable/actions
|