is-fun
v1.0.4
Published
Checks whether given variable is callable. Works fine function and generators in spite of ES6 @@toStringTag
Downloads
73
Maintainers
Readme
Yes! One more package detecting that given variable is function.
Made as drop-in replacement for is-callable package, but lighter and faster
npm install is-fun
# or via yarn
yarn add is-fun
Use it wherever and however you want - node.js or webpack, CJS or ESM modules!
const isFun = require("is-fun");
isFun(() => {}); // true
import isFun from "is-fun";
isFun(undefined); // false
isFun(null); // false
isFun(false); // false
isFun(true); // false
isFun([]); // false
isFun({}); // false
isFun(/a/g); // false
isFun(new RegExp("a", "g")); // false
isFun(new Date()); // false
isFun(42); // false
isFun(NaN); // false
isFun(Infinity); // false
isFun(new Number(42)); // false
isFun("foo"); // false
isFun(Object("foo")); // false
isFun(function() {}); // true
isFun(function*() {}); // true
isFun(x => x * x); // true
Performance (recent benchmarks results)
benchmarks ran on 3.4GHz Core i7 CPU width 16GB DDR4 RAM
npm run build && npm i -C benchmark && npm -C benchmark start