|
Portions of Underscore are inspired by or borrowed from Oliver Steele's Functional, Prototype.js and John Resig's Micro-Templating.
Functional programming support is added, but without extending any of the built-in JavaScript objects.
Underscore provides 60-odd functions that support both the usual functional suspects: map, select, invoke — as well as more specialized helpers: function binding, javascript templating, deep equality testing, and so on. It delegates to built-in functions, if present, so modern browsers will use the native implementations of forEach, map, reduce, filter, every, some and indexOf.
What's New in This Release: [ read full changelog ]
· Added a pairs function, for turning a JavaScript object into [key, value] pairs ... as well as an object function, for converting an array of [key, value] pairs into an object.
· Added a countBy function, for counting the number of objects in a list that match a certain criteria.
· Added an invert function, for performing a simple inversion of the keys and values in an object.
· Added a where function, for easy cases of filtering a list for objects with specific values.
· Added an omit function, for filtering an object to remove certain keys.
· Added a random function, to return a random number in a given range.
· _.debounce'd functions now return their last updated value, just like _.throttle'd functions do.
· The sortBy function now runs a stable sort algorithm.
· Added the optional fromIndex option to indexOf and lastIndexOf.
· "Sparse" arrays are no longer supported in Underscore iteration functions. Use a for instead (or better yet, an object).
· The min and max functions may now be called on very large arrays.
· Interpolation in templates now represents null and undefined as the empty string.
Via: Underscore.js 1.4.0
0 Comment:
Post a Comment