is-callback-function

Returns true if function is a callback. Checks its name is one of common-callback-names - callback, cb, cb_, callback_, next, done, they can be customized, these are default.
Install
npm i is-callback-function --save
Usage
For more use-cases see the tests
const isCallbackFunction =
isCallbackFunction
Check if given
fn
is callback function or not. Notice that "async" functions are notis-callback-function
, they are is-async-function - it may be consfusing, but they are different.
Params
fn
{Function}names
{Array}returns
{Boolean}
Example
var fs = var isCallback = var isAsync = console // => falseconsole // => true console // => falseconsole // => true console // => trueconsole // => false console // => falseconsole // => true console // => falseconsole // => false console // => trueconsole // => trueconsole // => false
Whaaat?!
Need clarification? Both signatures are equal.
is-callback-function
- checks the name of given functionis-async-function
- checks the arguments names of given function
Related
- arr-includes: Return true if any of passed values exists in array. Using in-array. | homepage
- common-callback-names: List of common callback names - callback, cb, callback_, next, done. | homepage
- function-arguments: Get arguments of a function, useful for and used in dependency injectors.… more | homepage
- get-fn-name: Get function name with strictness and correctness in mind. Also works for… more | homepage
- in-array: Return true if a value exists in an array. Faster than using… more | homepage
- is-async-function: Is function really asynchronous function? Trying to guess that based on check… more | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.