When making something that can take a CallBack, you can use ifrun to only run if defined.
the entirety of ifrun is 70 characters
- Runs a function with args if it is not null
There are 2 ways to use if run Option 1 using the npm package and Option 2 without it
install
$ npm i ifrun
import
const ifRun = require("ifRun");
define
const ifRun = (func, args)=>{if(!func) return; func(args)};
function test(hello){
console.log(hello);
}
ifRun(test,"sup");
- Arnar Freyr Ástvaldsson
This project is licensed under the MIT License