I'm looking for a vanilla JavaScript solution.
Say I've got a function with the following header:
generateEmail(firstName, lastname, provider)
I need to run it like this:
generateEmail("John","Smith","gmail.com");
I would like to be able to call it with argument map instead of positional arguments, i.e.
generateEmail({
"firstName":"John",
"lastname": "Smith",
"provider": "gmail.com"
});
And I'm looking for an already-written solution to do this in JavaScript, since I've got an unlimited number of functions such as generateEmail above to handle. Does such library exist?
I have seen https://github.com/kilianc/node-introspect which handles function introspection (returning function abstract parameter information). But the second part is missing - mapping map-call into positional-call.
Please tell me, whether such thing exists.
edit: if I didn't make myself clear: I don't want to modify the original positional-argument function. I get such functions from an external provider which may update his code. I'd rather prefer to have a wrapper that could call the original function beneath, and provide a map-argument API outside.