Getting the scope right for your callback function may be tricky depending on what your function does. Below are a few exmaples of how to wrap your function.
Pure function
In this example our function pureFunction does not call this and doesn’t interact with any external functions. We can pass the function without calling it as the callback value, and pass an array of arguments to callbackArgs.
import test from"ava";
import { timeExecution } from"wedgetail";
functionpureFunction(x, y){ return x * y * x * y; }
In this example, the method ConfigClass#getConfig calls this.config. We can use a closure on the callback to ensure the scope of this stays with the config.