run-function
v0.1.3
Published
Run a function if it exists.
Maintainers
Readme
run-function
Run a function if it exists.
Install
$ npm install run-functionUsage
const runFn = require('run-function');
function fn() {
// do something
}
runFn(fn);API
runFn(fn, ...args)
- when
fnisundefined/null, do nothing; - when
fnis function, runfnwith argumentsargs; - when
fnis notundefined/null/ function, throw an error;
