Skip to content

Commit

Permalink
Underscore.js 1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Dec 1, 2010
1 parent 2d06e1d commit c714175
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 153 deletions.
8 changes: 4 additions & 4 deletions docs/docco.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ p {
margin: 0 0 15px 0;
}
h1, h2, h3, h4, h5, h6 {
margin: 40px 0 15px 0;
margin: 0px 0 15px 0;
}
h3, h4, h5, h6 {
margin-top: 20px;
h1 {
margin-top: 40px;
}
#container {
position: relative;
}
#background {
position: fixed;
top: 0; left: 575px; right: 0; bottom: 0;
top: 0; left: 525px; right: 0; bottom: 0;
background: #f5f5ff;
border-left: 1px solid #e5e5ee;
z-index: -1;
Expand Down
243 changes: 136 additions & 107 deletions docs/underscore.html

Large diffs are not rendered by default.

74 changes: 50 additions & 24 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ <h1>Underscore.js</h1>
The project is
<a href="http://github.com/documentcloud/underscore/">hosted on GitHub</a>.
You can report bugs and discuss features on the
<a href="http://github.com/documentcloud/jammit/issues">issues page</a>,
<a href="http://github.com/documentcloud/underscore/issues">issues page</a>,
on Freenode in the <tt>#documentcloud</tt> channel,
or send tweets to <a href="http://twitter.com/documentcloud">@documentcloud</a>.
</p>
Expand All @@ -118,11 +118,11 @@ <h2>Downloads <i style="padding-left: 12px; font-size:12px;">(Right-click, and u

<table>
<tr>
<td><a href="underscore.js">Development Version (1.1.2)</a></td>
<td><i>25kb, Uncompressed with Comments</i></td>
<td><a href="underscore.js">Development Version (1.1.3)</a></td>
<td><i>26kb, Uncompressed with Comments</i></td>
</tr>
<tr>
<td><a href="underscore-min.js">Production Version (1.1.2)</a></td>
<td><a href="underscore-min.js">Production Version (1.1.3)</a></td>
<td><i>3kb, Packed and Gzipped</i></td>
</tr>
</table>
Expand Down Expand Up @@ -159,6 +159,7 @@ <h2>Table of Contents</h2>
<br />
<span class="methods"><a href="#bind">bind</a>, <a href="#bindAll">bindAll</a>,
<a href="#memoize">memoize</a>, <a href="#delay">delay</a>, <a href="#defer">defer</a>,
<a href="#throttle">throttle</a>, <a href="#debounce">debounce</a>,
<a href="#wrap">wrap</a>, <a href="#compose">compose</a></span>
</p>

Expand All @@ -180,8 +181,8 @@ <h2>Table of Contents</h2>
<br />
<span class="methods"><a href="#noConflict">noConflict</a>,
<a href="#identity">identity</a>, <a href="#times">times</a>,
<a href="#breakLoop">breakLoop</a>, <a href="#mixin">mixin</a>,
<a href="#uniqueId">uniqueId</a>, <a href="#template">template</a></span>
<a href="#mixin">mixin</a>, <a href="#uniqueId">uniqueId</a>,
<a href="#template">template</a></span>
</p>

<p>
Expand Down Expand Up @@ -249,8 +250,7 @@ <h2>Collection Functions (Arrays or Objects)</h2>
function. The <b>iterator</b> is bound to the <b>context</b> object, if one is
passed. Each invocation of <b>iterator</b> is called with three arguments:
<tt>(element, index, list)</tt>. If <b>list</b> is a JavaScript object, <b>iterator</b>'s
arguments will be <tt>(value, key, list)</tt>. Use <a href="#breakLoop"><tt>breakLoop</tt></a>
to break out of the iteration. Delegates to the native
arguments will be <tt>(value, key, list)</tt>. Delegates to the native
<b>forEach</b> function if it exists.
</p>
<pre>
Expand Down Expand Up @@ -707,6 +707,33 @@ <h2>Function (uh, ahem) Functions</h2>
<pre>
_.defer(function(){ alert('deferred'); });
// Returns from the function before the alert runs.
</pre>

<p id="throttle">
<b class="header">throttle</b><code>_.throttle(function, wait)</code>
<br />
Returns a throttled version of the function, that, when invoked repeatedly,
will only actually call the wrapped function at most once per every <b>wait</b>
milliseconds. Useful for rate-limiting events that occur faster than you
can keep up with.
</p>
<pre>
var throttled = _.throttle(updatePosition, 100);
$(window).scroll(throttled);
</pre>

<p id="debounce">
<b class="header">debounce</b><code>_.debounce(function, wait)</code>
<br />
Repeated calls to a debounced function will postpone it's execution
until after <b>wait</b> milliseconds have elapsed. Useful for implementing
behavior that should only happen <i>after</i> the input has stopped arriving.
For example: rendering a preview of a Markdown comment, recalculating a
layout after the window has stopped being resized...
</p>
<pre>
var lazyLayout _.debounce(calculateLayout, 300);
$(window).resize(lazyLayout);
</pre>

<p id="wrap">
Expand Down Expand Up @@ -1006,22 +1033,6 @@ <h2>Utility Functions</h2>
<pre>
_(3).times(function(){ genie.grantWish(); });</pre>

<p id="breakLoop">
<b class="header">breakLoop</b><code>_.breakLoop()</code>
<br />
Breaks out of the current loop iteration. Similar to the <tt>break</tt>
keyword in regular "for" loop, but works within an iterator function.
Uses the native <tt>StopIteration</tt> object in JavaScript 1.7 compliant
browsers.
</p>
<pre>
var result = null;
_.each([1, 2, 3], function(num) {
if ((result = num) == 2) _.breakLoop();
});
result;
=&gt; 2</pre>

<p id="mixin">
<b class="header">mixin</b><code>_.mixin(object)</code>
<br />
Expand Down Expand Up @@ -1170,6 +1181,21 @@ <h2>Links &amp; Suggested Reading</h2>

<h2>Change Log</h2>

<p>
<b class="header">1.1.3</b> &mdash; <small><i>Dec 1, 2010</i></small><br />
In CommonJS, Underscore may now be required with just: <br />
<tt>var _ = require("underscore")</tt>.
Added <tt>_.throttle</tt> and <tt>_.debounce</tt> functions.
Removed <tt>_.breakLoop</tt>, in favor of an ECMA5-style un-<i>break</i>-able
each implementation &mdash; this removes the try/catch, and you'll now have
better stack traces for exceptions that are thrown within an Underscore iterator.
Improved the <b>isType</b> family of functions for better interoperability
with Internet Explorer host objects.
<tt>_.template</tt> now correctly escapes backslashes in templates.
Improved <tt>_.reduce</tt> compatibility with the ECMA5 version:
if you don't pass an initial value, the first item in the collection is used.
</p>

<p>
<b class="header">1.1.2</b><br />
Fixed <tt>_.contains</tt>, which was mistakenly pointing at
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"dependencies" : [],
"lib" : ".",
"main" : "underscore.js",
"version" : "1.1.2"
"version" : "1.1.3"
}
Loading

0 comments on commit c714175

Please sign in to comment.