function-apply
Allows to apply functions to hash-maps of arguments
Features
- Binds argument object keys to function argument names
- Works with objects and arrays
Motivation
HTTP requests, configuration objects, settings for JavaScript apps come in form of JSON objects. Yet, we usually prefer to write our functions in classical manner: listing and naming all the required parameters. Mapping incoming objects to function parameters might become repetitive and make the code harder to read. Especially, when dealing with higher-order functions that don't necessarily know their products' arguments.
One more thing: naming arguments in function calls can sometimes make them easier to understand:
var result =
Installation
npm install function-apply
Usage
var apply = ; // Argument name bindingvar multiply = ; var result = // Object applicationvar config = url: 'http://my.url' method: 'get' url: 'http://my.url' method: 'get'; { ......} var routes = config;