itemsapi/itemsjs

Prefilter is confusing

domoritz opened this issue · 2 comments

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.prefilter is 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;
  });
}

@domoritz good point. The part of prefilter in docs was quite confusing..

Answering questions:

  1. The prefilter function 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. The prefilter doesn't sound intuitively but no idea how to name it better.. I've added also now filter function which is just responsible for filtering items the same way like in lodash or in native js Array.prototype.filter(). There is a chance filter will cover most custom cases and prefilter could be deleted in the future.
  2. 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.
  3. The same as above

Thank you so much for the prompt and comprehensive response. I am going to close this issue as solved.