So I'm creating some functions dynamically based on some input from the users. One input is the name of each function. I would like to be able to create (and expose) some functions with the same name but different parameters.
const input = [
{name: 'mul', paramTypes: { par1: 'number', par2: 'number'},
{name: 'add', paramTypes: { par1: 'number', par2: 'number'},
{name: 'add', paramTypes: { par1: 'string', par2: 'string'}
];
let functionsToExpose = [];
for (fun in input){
functionsToExpose[fun.name] = (...arguments)=>{...}
}
return functionsToExpose;
I would like to create two add functions, one for numbers and one for strings (concatenation). Currently, only one is created. Is there a way I could create and expose both?
funloop var gets keys"0","1", and"2";functionsToExposeis apparently an array; the conceptual issue for how someone could ask for a function implementation merely by name and parameter types is overlooked completely; etc. Without a toy example that at least begins to work I don't know how to advise, or at least I can't test it against any use case. If you edit to include a minimal reproducible example and want me to take another look, pls mention @jcalz in your reply.