Reduce _.merge.

Former-commit-id: 5797e14e589d39e553d7af109d282109e633cd80
This commit is contained in:
John-David Dalton
2012-10-13 20:58:39 -07:00
parent 3f79ed5d91
commit 96553b217c

View File

@@ -1665,17 +1665,15 @@
* _.merge(stooges, ages); * _.merge(stooges, ages);
* // => [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }] * // => [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }]
*/ */
function merge(object, source, indicator) { function merge(object, source, indicator, stackA, stackB) {
var args = arguments, var args = arguments,
index = 0, index = 0,
length = 2, length = 2;
stackA = args[3],
stackB = args[4];
if (indicator != compareAscending) { if (indicator != compareAscending) {
length = args.length;
stackA = []; stackA = [];
stackB = []; stackB = [];
length = args.length;
} }
while (++index < length) { while (++index < length) {
forOwn(args[index], function(source, key) { forOwn(args[index], function(source, key) {
@@ -3476,18 +3474,18 @@
return function() { return function() {
var now = new Date, var now = new Date,
remain = wait - (now - lastCalled); remaining = wait - (now - lastCalled);
args = arguments; args = arguments;
thisArg = this; thisArg = this;
if (remain <= 0) { if (remaining <= 0) {
clearTimeout(timeoutId); clearTimeout(timeoutId);
lastCalled = now; lastCalled = now;
result = func.apply(thisArg, args); result = func.apply(thisArg, args);
} }
else if (!timeoutId) { else if (!timeoutId) {
timeoutId = setTimeout(trailingCall, remain); timeoutId = setTimeout(trailingCall, remaining);
} }
return result; return result;
}; };