![](/img/trans.png)
[英]Where can I find an explanation/summary of symbols used to explain functional programming, specifically Ramda.js?
[英]How can I make this code more 'functional programming' style in Ramda.js / lodash
我有这段代码:
var fn = function(fn, name) {
this.commands.add(name, fn);
}.bind(this);
_.mapObjIndexed(fn, this.commandList);
我觉得有一种方法可以改进这段代码,使其仅一行。 我尝试了许多不同的方法,但是我对ramda.js
,我可能会缺少一些功能,这会使此操作变得更加容易和简单。
_.mapObjIndexed(_.flip(this.commands.add), this.commandList);
如果需要add
函数的.bind(this.commands)
,则可以使用_.bindKey (this.commands, "add")
来缩短它。
如果由于参数数量而导致翻转无法正常进行,则可能不需要输入_.ary(…, 2)
或_.binary(…)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.