Prefilter is confusing
domoritz opened this issue · 2 comments
domoritz commented
I'm very confused by the prefiltering method and would appreciate your help and some improvements to the docs.
- The grammar is odd. What does it mean to make something prefiltering?
- The function is not valid js.
itemsjs.prefilteris also not defined
It is making items prefiltering before search or aggregation, i.e.:
itemsjs.prefilter(items) {
return items.filter(item => {
return item.price > 100;
});
}
cigolpl commented
@domoritz good point. The part of prefilter in docs was quite confusing..
Answering questions:
- The
prefilterfunction gives you an access to indexed items so you can narrow it down in the custom way i.e. by using js filter or slice function. Theprefilterdoesn't sound intuitively but no idea how to name it better.. I've added also nowfilterfunction which is just responsible for filtering items the same way like in lodash or in native js Array.prototype.filter(). There is a chancefilterwill cover most custom cases andprefiltercould be deleted in the future. - It's not valid function because it's not part of of ItemsJS API. It's a function argument in itemsjs.search function. The docs was incorrect about that and thanks for pointing that out! I've fixed that.
- The same as above
domoritz commented
Thank you so much for the prompt and comprehensive response. I am going to close this issue as solved.