blob: 8f3dcedcbafdf7bc0df99ccc070aa3e8a0175106 [file] [log] [blame] [view]
Tim van der Lippe16aca392020-11-13 11:37:131# is-callable <sup>[![Version Badge][2]][1]</sup>
2
Tim van der Lippebc3a0b72021-11-08 15:22:373[![github actions][actions-image]][actions-url]
4[![coverage][codecov-image]][codecov-url]
Tim van der Lippe16aca392020-11-13 11:37:135[![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
Tim van der Lippe16aca392020-11-13 11:37:1312Is this JS value callable? Works with Functions and GeneratorFunctions, despite ES6 @@toStringTag.
13
14## Example
15
16```js
17var isCallable = require('is-callable');
18var assert = require('assert');
19
20assert.notOk(isCallable(undefined));
21assert.notOk(isCallable(null));
22assert.notOk(isCallable(false));
23assert.notOk(isCallable(true));
24assert.notOk(isCallable([]));
25assert.notOk(isCallable({}));
26assert.notOk(isCallable(/a/g));
27assert.notOk(isCallable(new RegExp('a', 'g')));
28assert.notOk(isCallable(new Date()));
29assert.notOk(isCallable(42));
30assert.notOk(isCallable(NaN));
31assert.notOk(isCallable(Infinity));
32assert.notOk(isCallable(new Number(42)));
33assert.notOk(isCallable('foo'));
34assert.notOk(isCallable(Object('foo')));
35
36assert.ok(isCallable(function () {}));
37assert.ok(isCallable(function* () {}));
38assert.ok(isCallable(x => x * x));
39```
40
41## Install
42
43Install with
44
45```
46npm install is-callable
47```
48
49## Tests
50
51Simply clone the repo, `npm install`, and run `npm test`
52
53[1]: https://npmjs.org/package/is-callable
Tim van der Lippebc3a0b72021-11-08 15:22:3754[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
Tim van der Lippe16aca392020-11-13 11:37:1359[11]: https://nodei.co/npm/is-callable.png?downloads=true&stars=true
Tim van der Lippebc3a0b72021-11-08 15:22:3760[license-image]: https://img.shields.io/npm/l/is-callable.svg
Tim van der Lippe16aca392020-11-13 11:37:1361[license-url]: LICENSE
Tim van der Lippebc3a0b72021-11-08 15:22:3762[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