[英]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.