Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare V1.9.0 #2213

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"repo" : "jashkenas/underscore",
"main" : "underscore.js",
"scripts" : ["underscore.js"],
"version" : "1.8.3",
"version" : "1.9.0",
"license" : "MIT"
}
52 changes: 51 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
<div id="sidebar" class="interface">

<a class="toc_title" href="#">
Underscore.js <span class="version">(1.8.3)</span>
Underscore.js <span class="version">(1.9.0)</span>
</a>
<ul class="toc_section">
<li>&raquo; <a href="https://github.com/jashkenas/underscore">GitHub Repository</a></li>
Expand Down Expand Up @@ -256,6 +256,7 @@
<li>- <a href="#bind">bind</a></li>
<li>- <a href="#bindAll">bindAll</a></li>
<li>- <a href="#partial">partial</a></li>
<li>- <a href="#restParam">restParam</a></li>
<li>- <a href="#memoize">memoize</a></li>
<li>- <a href="#delay">delay</a></li>
<li>- <a href="#defer">defer</a></li>
Expand Down Expand Up @@ -1151,6 +1152,10 @@ <h2 id="functions">Function (uh, ahem) Functions</h2>
subFrom20 = _.partial(subtract, _, 20);
subFrom20(5);
=&gt; 15

// To change the placeholder to any given value set
var customPlaceholder = null;
_.partial.placeholder = customPlaceholder;
</pre>

<p id="memoize">
Expand All @@ -1168,6 +1173,25 @@ <h2 id="functions">Function (uh, ahem) Functions</h2>
var fibonacci = _.memoize(function(n) {
return n &lt; 2 ? n: fibonacci(n - 1) + fibonacci(n - 2);
});
</pre>

<p id="restParam">
<b class="header">memoize</b><code>_.memoize(function, [index=function.length-1])</code>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memoize? 😛

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops (feel free to just push to this branch as you see fit)

<span class="alias">Alias: <b>restArgs</b></span>
<br />
Similar to ES6's <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/rest_parameters">rest param</a>,
<code>restParam</code> collects arguments passed to a function from
a given <code>index</code> as an array.
</p>
<pre>
function multiply(multiplier, ...theArgs) {
return theArgs.map(function (element) {
return multiplier * element;
});
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd probably be more helpful to show how a restParam function translates into ES6.


var arr = multiply(2, 1, 2, 3);
console.log(arr); // [2, 4, 6]
</pre>

<p id="delay">
Expand Down Expand Up @@ -2206,6 +2230,32 @@ <h2 id="links">Links &amp; Suggested Reading</h2>

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

<p id="1.9.0">
<b class="header">1.9.0</b> &mdash; <small><i>June 12, 2015</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.8.3...1.9.0">Diff</a> &mdash; <a href="https://cdn.rawgit.com/jashkenas/underscore/1.9.0/index.html">Docs</a><br />
<ul>
<li>
Adds <tt>_.restParam</tt> wrapper function.
</li>
<li>
Adds support for several environments including: <code>WebWorker</code>, browserify and ES6 imports.
</li>
<li>
Remove use of native implementation of <code>Function.prototype.bind</code>
in <code>_.bind</code>.
</li>
<li>
The placeholder used for partial is now configurable by setting
<code>_.partial.placeholder</code>.
</li>
<li>
<code>_.bindAll</code> now accepts arrays or arguments for keys.
</li>
<li>
Numerous performance improvements.
</li>
</ul>
</p>

<p id="1.8.3">
<b class="header">1.8.3</b> &mdash; <small><i>April 2, 2015</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.8.2...1.8.3">Diff</a> &mdash; <a href="https://cdn.rawgit.com/jashkenas/underscore/1.8.3/index.html">Docs</a><br />
<ul>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"url": "git://github.com/jashkenas/underscore.git"
},
"main": "underscore.js",
"version": "1.8.3",
"version": "1.9.0",
"devDependencies": {
"coveralls": "^2.11.2",
"docco": "*",
Expand Down
4 changes: 4 additions & 0 deletions test/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,4 +620,8 @@
}, 0)(1, 2, 3, 4);
});

test('restParam', function() {
strictEqual(_.restParam, _.restArgs, 'Should be aliased');
});

}());
6 changes: 3 additions & 3 deletions underscore.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Underscore.js 1.8.3
// Underscore.js 1.9.0
// http://underscorejs.org
// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Underscore may be freely distributed under the MIT license.
Expand Down Expand Up @@ -56,7 +56,7 @@
}

// Current version.
_.VERSION = '1.8.3';
_.VERSION = '1.9.0';

// Internal function that returns an efficient (for current engines) version
// of the passed-in callback, to be repeatedly applied in other Underscore
Expand Down Expand Up @@ -902,7 +902,7 @@
// often you call it. Useful for lazy initialization.
_.once = _.partial(_.before, 2);

_.restArgs = restArgs;
_.restParam = _.restArgs = restArgs;

// Object Functions
// ----------------
Expand Down