converge
-> modArgs
and useWith
-> modPerArg
createModArgs
resolver
arg, index, arguments
(like value, index, array)
useWith
the resolver would be identity
and for converge
it would be function(value, index, args) { return args }
baseModArgs(func, transforms, resolver)
['FY', 'Q3', 'Q2'] => {'FY': [ some filtered stuff here], 'Q3': [ 'some other stuff' ], 'Q2': [ ]}
Use case is when getting some stuff from SQL and transforming into more json like structure
converge
as a name. I do think useWith
would have to be renamed as it can mean anything. How about converge
("To come together from different directions") and disperse
("To strew or distribute widely")? The two words are related because they're kind of opposite, but they also both say something about what happens to the arguments. Besides, I think the subtle differences between the two are too great to name them after the same thing. I'm specifically talking about how the arity for the returned functions is chosen. For converge
it will be the biggest arity of all given transformers, and for useWith
it will be equal to the amount of given transformers.
// input
var input = {
apple: 3,
cucumber: 1
};
// desired output
[{
name: 'apple',
quantity: 3
}, {
name: 'cucumber',
quantity: 1
}];
function transformData(content) {
return reduce(function(output, key) {
output.push({
name: key,
quantity: content[key]
});
return output;
}, [], Object.keys(content));
}
var transformData = R.pipe(R.toPairs, R.map(R.zipObj(["name", "quantity"])))
- http://bit.ly/1QfI7WH
disperse
, the more I like it! Converge "converges" the arguments with every given transformer, and disperse "disperses" the arguments across all given transformers! :D .. Maybe I'm falling in love, and I should kill my darlings and such.. It's a good name right? :worried:
converge
and useWith
necessarily disperse first, converge
dispersing the entirety of arguments
to all transformers and useWith
dispersing individual arguments to individual transformers. So it's a little unclear from that perspective, I think. It's still better than useWith
to describe the behaviour at least.
useWith
's new name would be helpful, considering "spread" is used with similar meaning by Q (and other promise libraries?).