Comment by jansommer

Comment by jansommer 4 days ago

16 replies

Wouldn't the query for your example just be

data.filter(d => d.friends.includes("John")).map(d => ({name: d.name+" "+d.lastName}))

Maybe I'm missing the bigger picture, but that doesn't seem so bad

allannienhuis 4 days ago

one of the cases something like this is useful for is when you have user configured saved 'filters' - you can simply pass the stored object into the where clause. I agree if you're doing hard-coded queries on arrays of objects, this may not add a lot. That said, a consistent syntax for doing searches and mapping is useful - projects like lodash have that as part of their api too.

meiraleal 4 days ago

I liked JAQT API but it is not really good to create a layer on top of already simple functional constructors.

  • austin-cheney 4 days ago

    Why is that not good? JavaScript is full of layers of unnecessary abstraction often for completely superficial reasons and sometimes even irrationally applied at great cost in defiance of evidence and simplicity. So, what makes this specific example less good than all the other countless examples of abstractions most JavaScript developers would happily die to defend?

    • meiraleal 4 days ago

      because in the past it didn't have those functional constructors so things like underscore or lodash would be needed but adding a layer as you mentioned. It is not good, for me, to add a dependency for this again. But in the end I have in my utils file a few functions that basically do what JAQT does and I might copy a few more.

Poefke 3 days ago

Author here, if you are comfortable with filter/map/reduce, than JAQT doesn't provide much benefits, I agree. My target audience is developers who aren't that used to that. I've had much more success with junior developers using JAQT, then trying to get them to use map/reduce.