is-bound-function
Check if given function is bound or not.
You might also be interested in bind-context.
Install
npm i is-bound-function --save
Usage
For more use-cases see the tests
const isBoundFunction =
isBoundFunction
Check
fn
is bound function,false
otherwise.
Params
fn
{Function}returns
{Boolean}
Example
var isBoundFunction = { return thisfoo || 'abc' } console // => falseconsole // => true
Notice that if you consider using bind-context library it will be different case.
It tries to solve exactly this problem and actually do it well for now.
var bind = var isBound = { return thisbaz } console // => falseconsole // => trueconsole // => false var nativeBound = foobarvar customBound = console // => function () { [native code] }console // => function foobar () { return this.baz }
So yea, that's the awesome point of this lib! 😋
Related
You might also be interested in these packages:
- bind-context: Bind context to a function and preserves her name. Can be used… more | homepage
- function-arguments: Get arguments of a function, useful for and used in dependency injectors.… more | homepage
- is-async-function: Is function really asynchronous function? Trying to guess that based on check… more | homepage
- is-callback-function: Returns true if function is a callback. Checks its name is one… more | homepage
- parse-arguments: Parse function to object with same key names as arguments names and… more | homepage
- parse-function: Parse a function, arrow function or string to object with name, args,… 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.