News for hackers. Stuff that matters.
Re:Lodash's Chain vs. Native Methods by darepublic on Friday August 27, 2021 @09:59AM (#28327875)
I don't see how lodash could possibly filter a list of 30 by a criteria without visiting each item at least once to take a look at it. the only way to make it more efficient would be to have lodash collect the desired transformations (filter/map) and then run a single loop over the items, mapping only those items that meet the filter criteria. But that is not much more efficient than the [].filter().map() that you could do with native methods.
Re:Lodash's Chain vs. Native Methods by dsego on Friday August 27, 2021 @06:17PM (#28333556)
It doesn't have to visit all 30 items, just enough items to take 5 from, could be 8, could be 10 etc. The lazy approach _is_ to collect all transformations and apply them in the end.
Re:Lodash's Chain vs. Native Methods by darepublic on Saturday August 28, 2021 @10:56AM (#28338556)
ah, yeah you are right.