by wingspan · 14y ago · 0 comments
from([1,2,3]).select(n => n * n).where(n >=2).toArray()
which outputs [4, 9]
Hoping to open source it soon.Edit: typo, n * 2 should have been n * n, sorry for the confusion
_.chain([1,2,3]).map(n => n * n).filter(n => n >= 2).value()It should be pretty straightforward to provide Underscore bindings for TypeScript.
One big difference in the library I was working on is that it is lazy, and modeled after .NETs IEnumerable. Whether this is a good thing or not, I'm not yet sure.
The problem i had was that the native array methods are rather fast while function calls (for moveNext) are quite slow, so i couldn't get a whole lot of speed out of it.
Newer javascript engines might be sufficient to offset that though.