Skip to content

Commit e4743ab

Browse files
committed
Merge branch 'master' into gh-pages
2 parents 1d0786a + a11976e commit e4743ab

File tree

12 files changed

+495
-378
lines changed

12 files changed

+495
-378
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ matrix:
88
- node_js: "0.10"
99
env: BROWSER=true
1010
before_install:
11-
- npm install -g npm
11+
- npm install -g npm@2.6
1212
- npm install -g karma-cli
1313
before_script:
1414
- npm install karma-sauce-launcher

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "underscore",
3-
"version": "1.8.2",
3+
"version": "1.8.3",
44
"main": "underscore.js",
55
"keywords": ["util", "functional", "server", "client", "browser"],
6-
"ignore" : ["docs", "test", "*.yml", "CNAME", "index.html", "favicon.ico", "CONTRIBUTING.md"]
6+
"ignore" : ["docs", "test", "*.yml", "CNAME", "index.html", "favicon.ico", "CONTRIBUTING.md", ".*", "component.json", "package.json", "karma.*"]
77
}

component.json

Lines changed: 1 addition & 1 deletion
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.8.2",
8+
"version" : "1.8.3",
99
"license" : "MIT"
1010
}

docs/underscore.html

Lines changed: 333 additions & 297 deletions
Large diffs are not rendered by default.

index.html

