Skip to content

Commit 9437f67

Browse files
committed
Merge pull request #1799 from akre54/release-170
Release Underscore 1.7.0
2 parents 15a757d + 1ad2985 commit 9437f67

8 files changed

+1065
-887
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "underscore",
3-
"version": "1.6.0",
3+
"version": "1.7.0",
44
"main": "underscore.js",
55
"keywords": ["util", "functional", "server", "client", "browser"],
66
"ignore" : ["docs", "test", "*.yml", "CNAME", "index.html", "favicon.ico", "CONTRIBUTING.md"]

component.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"repo" : "jashkenas/underscore",
66
"main" : "underscore.js",
77
"scripts" : ["underscore.js"],
8-
"version" : "1.6.0",
8+
"version" : "1.7.0",
99
"license" : "MIT"
1010
}

docs/underscore.html

+955-858
Large diffs are not rendered by default.

index.html

+101-21
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
<div id="sidebar" class="interface">
181181

182182
<a class="toc_title" href="#">
183-
Underscore.js <span class="version">(1.6.0)</span>
183+
Underscore.js <span class="version">(1.7.0)</span>
184184
</a>
185185
<ul class="toc_section">
186186
<li>&raquo; <a href="https://github.com/jashkenas/underscore">GitHub Repository</a></li>
@@ -311,6 +311,7 @@
311311
<li>- <a href="#times">times</a></li>
312312
<li>- <a href="#random">random</a></li>
313313
<li>- <a href="#mixin">mixin</a></li>
314+
<li>- <a href="#iteratee">iteratee</a></li>
314315
<li>- <a href="#uniqueId">uniqueId</a></li>
315316
<li>- <a href="#escape">escape</a></li>
316317
<li>- <a href="#unescape">unescape</a></li>
@@ -355,7 +356,7 @@
355356
</p>
356357

357358
<p>
358-
Underscore provides 80-odd functions that support both the usual
359+
Underscore provides 115-odd functions that support both the usual
359360
functional suspects: <b>map</b>, <b>filter</b>, <b>invoke</b> &mdash;
360361
as well as more specialized helpers: function binding, javascript
361362
templating, deep equality testing, and so on.
@@ -391,11 +392,11 @@ <h2>Downloads <i style="padding-left: 12px; font-size:12px;">(Right-click, and u
391392

392393
<table>
393394
<tr>
394-
<td><a href="underscore.js">Development Version (1.6.0)</a></td>
395+
<td><a href="underscore.js">Development Version (1.7.0)</a></td>
395396
<td><i>44kb, Uncompressed with Plentiful Comments</i></td>
396397
</tr>
397398
<tr>
398-
<td><a href="underscore-min.js">Production Version (1.6.0)</a></td>
399+
<td><a href="underscore-min.js">Production Version (1.7.0)</a></td>
399400
<td>
400401
<i>5.0kb, Minified and Gzipped</i>
401402
&nbsp;<small>(<a href="underscore-min.map">Source Map</a>)</small>
@@ -477,15 +478,15 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
477478
<b class="header">reduce</b><code>_.reduce(list, iteratee, [memo], [context])</code>
478479
<span class="alias">Aliases: <b>inject, foldl</b></span>
479480
<br />
480-
Also known as <b>inject</b> and <b>foldl</b>, reduce boils down a <b>list</b> of values into a single value.
481-
<b>Memo</b> is the initial state of the reduction, and each successive step of it should be returned by
482-
<b>iteratee</b>. The iteratee is passed four arguments: the <tt>memo</tt>, then the <tt>value</tt> and
483-
<tt>index</tt> (or key) of the iteration, and finally a reference to the entire <tt>list</tt>.
481+
Also known as <b>inject</b> and <b>foldl</b>, reduce boils down a <b>list</b> of values into a single value.
482+
<b>Memo</b> is the initial state of the reduction, and each successive step of it should be returned by
483+
<b>iteratee</b>. The iteratee is passed four arguments: the <tt>memo</tt>, then the <tt>value</tt> and
484+
<tt>index</tt> (or key) of the iteration, and finally a reference to the entire <tt>list</tt>.
484485
</p>
485486
<p>
486-
If no memo is passed to the initial invocation of reduce, the iteratee is not invoked on the first element
487-
of the list. The first element is instead passed as the memo in the invocation of the iteratee on the next
488-
element in the list.
487+
If no memo is passed to the initial invocation of reduce, the iteratee is not invoked on the first element
488+
of the list. The first element is instead passed as the memo in the invocation of the iteratee on the next
489+
element in the list.
489490
</p>
490491
<pre>
491492
var sum = _.reduce([1, 2, 3], function(memo, num){ return memo + num; }, 0);
@@ -1202,6 +1203,21 @@ <h2 id="functions">Function (uh, ahem) Functions</h2>
12021203
note.asyncSave({success: renderNotes});
12031204
});
12041205
// renderNotes is run once, after all notes have saved.
1206+
</pre>
1207+
1208+
<p id="before">
1209+
<b class="header">before</b><code>_.before(count, function)</code>
1210+
<br />
1211+
Creates a version of the function that can be called no more than
1212+
<b>count</b> times. The result of the last function call is memoized and
1213+
returned when <b>count</b> has been reached.
1214+
</p>
1215+
<pre>
1216+
var monthlyMeeting = _.before(3, askForRaise);
1217+
monthlyMeeting();
1218+
monthlyMeeting();
1219+
monthlyMeeting();
1220+
// the result of any subsequent calls is the same as the second call
12051221
</pre>
12061222

