8000 Update vendor/underscore to 1.5.2. · lodash/lodash@eeabb47 · GitHub
[go: up one dir, main page]

Skip to content

Commit eeabb47

Browse files
committed
Update vendor/underscore to 1.5.2.
1 parent e078f58 commit eeabb47

File tree

7 files changed

+143
-76
lines changed

7 files changed

+143
-76
lines changed

vendor/requirejs/require.js

Lines changed: 3 additions & 3 deletions
url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** vim: et:ts=4:sw=4:sts=4
2-
* @license RequireJS 2.1.8+ Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
2+
* @license RequireJS 2.1.8 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
33
* Available via the MIT or new BSD license.
44
* see: http://github.com/jrburke/requirejs for details
55
*/
@@ -12,7 +12,7 @@ var requirejs, require, define;
1212
(function (global) {
1313
var req, s, head, baseElement, dataMain, src,
1414
interactiveScript, currentlyAddingScript, mainScript, subPath,
15-
version = '2.1.8+',
15+
version = '2.1.8',
1616
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
1717
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
1818
jsSuffixRegExp = /\.js$/,
@@ -1609,7 +1609,7 @@ var requirejs, require, define;
16091609

16101610
//Join the path parts together, then figure out if baseUrl is needed.
16111611
url = syms.join('/');
1612-
url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js'));
1612+
url += (ext || (/\?/.test(url) || skipExt ? '' : '.js'));
16131613
16141614
}
16151615

vendor/underscore/test/collections.js

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ $(document).ready(function() {
261261
result = _.where(list, {b: 2});
262262
equal(result.length, 2);
263263
equal(result[0].a, 1);
264-
264+
265265
result = _.where(list, {a: 1}, true);
266266
equal(result.b, 2, "Only get the first object matched.")
267267
result = _.where(list, {a: 1}, false);
@@ -274,6 +274,12 @@ $(document).ready(function() {
274274
deepEqual(result, {a: 1, b: 2});
275275
result = _.findWhere(list, {b: 4});
276276
deepEqual(result, {a: 1, b: 4});
277+
278+
result = _.findWhere(list, {c:1})
279+
ok(_.isUndefined(result), "undefined when not found");
280+
281+
result = _.findWhere([], {c:1});
282+
ok(_.isUndefined(result), "undefined when searching empty list");
277283
});
278284

279285
test('max', function() {
@@ -379,6 +385,24 @@ $(document).ready(function() {
379385
deepEqual(_.groupBy(matrix, 1), {2: [[1,2]], 3: [[1,3], [2,3]]})
380386
});
381387

388+
test('indexBy', function() {
389+
var parity = _.indexBy([1, 2, 3, 4, 5], function(num){ return num % 2 == 0; });
390+
equal(parity['true'], 4);
391+
equal(parity['false'], 5);
392+
393+
var list = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"];
394+
var grouped = _.indexBy(list, 'length');
395+
equal(grouped['3'], 'ten');
396+
equal(grouped['4'], 'nine');
397+
equal(grouped['5'], 'eight');
398+
399+
var array = [1, 2, 1, 2, 3];
400+
var grouped = _.indexBy(array);
401+
equal(grouped['1'], 1);
402+
equal(grouped['2'], 2);
403+
equal(grouped['3'], 3);
404+
});
405+
382406
test('countBy', function() {
383407
var parity = _.countBy([1, 2, 3, 4, 5], function(num){ return num % 2 == 0; });
384408
equal(parity['true'], 2);
@@ -433,6 +457,19 @@ $(document).ready(function() {
433457
equal(shuffled.join(','), numbers.join(','), 'contains the same members before and after shuffle');
434458
});
435459

460+
test('sample', function() {
461+
var numbers = _.range(10);
462+
var all_sampled = _.sample(numbers, 10).sort();
463+
equal(all_sampled.join(','), numbers.join(','), 'contains the same members before and after sample');
464+
all_sampled = _.sample(numbers, 20).sort();
465+
equal(all_sampled.join(','), numbers.join(','), 'also works when sampling more objects than are present');
466+
ok(_.contains(numbers, _.sample(numbers)), 'sampling a single element returns something from the array');
467+
strictEqual(_.sample([]), undefined, 'sampling empty array with no number returns undefined');
468+
notStrictEqual(_.sample([], 5), [], 'sampling empty array with a number returns an empty array');
469+
notStrictEqual(_.sample([1, 2, 3], 0), [], 'sampling an array with 0 picks returns an empty array');
470+
deepEqual(_.sample([1, 2], -1), [], 'sampling a negative number of picks returns an empty array');
471+
});
472+
436473
test('toArray', function() {
437474
ok(!_.isArray(arguments), 'arguments object is not an array');
438475
ok(_.isArray(_.toArray(arguments)), 'arguments object converted into array');

vendor/underscore/test/functions.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,14 @@ $(document).ready(function() {
159159
asyncTest("throttle repeatedly with results", 6, function() {
160160
var counter = 0;
161161
var incr = function(){ return ++counter; };
162-
var throttledIncr = _.throttle(incr, 64);
162+
var throttledIncr = _.throttle(incr, 100);
163163
var results = [];
164164
var saveResult = function() { results.push(throttledIncr()); };
165165
saveResult(); saveResult();
166-
_.delay(saveResult, 32);
167-
_.delay(saveResult, 80);
168-
_.delay(saveResult, 96);
169-
_.delay(saveResult, 144);
166+
_.delay(saveResult, 50);
167+
_.delay(saveResult, 150);
168+
_.delay(saveResult, 160);
169+
_.delay(saveResult, 230);
170170
_.delay(function() {
171171
equal(results[0], 1, "incr was called once");
172172
equal(results[1], 1, "incr was throttled");
@@ -175,7 +175,7 @@ $(document).ready(function() {
175175
equal(results[4], 2, "incr was throttled");
176176
equal(results[5], 3, "incr was called trailing");
177177
start();
178-
}, 192);
178+
}, 300);
179179
});
180180

181181
asyncTest("throttle triggers trailing call when invoked repeatedly", 2, function() {
@@ -239,10 +239,10 @@ $(document).ready(function() {
239239

240240
var time = new Date;
241241
while (new Date - time < 350) throttledIncr();
242-
ok(counter === 3);
242+
ok(counter <= 3);
243243

244244
_.delay(function() {
245-
equal(counter, 4);
245+
ok(counter <= 4);
246246
start();
247247
}, 200);
248248
});

vendor/underscore/test/objects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ $(document).ready(function() {
5252
result = _.extend({x:'x'}, {a:'a', x:2}, {a:'b'});
5353
ok(_.isEqual(result, {x:2, a:'b'}), 'extending from multiple source objects last property trumps');
5454
result = _.extend({}, {a: void 0, b: null});
55-
equal(_.keys(result).join(''), 'ab', 'extend does not copy undefined values');
55+
equal(_.keys(result).join(''), 'ab', 'extend copies undefined values');
5656

5757
try {
5858
result = {};

vendor/underscore/test/utility.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ $(document).ready(function() {
7373

7474
test("_.escape", function() {
7575
equal(_.escape("Curly & Moe"), "Curly &amp; Moe");
76-
equal(_.escape('<a href="http://moe.com">Curly & Moe\'s</a>'), '&lt;a href=&quot;http:&#x2F;&#x2F;moe.com&quot;&gt;Curly &amp; Moe&#x27;s&lt;&#x2F;a&gt;');
76+
equal(_.escape('<a href="http://moe.com">Curly & Moe\'s</a>'), '&lt;a href=&quot;http://moe.com&quot;&gt;Curly &amp; Moe&#x27;s&lt;/a&gt;');
7777
equal(_.escape("Curly &amp; Moe"), "Curly &amp;amp; Moe");
7878
equal(_.escape(null), '');
7979
});
8080

8181
test("_.unescape", function() {
8282
var string = "Curly & Moe";
8383
equal(_.unescape("Curly &amp; Moe"), string);
84-
equal(_.unescape('&lt;a href=&quot;http:&#x2F;&#x2F;moe.com&quot;&gt;Curly &amp; Moe&#x27;s&lt;&#x2F;a&gt;'), '<a href="http://moe.com">Curly & Moe\'s</a>');
84+
equal(_.unescape('&lt;a href=&quot;http://moe.com&quot;&gt;Curly &amp; Moe&#x27;s&lt;/a&gt;'), '<a href="http://moe.com">Curly & Moe\'s</a>');
8585
equal(_.unescape("Curly &amp;amp; Moe"), "Curly &amp; Moe");
8686
equal(_.unescape(null), '');
8787
equal(_.unescape(_.escape(string)), string);

0 commit comments

Comments
 (0)
0