Projekt

Obecné

Profil

Stáhnout (1.93 KB) Statistiky
| Větev: | Revize:
1
# is-callable <sup>[![Version Badge][2]][1]</sup>
2

    
3
[![Build Status][3]][4]
4
[![dependency status][5]][6]
5
[![dev dependency status][7]][8]
6
[![License][license-image]][license-url]
7
[![Downloads][downloads-image]][downloads-url]
8

    
9
[![npm badge][11]][1]
10

    
11
[![browser support][9]][10]
12

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

    
15
## Example
16

    
17
```js
18
var isCallable = require('is-callable');
19
var assert = require('assert');
20

    
21
assert.notOk(isCallable(undefined));
22
assert.notOk(isCallable(null));
23
assert.notOk(isCallable(false));
24
assert.notOk(isCallable(true));
25
assert.notOk(isCallable([]));
26
assert.notOk(isCallable({}));
27
assert.notOk(isCallable(/a/g));
28
assert.notOk(isCallable(new RegExp('a', 'g')));
29
assert.notOk(isCallable(new Date()));
30
assert.notOk(isCallable(42));
31
assert.notOk(isCallable(NaN));
32
assert.notOk(isCallable(Infinity));
33
assert.notOk(isCallable(new Number(42)));
34
assert.notOk(isCallable('foo'));
35
assert.notOk(isCallable(Object('foo')));
36

    
37
assert.ok(isCallable(function () {}));
38
assert.ok(isCallable(function* () {}));
39
assert.ok(isCallable(x => x * x));
40
```
41

    
42
## Tests
43
Simply clone the repo, `npm install`, and run `npm test`
44

    
45
[1]: https://npmjs.org/package/is-callable
46
[2]: http://versionbadg.es/ljharb/is-callable.svg
47
[3]: https://travis-ci.org/ljharb/is-callable.svg
48
[4]: https://travis-ci.org/ljharb/is-callable
49
[5]: https://david-dm.org/ljharb/is-callable.svg
50
[6]: https://david-dm.org/ljharb/is-callable
51
[7]: https://david-dm.org/ljharb/is-callable/dev-status.svg
52
[8]: https://david-dm.org/ljharb/is-callable#info=devDependencies
53
[9]: https://ci.testling.com/ljharb/is-callable.png
54
[10]: https://ci.testling.com/ljharb/is-callable
55
[11]: https://nodei.co/npm/is-callable.png?downloads=true&stars=true
56
[license-image]: http://img.shields.io/npm/l/is-callable.svg
57
[license-url]: LICENSE
58
[downloads-image]: http://img.shields.io/npm/dm/is-callable.svg
59
[downloads-url]: http://npm-stat.com/charts.html?package=is-callable
(5-5/7)