has-callback

0.0.3 • Public • Published

hasCallback

Check if function takes callback as argument.

Will check for common callback names in argument footprint:

  • callback
  • cb
  • done
  • next

API

hasCallback(fn, [userDefinedNames])

fn

Type: function

(Required)

The function to be tested.

userDefinedNames

Type: string | array

User-defined callback name string or list of strings.

Example Usage

import hasCallback from 'has-callback';

hasCallback(JSON.stringify);
// => false

hasCallback(fs.rename);
// => true

Limitations

This function merely checks the name of function arguments, it is not a reliable way of checking if a function is asynchronous, for example it will not detect if a function returns a Promise.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.3
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.3
    2
  • 0.0.2
    0
  • 0.0.1
    0
  • 0.0.0
    0

Package Sidebar

Install

npm i has-callback

Weekly Downloads

2

Version

0.0.3

License

MIT

Last publish

Collaborators

  • rohan_orton