caoge c760052ff9 机车状态修改 | преди 8 месеца | |
---|---|---|
.. | ||
.github | преди 8 месеца | |
test | преди 8 месеца | |
.editorconfig | преди 8 месеца | |
.eslintrc | преди 8 месеца | |
.nycrc | преди 8 месеца | |
CHANGELOG.md | преди 8 месеца | |
LICENSE | преди 8 месеца | |
README.md | преди 8 месеца | |
index.js | преди 8 месеца | |
package.json | преди 8 месеца |
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