12071223
<p id="wrap">
@@ -1689,6 +1705,19 @@ <h2 id="utility">Utility Functions</h2>
16891705
});
16901706
_("fabio").capitalize();
16911707
=&gt; "Fabio"
1708+
</pre>
1709+
1710+
<p id="iteratee">
1711+
<b class="header">iteratee</b><code>_.iteratee(value, [context], [argCount])</code>
1712+
<br />
1713+
A mostly-internal function to generate callbacks that can be applied
1714+
to each element in a collection, returning the desired result — either
1715+
identity, an arbitrary callback, a property matcher, or a property accessor.
1716+
</p>
1717+
<pre>
1718+
var stooges = [{name: 'curly', age: 25}, {name: 'moe', age: 21}, {name: 'larry', age: 23}];
1719+
_.map(stooges, _.iteratee('age'));
1720+
=&gt; [25, 21, 23];
16921721
</pre>
16931722

16941723
<p id="uniqueId">
@@ -1749,18 +1778,16 @@ <h2 id="utility">Utility Functions</h2>
17491778
</pre>
17501779

17511780
<p id="template">
1752-
<b class="header">template</b><code>_.template(templateString, [data], [settings])</code>
1781+
<b class="header">template</b><code>_.template(templateString, [settings])</code>
17531782
<br />
17541783
Compiles JavaScript templates into functions that can be evaluated
17551784
for rendering. Useful for rendering complicated bits of HTML from JSON
17561785
data sources. Template functions can both interpolate variables, using
17571786
<tt>&lt;%= &hellip; %&gt;</tt>, as well as execute arbitrary JavaScript code, with
17581787
<tt>&lt;% &hellip; %&gt;</tt>. If you wish to interpolate a value, and have
1759-
it be HTML-escaped, use <tt>&lt;%- &hellip; %&gt;</tt> When you evaluate a template function, pass in a
1760-
<b>data</b> object that has properties corresponding to the template's free
1761-
variables. If you're writing a one-off, you can pass the <b>data</b>
1762-
object as the second parameter to <b>template</b> in order to render
1763-
immediately instead of returning a template function. The <b>settings</b> argument
1788+
it be HTML-escaped, use <tt>&lt;%- &hellip; %&gt;</tt> When you evaluate a
1789+
template function, pass in a <b>data</b> object that has properties
1790+
corresponding to the template's free variables. The <b>settings</b> argument
17641791
should be a hash containing any <tt>_.templateSettings</tt> that should be overridden.
17651792
</p>
17661793

@@ -1769,10 +1796,6 @@ <h2 id="utility">Utility Functions</h2>
17691796
compiled({name: 'moe'});
17701797
=&gt; "hello: moe"
17711798

