For example. I have this code:
export const mergeWrapper = function(aFunction, meta) {
return aFunction;
};
function exampleFunction(temp) {
console.log(temp);
// can print here. without changing exampleFunction method signature.
// in this case should be 'stackoverflow'
console.log(meta);
}
mergeWrapper(exampleFunction, 'stackoverflow')('hello');
I want to do "something" in mergeWrapper
. so that, inside aFunction, I can call meta
. I have tried something such as:
export const mergeWrapper = function(aFunction, meta) {
aFunction.bind(this);
return aFunction;
};
But it doesn't work. How can I do this.
My idea because I can write some sort of this function using currying. for example:
export const wrapperFunction = function(meta) {
return function(temp) {
console.log(temp);
console.log(meta);
}
}
wrapperFunction('StackOverFlow')('hello');
But written like this will make me write wrapper for all functions. So I want to write a helper.
Thanks