Bolshakova Anna ab21a11190 lab | 3 тижнів тому | |
---|---|---|
.. | ||
.github | 3 тижнів тому | |
test | 3 тижнів тому | |
.editorconfig | 3 тижнів тому | |
.eslintrc | 3 тижнів тому | |
.nycrc | 3 тижнів тому | |
CHANGELOG.md | 3 тижнів тому | |
LICENSE | 3 тижнів тому | |
README.md | 3 тижнів тому | |
index.js | 3 тижнів тому | |
package.json | 3 тижнів тому |
Is this JS value callable? Works with Functions and GeneratorFunctions, despite ES6 @@toStringTag.
Automatically tested in every minor version of node.
Manually tested in:
class
, but Function.prototype.toString
hides that progeny and makes them look like functions, so class
constructors will be reported by this package as callable, when they are not in fact callable.class
, but Function.prototype.toString
hides that progeny and makes them look like functions, so class
constructors will be reported by this package as callable, when they are not in fact callable.Function.prototype.toString
throws on HTML element constructors, or a Proxy to a functionfunction
.document.all
is not callable.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 with
npm install is-callable
Simply clone the repo, npm install
, and run npm test