callIfExists
Executes the given callback function, if present.
API
function callIfExists<T extends (...args: unknown[]) => ReturnType<T>>(
callback: T | undefined | null,
...args: Parameters<T>
): ReturnType<T> | undefined
Usage
import { callIfExists } from '@feedzai/js-utilities';
// Calling a function with several arguments
callIfExists(functionName, arg1, arg2);
// Calling a function without any argument
callIfExists(functionName);