mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Underscore.js 1.2.1
This commit is contained in:
72
index.html
72
index.html
@@ -126,11 +126,11 @@
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><a href="underscore.js">Development Version (1.2.0)</a></td>
|
||||
<td><i>32kb, Uncompressed with Comments</i></td>
|
||||
<td><a href="underscore.js">Development Version (1.2.1)</a></td>
|
||||
<td><i>33kb, Uncompressed with Comments</i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="underscore-min.js">Production Version (1.2.0)</a></td>
|
||||
<td><a href="underscore-min.js">Production Version (1.2.1)</a></td>
|
||||
<td><i>< 4kb, Minified and Gzipped</i></td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -454,11 +454,16 @@ _.sortBy([1, 2, 3, 4, 5, 6], function(num){ return Math.sin(num); });
|
||||
<b class="header">groupBy</b><code>_.groupBy(list, iterator)</code>
|
||||
<br />
|
||||
Splits a collection into sets, grouped by the result of running each
|
||||
value through <b>iterator</b>.
|
||||
value through <b>iterator</b>. If <b>iterator</b> is a string instead of
|
||||
a function, groups by the property named by <b>iterator</b> on each of
|
||||
the values.
|
||||
</p>
|
||||
<pre>
|
||||
_.groupBy([1.3, 2.1, 2.4], function(num){ return Math.floor(num); });
|
||||
=> {1: [1.3], 2: [2.1, 2.4]}
|
||||
|
||||
_.groupBy(['one', 'two', 'three'], 'length');
|
||||
=> {3: ["one", "two"], 5: ["three"]}
|
||||
</pre>
|
||||
|
||||
<p id="sortedIndex">
|
||||
@@ -1265,26 +1270,6 @@ _([1, 2, 3]).value();
|
||||
=> [1, 2, 3]
|
||||
</pre>
|
||||
|
||||
<h2 id="duck_typing">Duck Typing</h2>
|
||||
|
||||
<p>
|
||||
The <b>isType</b> (<tt>isArray</tt>, <tt>isFunction</tt>, <tt>isString</tt> ...) family of type-checking
|
||||
functions use property detection to do their work, which, although
|
||||
orders of magnitude faster than the alternative, isn't entirely safe when dealing
|
||||
with objects that are used as hashes, where arbitrary strings are being
|
||||
set for the keys. It's entirely possible for an object to masquerade as
|
||||
another type, if you're setting properties with names like "concat" and
|
||||
"charCodeAt". So be aware.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
In a similar fashion, <tt>_.each</tt> and all of the other functions
|
||||
based on it are designed to be able to iterate over any Array-like
|
||||
JavaScript object, including <tt>arguments</tt>, NodeLists, and more.
|
||||
Passing hash-like objects with a numeric <tt>length</tt> key won't work.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>Links & Suggested Reading</h2>
|
||||
|
||||
<p>
|
||||
@@ -1343,6 +1328,45 @@ _([1, 2, 3]).value();
|
||||
|
||||
<h2 id="changelog">Change Log</h2>
|
||||
|
||||
<p>
|
||||
<b class="header">1.2.1</b> — <small><i>Oct. 24, 2011</i></small><br />
|
||||
<ul>
|
||||
<li>
|
||||
Several important bug fixes for <tt>_.isEqual</tt>, which should now
|
||||
do better on mutated Arrays, and on non-Array objects with
|
||||
<tt>length</tt> properties. <small>(#329)</small>
|
||||
</li>
|
||||
<li>
|
||||
<b>jrburke</b> contributed Underscore exporting for AMD module loaders,
|
||||
and <b>tonylukasavage</b> for Appcelerator Titanium.
|
||||
<small>(#335, #338)</small>
|
||||
</li>
|
||||
<li>
|
||||
You can now <tt>_.groupBy(list, 'property')</tt> as a shortcut for
|
||||
grouping values by a particular common property.
|
||||
</li>
|
||||
<li>
|
||||
<tt>_.throttle</tt>'d functions now fire immediately upon invocation,
|
||||
and are rate-limited thereafter <small>(#170, #266)</small>.
|
||||
</li>
|
||||
<li>
|
||||
Most of the <tt>_.is[Type]</tt> checks no longer ducktype.
|
||||
</li>
|
||||
<li>
|
||||
The <tt>_.bind</tt> function now also works on constructors, a-la
|
||||
ES5 ... but you would never want to use <tt>_.bind</tt> on a
|
||||
constructor function.
|
||||
</li>
|
||||
<li>
|
||||
<tt>_.clone</tt> no longer wraps non-object types in Objects.
|
||||
</li>
|
||||
<li>
|
||||
<tt>_.find</tt> and <tt>_.filter</tt> are now the preferred names for
|
||||
<tt>_.detect</tt> and <tt>_.select</tt>.
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b class="header">1.2.0</b> — <small><i>Oct. 5, 2011</i></small><br />
|
||||
<ul>
|
||||
|
||||
Reference in New Issue
Block a user