run-function
v0.1.3
Published
Run a function if it exists.
Downloads
5
Maintainers
Readme
run-function
Run a function if it exists.
Install
$ npm install run-function
Usage
const runFn = require('run-function');
function fn() {
// do something
}
runFn(fn);
API
runFn(fn, ...args)
- when
fn
isundefined
/null
, do nothing; - when
fn
is function, runfn
with argumentsargs
; - when
fn
is notundefined
/null
/ function, throw an error;