在基于webpack的项目中使用lodash的最有效方法是什么?

时间:2017-01-25 20:30:32

标签: javascript functional-programming lodash

我尝试使用lodash fp添加lodash,但我无法理解它。我认为这是优化lodash的最佳方式。在我的aurelia项目中,我有

 import lofind from 'lodash/fp/find';

然后在我的代码中我尝试使用它

this.activeTrek = lofind(this.treks._embedded.get_user_treks, { 'default_trip': '1'});

这似乎根本不起作用。我是否缺少一些步骤或在FP中加载的正确方法?我的查找语法是错误还是什么?

1 个答案:

答案 0 :(得分:1)

FP lodash中的find函数与正常lodash.find的参数不同。也就是说,它是curried并且首先采用迭代,数据最后。他们的FP指南(docs here)列出了以“capped iteratee arguments”方式改变的函数。

this.activeTrek = lofind({ default_trip: '1' })(this.treks._embedded.get_user_treks);