Jeremy Ashkenas and the DocumentCloud team have just released Underscore.js a small library that provides all the functional programming helpers that you expect from Prototype.js or Ruby, but without extending any core JavaScript objects.
Jeremy told us:
This makes it a natural fit alongside jQuery, without having to worry about the conflicts and redundant functionality that using Prototype and jQuery together would entail. For browsers that support the new Javascript 1.6 array functions, it delegates to the native implementations, so your “_.map()” can run at full speed, where available. It’s a tiny download, 4k when gzipped. Here’s the project page, with full documentation, live tests and benchmarks.
Some of the utilities:
Collections
each, map,
reduce, detect, select, reject, all,
any, include, invoke, pluck, max,
min, sortBy, sortedIndex, toArray,
size
Arrays
first, last,
compact, flatten, without, uniq,
intersect, zip, indexOf,
lastIndexOf
Functions
bind, bindAll, delay,
defer, wrap, compose
Objects
keys, values,
extend, clone, isEqual, isElement,
isArray, isFunction, isUndefined
Utility
noConflict,
uniqueId, template
There has already been nice community patches and suggestions from the community, and Kris Kowal helped make it CommonJS-compliant.
Obviously, other libraries have covered a lot of these before, but it is nice to see a small core covering.
Popularity: 1% [?]