Lines changed: 35 additions & 8 deletions
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.8.2)</span>
183+
Underscore.js <span class="version">(1.8.3)</span>
184184
</a>
185185
<ul class="toc_section">
186186
<li>&raquo; <a href="https://github.com/jashkenas/underscore">GitHub Repository</a></li>
@@ -279,6 +279,7 @@
279279
<li>- <a href="#mapObject">mapObject</a></li>
280280
<li>- <a href="#pairs">pairs</a></li>
281281
<li>- <a href="#invert">invert</a></li>
282+
<li>- <a href="#create">create</a></li>
282283
<li>- <a href="#object-functions">functions</a></li>
283284
<li>- <a href="#findKey">findKey</a></li>
284285
<li>- <a href="#extend">extend</a></li>
@@ -402,11 +403,11 @@ <h2>Downloads <i style="padding-left: 12px; font-size:12px;">(Right-click, and u
402403

403404
<table>
404405
<tr>
405-
<td><a href="underscore.js">Development Version (1.8.2)</a></td>
406-
<td><i>51kb, Uncompressed with Plentiful Comments</i></td>
406+
<td><a href="underscore.js">Development Version (1.8.3)</a></td>
407+
<td><i>52kb, Uncompressed with Plentiful Comments</i></td>
407408
</tr>
408409
<tr>
409-
<td><a href="underscore-min.js">Production Version (1.8.2)</a></td>
410+
<td><a href="underscore-min.js">Production Version (1.8.3)</a></td>
410411
<td>
411412
<i>5.7kb, Minified and Gzipped</i>
412413
&nbsp;<small>(<a href="underscore-min.map">Source Map</a>)</small>
@@ -939,14 +940,15 @@ <h2 id="arrays">Array Functions</h2>
939940
<span class="alias">Alias: <b>unique</b></span>
940941
<br />
941942
Produces a duplicate-free version of the <b>array</b>, using <i>===</i> to test
942-
object equality. If you know in advance that the <b>array</b> is sorted,
943+
object equality. In particular only the first occurence of each value is kept.
944+
If you know in advance that the <b>array</b> is sorted,
943945
passing <i>true</i> for <b>isSorted</b> will run a much faster algorithm.
944946
If you want to compute unique items based on a transformation, pass an
945947
<b>iteratee</b> function.
946948
</p>
947949
<pre>
948-
_.uniq([1, 2, 1, 3, 1, 4]);
949-
=&gt; [1, 2, 3, 4]
950+
_.uniq([1, 2, 1, 4, 1, 3]);
951+
=&gt; [1, 2, 4, 3]
950952
</pre>
951953

952954
<p id="zip">
@@ -1369,7 +1371,7 @@ <h2 id="objects">Object Functions</h2>
13691371
</pre>
13701372

13711373
<p id="mapObject">
1372-
<b class="header">mapObject</b><code>_.mapObject(array, iteratee, [context])</code>
1374+
<b class="header">mapObject</b><code>_.mapObject(object, iteratee, [context])</code>
13731375
<br />
13741376
Like <a href="#map">map</a>, but for objects. Transform the value
13751377
of each property in turn.
@@ -1401,6 +1403,17 @@ <h2 id="objects">Object Functions</h2>
14011403
<pre>
14021404
_.invert({Moe: "Moses", Larry: "Louis", Curly: "Jerome"});
14031405
=&gt; {Moses: "Moe", Louis: "Larry", Jerome: "Curly"};
1406+
</pre>
1407+
1408+
<p id="create">
1409+
<b class="header">create</b><code>_.create(prototype, props)</code>
1410+
<br />
1411+
Creates a new object with the given prototype, optionally attaching
1412+
<b>props</b> as <i>own</i> properties. Basically, <tt>Object.create</tt>,
1413+
but without all of the property descriptor jazz.
1414+
</p>
1415+
<pre>
1416+
var moe = _.create(Stooge.prototype, {name: "Moe"});
14041417
</pre>
14051418

14061419
<p id="object-functions">
@@ -2192,6 +2205,20 @@ <h2 id="links">Links &amp; Suggested Reading</h2>
21922205

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

2208+
<p id="1.8.3">
2209+
<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 />
2210+
<ul>
2211+
<li>
2212+
Adds an <tt>_.create</tt> method, as a slimmed down version of
2213+
<tt>Object.create</tt>.
2214+
</li>
2215+
<li>
2216+
Works around an iOS bug that can improperly cause <tt>isArrayLike</tt>
2217+
to be JIT-ed. Also fixes a bug when passing <tt>0</tt> to <tt>isArrayLike</tt>.
2218+
</li>
2219+
</ul>
2220+
</p>
2221+
21952222
<p id="1.8.2">
21962223
<b class="header">1.8.2</b> &mdash; <small><i>Feb. 22, 2015</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.8.1...1.8.2">Diff</a> &mdash; <a href="https://cdn.rawgit.com/jashkenas/underscore/1.8.2/index.html">Docs</a><br />
21972224
<ul>

package.json

Lines changed: 1 addition & 1 deletion
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.8.2",
18+
"version": "1.8.3",
1919
"devDependencies": {
2020
"docco": "*",
2121
"eslint": "0.6.x",

test/arrays.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@
344344
strictEqual(_.indexOf([1, 2, NaN, NaN], NaN), 2, 'Expected [1, 2, NaN] to contain NaN');
345345
strictEqual(_.indexOf([1, 2, Infinity], NaN), -1, 'Expected [1, 2, NaN] to contain NaN');
346346

347+
strictEqual(_.indexOf([1, 2, NaN, NaN], NaN, 1), 2, 'startIndex does not affect result');
348+
strictEqual(_.indexOf([1, 2, NaN, NaN], NaN, -2), 2, 'startIndex does not affect result');
349+
347350
(function() {
348351
strictEqual(_.indexOf(arguments, NaN), 2, 'Expected arguments [1, 2, NaN] to contain NaN');
349352
}(1, 2, NaN, NaN));
@@ -418,6 +421,9 @@
418421
strictEqual(_.lastIndexOf([1, 2, NaN, NaN], NaN), 3, 'Expected [1, 2, NaN] to contain NaN');
419422
strictEqual(_.lastIndexOf([1, 2, Infinity], NaN), -1, 'Expected [1, 2, NaN] to contain NaN');
420423

424+
strictEqual(_.lastIndexOf([1, 2, NaN, NaN], NaN, 2), 2, 'fromIndex does not affect result');
425+
strictEqual(_.lastIndexOf([1, 2, NaN, NaN], NaN, -2), 2, 'fromIndex does not affect result');
426+
421427
(function() {
422428
strictEqual(_.lastIndexOf(arguments, NaN), 3, 'Expected arguments [1, 2, NaN] to contain NaN');
423429
}(1, 2, NaN, NaN));

test/collections.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
deepEqual(answers, ['one', 'two', 'three'], 'iterating over objects works, and ignores the object prototype.');
2424
delete obj.constructor.prototype.four;
2525

26+
// ensure the each function is JITed
27+
_(1000).times(function() { _.each([], function(){}); });
28+
var count = 0;
29+
obj = {1 : 'foo', 2 : 'bar', 3 : 'baz'};
30+
_.each(obj, function(value, key){ count++; });
31+
equal(count, 3, 'the fun should be called only 3 times');
32+
2633
var answer = null;
2734
_.each([1, 2, 3], function(num, index, arr){ if (_.include(arr, num)) answer = true; });
2835
ok(answer, 'can reference the original collection from inside the iterator');
@@ -420,12 +427,14 @@
420427
strictEqual(_.includes, _.contains, 'alias for includes');
421428

422429
var numbers = [1, 2, 3, 1, 2, 3, 1, 2, 3];
423-
strictEqual(_.includes(numbers, 1, 1), true);
424-
strictEqual(_.includes(numbers, 1, -1), false);
425-
strictEqual(_.includes(numbers, 1, -2), false);
426-
strictEqual(_.includes(numbers, 1, -3), true);
427-
strictEqual(_.includes(numbers, 1, 6), true);
428-
strictEqual(_.includes(numbers, 1, 7), false);
430+
strictEqual(_.includes(numbers, 1, 1), true, 'contains takes a fromIndex');
431+
strictEqual(_.includes(numbers, 1, -1), false, 'contains takes a fromIndex');
432+
strictEqual(_.includes(numbers, 1, -2), false, 'contains takes a fromIndex');
433+
strictEqual(_.includes(numbers, 1, -3), true, 'contains takes a fromIndex');
434+
strictEqual(_.includes(numbers, 1, 6), true, 'contains takes a fromIndex');
435+
strictEqual(_.includes(numbers, 1, 7), false, 'contains takes a fromIndex');
436+
437+
ok(_.every([1, 2, 3], _.partial(_.contains, numbers)), 'fromIndex is guarded');
429438
});
430439

