With this feature developers get a new helper/factory method which can be used for passing JS modules and functions to AskScript without the need of manually warping them with resources.
Usage:
import { factory } from 'askql/askvm/factory';
const moduleToBeWrapped = {
wrapMe1: () => {
return 100;
},
wrapMe2: (arg: string) => {
return arg;
},
dontWrapMe: () => {
return 0;
},
};
function ask(code: string) {
return runUntyped(
{
resources: { ...factory(moduleToBeWrapped, ['wrapMe1', 'wrapMe2'])},
values,
},
parse(code)
);
}
// now you can call the function `wrapMe1` of `moduleToBeWrapped` in AskScript
ask(`ask(call(get('wrapMe1')))
You can easily wrap a whole module like lodash by just simply:
With this feature developers get a new helper/factory method which can be used for passing JS modules and functions to AskScript without the need of manually warping them with resources.
Usage:
You can easily wrap a whole module like
lodash
by just simply: