IsCallable
A method to determine if an argument is a callable function with a call method.
This method follows ECMAScript's specification for the 'IsCallable ' abstract
operation.
Currently, this module only supports the ES2017 (ES8) specification.
This module follows the spec in order of operations, but has no way of
checking internal methods. It checks against public methods instead. You may be
interested in is-callable as an
alternative.
Installation Using npm
npm install es-abstract-is-callable
Example Usage
var isCallable = require('es-abstract-is-callable')
var a = {
yep: function() {},
nope: "foo"
}
function b() {}
var c = {
call: function() {}
}
console.log(isCallable(a))
console.log(isCallable(a.yep))
console.log(isCallable(a.nope))
console.log(isCallable(b))
console.log(isCallable(c))
Documentation
API
IsCallable ( argument )
The abstract operation IsCallable determines if argument, which must be an
ECMAScript language value, is a callable function with a [[Call]] internal
method.
A Boolean value is returned.
argument
Type: *
The value to check.
Related Projects
- is-callable: "Is this JS value
callable? Works with Functions and GeneratorFunctions, despite ES6
@@toStringTag."
- es-abstract: a single library
for multiple ECMAScript abstract operations.