mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 08:57:49 +00:00
Update vendor/underscore to v1.5.1 and update copyrights and tested environments.
Former-commit-id: 3bdfb1de97d08d05199f5f97c9c3145d7068e7fd
This commit is contained in:
3
vendor/underscore/LICENSE
vendored
3
vendor/underscore/LICENSE
vendored
@@ -1,4 +1,5 @@
|
||||
Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud
|
||||
Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative
|
||||
Reporters & Editors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
|
||||
14
vendor/underscore/test/arrays.js
vendored
14
vendor/underscore/test/arrays.js
vendored
@@ -134,19 +134,17 @@ $(document).ready(function() {
|
||||
var names = ['moe', 'larry', 'curly'], ages = [30, 40, 50], leaders = [true];
|
||||
var stooges = _.zip(names, ages, leaders);
|
||||
equal(String(stooges), 'moe,30,true,larry,40,,curly,50,', 'zipped together arrays of different lengths');
|
||||
});
|
||||
|
||||
test('unzip', function() {
|
||||
var stoogesUnzipped = _.unzip(['moe',30, 'stooge 1'],['larry',40, 'stooge 2'],['curly',50, 'stooge 3']);
|
||||
deepEqual(stoogesUnzipped, [['moe','larry','curly'],[30,40,50], ['stooge 1', 'stooge 2', 'stooge 3']], 'unzipped pairs');
|
||||
stooges = _.zip(['moe',30, 'stooge 1'],['larry',40, 'stooge 2'],['curly',50, 'stooge 3']);
|
||||
deepEqual(stooges, [['moe','larry','curly'],[30,40,50], ['stooge 1', 'stooge 2', 'stooge 3']], 'zipped pairs');
|
||||
|
||||
// In the case of difference lengths of the tuples undefineds
|
||||
// should be used as placeholder
|
||||
stoogesUnzipped = _.unzip(['moe',30],['larry',40],['curly',50, 'extra data']);
|
||||
deepEqual(stoogesUnzipped, [['moe','larry','curly'],[30,40,50], [undefined, undefined, 'extra data']], 'unzipped pairs');
|
||||
stooges = _.zip(['moe',30],['larry',40],['curly',50, 'extra data']);
|
||||
deepEqual(stooges, [['moe','larry','curly'],[30,40,50], [undefined, undefined, 'extra data']], 'zipped pairs with empties');
|
||||
|
||||
var emptyUnzipped = _.unzip([]);
|
||||
deepEqual(emptyUnzipped, [], 'unzipped empty');
|
||||
var empty = _.zip([]);
|
||||
deepEqual(empty, [], 'unzipped empty');
|
||||
});
|
||||
|
||||
test('object', function() {
|
||||
|
||||
50
vendor/underscore/test/functions.js
vendored
50
vendor/underscore/test/functions.js
vendored
@@ -142,6 +142,20 @@ $(document).ready(function() {
|
||||
_.delay(function(){ equal(counter, 2, "incr was called twice"); start(); }, 64);
|
||||
});
|
||||
|
||||
asyncTest("more throttling", 3, function() {
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 30);
|
||||
throttledIncr(); throttledIncr();
|
||||
ok(counter == 1);
|
||||
_.delay(function(){
|
||||
ok(counter == 2);
|
||||
throttledIncr();
|
||||
ok(counter == 3);
|
||||
start();
|
||||
}, 85);
|
||||
});
|
||||
|
||||
asyncTest("throttle repeatedly with results", 6, function() {
|
||||
var counter = 0;
|
||||
var incr = function(){ return ++counter; };
|
||||
@@ -197,6 +211,42 @@ $(document).ready(function() {
|
||||
}, 96);
|
||||
});
|
||||
|
||||
asyncTest("more throttle does not trigger leading call when leading is set to false", 3, function() {
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 100, {leading: false});
|
||||
|
||||
throttledIncr();
|
||||
_.delay(throttledIncr, 50);
|
||||
_.delay(throttledIncr, 60);
|
||||
_.delay(throttledIncr, 200);
|
||||
ok(counter === 0);
|
||||
|
||||
_.delay(function() {
|
||||
ok(counter == 1);
|
||||
}, 250);
|
||||
|
||||
_.delay(function() {
|
||||
ok(counter == 2);
|
||||
start();
|
||||
}, 350);
|
||||
});
|
||||
|
||||
asyncTest("one more throttle with leading: false test", 2, function() {
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 100, {leading: false});
|
||||
|
||||
var time = new Date;
|
||||
while (new Date - time < 350) throttledIncr();
|
||||
ok(counter === 3);
|
||||
|
||||
_.delay(function() {
|
||||
equal(counter, 4);
|
||||
start();
|
||||
}, 200);
|
||||
});
|
||||
|
||||
asyncTest("throttle does not trigger trailing call when trailing is set to false", 4, function() {
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
|
||||
9
vendor/underscore/underscore-min.js
vendored
9
vendor/underscore/underscore-min.js
vendored
File diff suppressed because one or more lines are too long
19
vendor/underscore/underscore.js
vendored
19
vendor/underscore/underscore.js
vendored
@@ -1,7 +1,6 @@
|
||||
// Underscore.js 1.5.0
|
||||
// Underscore.js 1.5.1
|
||||
// http://underscorejs.org
|
||||
// (c) 2009-2011 Jeremy Ashkenas, DocumentCloud Inc.
|
||||
// (c) 2011-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
// (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore may be freely distributed under the MIT license.
|
||||
|
||||
(function() {
|
||||
@@ -66,7 +65,7 @@
|
||||
}
|
||||
|
||||
// Current version.
|
||||
_.VERSION = '1.5.0';
|
||||
_.VERSION = '1.5.1';
|
||||
|
||||
// Collection Functions
|
||||
// --------------------
|
||||
@@ -495,16 +494,6 @@
|
||||
// Zip together multiple lists into a single array -- elements that share
|
||||
// an index go together.
|
||||
_.zip = function() {
|
||||
return _.unzip.apply(_, slice.call(arguments));
|
||||
};
|
||||
|
||||
// The inverse operation to `_.zip`. If given an array of pairs it
|
||||
// returns an array of the paired elements split into two left and
|
||||
// right element arrays, if given an array of triples it returns a
|
||||
// three element array and so on. For example, `_.unzip` given
|
||||
// `[['a',1],['b',2],['c',3]]` returns the array
|
||||
// [['a','b','c'],[1,2,3]].
|
||||
_.unzip = function() {
|
||||
var length = _.max(_.pluck(arguments, "length").concat(0));
|
||||
var results = new Array(length);
|
||||
for (var i = 0; i < length; i++) {
|
||||
@@ -662,7 +651,7 @@
|
||||
var previous = 0;
|
||||
options || (options = {});
|
||||
var later = function() {
|
||||
previous = new Date;
|
||||
previous = options.leading === false ? 0 : new Date;
|
||||
timeout = null;
|
||||
result = func.apply(context, args);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user