431440
test('includes with NaN', function() {
@@ -789,6 +798,7 @@
789798
equal(_.size(new String('hello')), 5, 'can compute the size of string object');
790799

791800
equal(_.size(null), 0, 'handles nulls');
801+
equal(_.size(0), 0, 'handles numbers');
792802
});
793803

794804
test('partition', function() {

test/objects.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,32 @@
282282
equal(_.clone(null), null, 'non objects should not be changed by clone');
283283
});
284284

285+
test('create', function() {
286+
var Parent = function() {};
287+
Parent.prototype = {foo: function() {}, bar: 2};
288+
289+
_.each(['foo', null, undefined, 1], function(val) {
290+
deepEqual(_.create(val), {}, 'should return empty object when a non-object is provided');
291+
});
292+
293+
ok(_.create([]) instanceof Array, 'should return new instance of array when array is provided');
294+
295+
var Child = function() {};
296+
Child.prototype = _.create(Parent.prototype);
297+
ok(new Child instanceof Parent, 'object should inherit prototype');
298+
299+
var func = function() {};
300+
Child.prototype = _.create(Parent.prototype, {func: func});
301+
strictEqual(Child.prototype.func, func, 'properties should be added to object');
302+
303+
Child.prototype = _.create(Parent.prototype, {constructor: Child});
304+
strictEqual(Child.prototype.constructor, Child);
305+
306+
Child.prototype.foo = 'foo';
307+
var created = _.create(Child.prototype, new Child);
308+
ok(!created.hasOwnProperty('foo'), 'should only add own properties');
309+
});
310+
285311
test('isEqual', function() {
286312
function First() {
287313
this.value = 1;

underscore-min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

underscore-min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)