All Projects → inspect-js → is-callable

inspect-js / is-callable

Licence: MIT license
Is this JS value callable? Works with Functions and GeneratorFunctions, despite ES6 @@toStringTag.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to is-callable

parallelizer
Simplifies the parallelization of function calls.
Stars: ✭ 62 (+63.16%)
Mutual labels:  functions, function
touch-callable
Automatically generate a Web UI for Python function using type annotations.
Stars: ✭ 36 (-5.26%)
Mutual labels:  function, callable
fnts
λ Minimal Functional Programming Utilities for TypeScript & JavaScript
Stars: ✭ 75 (+97.37%)
Mutual labels:  functions, function
serverless-scaleway-functions
Plugin for Serverless Framework to allow users to deploy their serverless applications on Scaleway Functions
Stars: ✭ 58 (+52.63%)
Mutual labels:  functions, function
Netlify Functions Workshop
Netlify Serverless Functions Workshop
Stars: ✭ 203 (+434.21%)
Mutual labels:  functions
Safe
All PHP functions, rewritten to throw exceptions instead of returning false
Stars: ✭ 1,890 (+4873.68%)
Mutual labels:  functions
Openwhisk Devtools
Development tools for building and deploying Apache OpenWhisk
Stars: ✭ 141 (+271.05%)
Mutual labels:  functions
Store
Official Function and Template Store for OpenFaaS
Stars: ✭ 136 (+257.89%)
Mutual labels:  functions
second-bridge
Second Bridge is a Swift framework for functional programming. Our goal is to make Swift development on par with other functional languages like Scala by adding new data types, functions and operators.
Stars: ✭ 71 (+86.84%)
Mutual labels:  functions
libnica
Common C library functions
Stars: ✭ 37 (-2.63%)
Mutual labels:  function
Netlify Express
Express.js hosted on Netlify
Stars: ✭ 194 (+410.53%)
Mutual labels:  functions
Mcw Serverless Architecture
MCW Serverless architecture
Stars: ✭ 147 (+286.84%)
Mutual labels:  functions
Array Functions
Some handy array functions
Stars: ✭ 215 (+465.79%)
Mutual labels:  functions
Faas Netes
Serverless on Kubernetes with OpenFaaS
Stars: ✭ 1,875 (+4834.21%)
Mutual labels:  functions
Library
This is a project of a library, driven by real business requirements. We use techniques strongly connected with Domain Driven Design, Behavior-Driven Development, Event Storming, User Story Mapping.
Stars: ✭ 2,685 (+6965.79%)
Mutual labels:  functions
Idaobjctypes
A collection of types & functions definitions useful for Objective-C binaries analysis.
Stars: ✭ 138 (+263.16%)
Mutual labels:  functions
java-concurrent
OpenTracing-aware helpers related to java.util.concurrent
Stars: ✭ 36 (-5.26%)
Mutual labels:  callable
Vscode Azurefunctions
Azure Functions extension for VS Code
Stars: ✭ 191 (+402.63%)
Mutual labels:  functions
Torchfunc
PyTorch functions and utilities to make your life easier
Stars: ✭ 177 (+365.79%)
Mutual labels:  functions
Python Novice Inflammation
Programming with Python
Stars: ✭ 199 (+423.68%)
Mutual labels:  functions

is-callable Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

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

Supported engines

Automatically tested in every minor version of node.

Manually tested in:

  • Safari: v4 - v15 (4, 5, 5.1, 6.0.5, 6.2, 7.1, 8, 9.1.3, 10.1.2, 11.1.2, 12.1, 13.1.2, 14.1.2, 15.3, 15.6.1)
    • Note: Safari 9 has 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.
  • Chrome: v15 - v81, v83 - v106(every integer version)
    • Note: This includes Edge v80+ and Opera v15+, which matches Chrome
  • Firefox: v3, v3.6, v4 - v105 (every integer version)
    • Note: v45 - v54 has 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.
    • Note: in v42 - v63, Function.prototype.toString throws on HTML element constructors, or a Proxy to a function
    • Note: in v20 - v35, HTML element constructors are not callable, despite having typeof function.
    • Note: in v19, document.all is not callable.
  • IE: v6 - v11(every integer version
  • Opera: v11.1, v11.5, v11.6, v12.1, v12.14, v12.15, v12.16, v15+ v15+ matches Chrome

Example

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

Install with

npm install is-callable

Tests

Simply clone the repo, npm install, and run npm test

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].