5 ms·
When would you really need this complex library over the native methods supported by Array? I know there are overhead to convert map and set into array but it
by aabbcc1241 7y ago
When would you really need this complex library over the native methods supported by Array?
I know there are overhead to convert map and set into array but it should be fine for non huge data set.
- oaiey 7y agoInteresting question. I share this train of thought. When I restarted writing JavaScript (thank god with TypeScript ;)) and I realized filter/map/reduce array methods, my fear of lacking LINQ vanished away. Reduce is painful in the beginning (because it is different to SQL's GroupBy) but it is a foundation for so much more (once you REALLY understand it). Some more helpers are useful (first, last, max, take, skip ... all with variation). They should added to the core language.
- jolux 7y agoLinq has Reduce as well, known as Aggregate (foldr/foldl in most functional languages).
- jermaustin1 7y agoI wrote as a fun little learning experiment linq.js[1], which is 90% renamed wrappers for the array prototype methods, then some logic thrown in for things like any, all, first/single[OrDefault], and orderBy. It is just under 90 lines of code. 1: https://github.com/jeremyaboyd/linq.js https://github.com/jeremyaboyd/linq.js
- aabbcc1241 7y agoAs learning experiment, you may try to add .d.ts or rewrite in Typescript ;)