I want to create a higher-level function that returns functions in order to be serialized and sent to another machine.
For example I want to create a function that returns Hello world, by passing world to a generator function and afterwards serialize by toString:
function returnAnotherFunction(name) {
return () => { return `Hello ${name}`}
}
const helloWorldFunction = returnAnotherFunction('world')
const serializedFunction = helloWorldFunction.toString()
console.log(serializedFunction)
// prints: () => { return `Hello ${name}`}
// I want: () => { return `Hello world`}
Instead, the returned serialized function does still rely on the variable. I need to serialize the function, so I need it without the variable. I am having problems finding the right keywords for a search and am happy with any help!