1772-
var list = "&lt;% _.each(people, function(name) { %&gt; &lt;li&gt;&lt;%= name %&gt;&lt;/li&gt; &lt;% }); %&gt;";
1773-
_.template(list, {people: ['moe', 'curly', 'larry']});
1774-
=&gt; "&lt;li&gt;moe&lt;/li&gt;&lt;li&gt;curly&lt;/li&gt;&lt;li&gt;larry&lt;/li&gt;"
1775-
17761799
var template = _.template("&lt;b&gt;&lt;%- value %&gt;&lt;/b&gt;");
17771800
template({value: '&lt;script&gt;'});
17781801
=&gt; "&lt;b&gt;&amp;lt;script&amp;gt;&lt;/b&gt;"</pre>
@@ -1998,6 +2021,63 @@ <h2 id="links">Links &amp; Suggested Reading</h2>
19982021

19992022
<h2 id="changelog">Change Log</h2>
20002023

2024+
<p id="1.7.0">
2025+
<b class="header">1.7.0</b> &mdash; <small><i>August 26, 2014</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.6.0...1.7.0">Diff</a> &mdash; <a href="https://cdn.rawgit.com/jashkenas/underscore/1.7.0/index.html">Docs</a><br />
2026+
<ul>
2027+
<li>
2028+
For consistency and speed across browsers, Underscore now ignores
2029+
native array methods for <tt>forEach</tt>, <tt>map</tt>, <tt>reduce</tt>,
2030+
<tt>reduceRight</tt>, <tt>filter</tt>, <tt>every</tt>, <tt>some</tt>,
2031+
<tt>indexOf</tt>, and <tt>lastIndexOf</tt>. "Sparse" arrays are
2032+
officially dead in Underscore.
2033+
</li>
2034+
<li>
2035+
Added <tt>_.iteratee</tt> to customize the iterators used by collection
2036+
functions. Many Underscore methods will take a string argument for easier
2037+
<tt>_.property</tt>-style lookups, an object for <tt>_.where</tt>-style
2038+
filtering, or a function as a custom callback.
2039+
</li>
2040+
<li>
2041+
Added <tt>_.before</tt> as a counterpart to <tt>_.after</tt>.
2042+
</li>
2043+
<li>
2044+
Added <tt>_.negate</tt> to invert the truth value of the passed-in
2045+
predicate.
2046+
</li>
2047+
<li>
2048+
Added <tt>_.noop</tt> as a handy empty placeholder function.
2049+
</li>
2050+
<li>
2051+
<tt>_.isEmpty</tt> now works with <tt>arguments</tt> objects.
2052+
</li>
2053+
<li>
2054+
<tt>_.has</tt> now guards against nullish objects.
2055+
</li>
2056+
<li>
2057+
Override base methods like <tt>each</tt> and <tt>some</tt>
2058+
and they'll be used internally by other Underscore functions too.
2059+
</li>
2060+
<li>
2061+
The escape functions handle backticks (<tt>`</tt>), to deal with an
2062+
IE &le; 8 bug.
2063+
</li>
2064+
<li>
2065+
<tt>_.memoize</tt> exposes the cache of memoized values as a property
2066+
on the returned function.
2067+
</li>
2068+
<li>
2069+
<tt>_.pick</tt> accepts `iteratee` and `context` arguments for a more
2070+
advanced callback.
2071+
</li>
2072+
<li>
2073+
Underscore templates no longer accept an initial <tt>data</tt> object.
2074+
<tt>_.template</tt> always returns a function now.
2075+
</li>
2076+
<li>
2077+
Optimizations and code cleanup aplenty.
2078+
</li>
2079+
</ul>
2080+
</p>
20012081

20022082
<p id="1.6.0">
20032083
<b class="header">1.6.0</b> &mdash; <small><i>February 10, 2014</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.5.2...1.6.0">Diff</a> &mdash; <a href="https://cdn.rawgit.com/jashkenas/underscore/1.6.0/index.html">Docs</a><br />

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"url": "git://github.com/jashkenas/underscore.git"
1616
},
1717
"main": "underscore.js",
18-
"version": "1.6.0",
18+
"version": "1.7.0",
1919
"devDependencies": {
2020
"docco": "0.6.x",
2121
"phantomjs": "1.9.7-1",

0 commit comments

Comments
 (0)