Learn how companies like Phone2Action are using npm in their front-end developmentJoin the conversation »

es-abstract-is-callable

0.1.0 • Public • Published

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))      // => false
console.log(isCallable(a.yep))  // => true
console.log(isCallable(a.nope)) // => false
console.log(isCallable(b))      // => true
console.log(isCallable(c))      // => true

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.

Install

npm i es-abstract-is-callable

DownloadsWeekly Downloads

2

Version

0.1.0

License

BSD-3-Clause

Last publish

Collaborators

  • avatar