Monday, December 7th, 2009p>We posted on the underscore.js initial announcement and we liked what we saw.
Jeremy Ashkenas of underscore.js pinged us to let us know that it is chuggin’ along and the library is now up to 0.5 and has had changes such as:
- OOP-style wrapping:
_([1, 2, 3, 4, 5]).each( ... );
- OOP wrapping allows you to chain together computations:
_([1, 2, 3, 4, 5]).chain().map( ... ).flatten().reduce( ... ).value();
- Added speed comparisons with jQuery to the test page. Because Underscore delegates to the native implementations whenever available, its “each” function is over 5 times faster than jQuery.each in Safari, and over 3.5 times faster in Firefox. Your mileage may vary, so you can use the test page to check it in your browser of choice.
- Added reduceRight / foldr, to go along with reduce / foldl.
- Added first / head, and rest / tail for car and cdr enthusiasts. It turns out that they’re immensely useful on JS arguments objects.
- Added a “range” function, identical to Python’s range(), for easy array initialization.
- A slew of other minor improvements, to get Underscore working out-of-the-box on Rhino, to use the native StopIteration object to break out of loops where available, and so on.
The latest Underscore.js 0.5.0 includes a couple of API cleanups, a couple of speedups, and a more comprehensive isEqual() function, with Date, NaN, and RegExp support.
Marcus Irven has ported the commonly-applicable Underscore functions to Lua, and released an Underscore.lua library this weekend.