mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Update vendor/underscore to v1.4.3 and update the Underscore build compatibility.
Former-commit-id: ebcaad4a92848bef3bbf65bb8eb3a0c1553e005c
This commit is contained in:
16
build.js
16
build.js
@@ -841,7 +841,7 @@
|
||||
// clip snippet after the JSDoc comment block
|
||||
match = match.replace(/^\s*(?:\/\/.*|\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)\n/, '');
|
||||
source = source.replace(match, function() {
|
||||
return funcValue;
|
||||
return funcValue.trimRight() + '\n';
|
||||
});
|
||||
}
|
||||
return source;
|
||||
@@ -1313,13 +1313,6 @@
|
||||
' }'
|
||||
].join('\n'));
|
||||
|
||||
// replace `_.isFinite`
|
||||
source = replaceFunction(source, 'isFinite', [
|
||||
' function isFinite(value) {',
|
||||
' return nativeIsFinite(value) && toString.call(value) == numberClass;',
|
||||
' }'
|
||||
].join('\n'));
|
||||
|
||||
// replace `_.omit`
|
||||
source = replaceFunction(source, 'omit', [
|
||||
' function omit(object) {',
|
||||
@@ -1412,6 +1405,11 @@
|
||||
' result = [],',
|
||||
' seen = result;',
|
||||
'',
|
||||
" if (typeof isSorted == 'function') {",
|
||||
' thisArg = callback;',
|
||||
' callback = isSorted;',
|
||||
' isSorted = false;',
|
||||
' }',
|
||||
' if (callback) {',
|
||||
' seen = [];',
|
||||
' callback = createCallback(callback, thisArg);',
|
||||
@@ -1437,7 +1435,7 @@
|
||||
// replace `_.uniqueId`
|
||||
source = replaceFunction(source, 'uniqueId', [
|
||||
' function uniqueId(prefix) {',
|
||||
' var id = idCounter++;',
|
||||
" var id = ++idCounter + '';",
|
||||
' return prefix ? prefix + id : id;',
|
||||
' }'
|
||||
].join('\n'));
|
||||
|
||||
@@ -679,7 +679,6 @@
|
||||
|
||||
object = { 'length': 0, 'splice': Array.prototype.splice };
|
||||
equal(lodash.isEmpty(object), false, '_.isEmpty should return `false` for jQuery/MooTools DOM query collections: ' + basename);
|
||||
equal(lodash.isFinite('2'), false, '_.isFinite should return `false` for numeric string values: ' + basename);
|
||||
|
||||
object = { 'a': 1, 'b': 2, 'c': 3 };
|
||||
equal(lodash.isEqual(object, { 'a': 1, 'b': 0, 'c': 3 }), false, '_.isEqual: ' + basename);
|
||||
@@ -697,10 +696,7 @@
|
||||
|
||||
equal(lodash.some([false, true, false]), true, '_.some: ' + basename);
|
||||
equal(lodash.template('${a}', object), '${a}', '_.template should ignore ES6 delimiters: ' + basename);
|
||||
|
||||
actual = [lodash.uniqueId(3), lodash.uniqueId(2), lodash.uniqueId(1)];
|
||||
equal(actual.join(','), '3,3,3', '_.uniqueId should not coerce the prefix argument to a string: ' + basename);
|
||||
equal(typeof lodash.uniqueId(), 'number', '_.uniqueId should return a number value when not passing a prefix argument: ' + basename);
|
||||
equal(lodash.uniqueId(0), '1', '_.uniqueId should ignore a prefix of `0`: ' + basename);
|
||||
|
||||
var wrapped = lodash(1);
|
||||
equal(wrapped.clone() instanceof lodash, false, '_(...) wrapped values are not chainable by default: ' + basename);
|
||||
|
||||
4
vendor/underscore/underscore-min.js
vendored
4
vendor/underscore/underscore-min.js
vendored
File diff suppressed because one or more lines are too long
17
vendor/underscore/underscore.js
vendored
17
vendor/underscore/underscore.js
vendored
@@ -1,4 +1,4 @@
|
||||
// Underscore.js 1.4.2
|
||||
// Underscore.js 1.4.3
|
||||
// http://underscorejs.org
|
||||
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
||||
// Underscore may be freely distributed under the MIT license.
|
||||
@@ -24,7 +24,6 @@
|
||||
var push = ArrayProto.push,
|
||||
slice = ArrayProto.slice,
|
||||
concat = ArrayProto.concat,
|
||||
unshift = ArrayProto.unshift,
|
||||
toString = ObjProto.toString,
|
||||
hasOwnProperty = ObjProto.hasOwnProperty;
|
||||
|
||||
@@ -65,7 +64,7 @@
|
||||
}
|
||||
|
||||
// Current version.
|
||||
_.VERSION = '1.4.2';
|
||||
_.VERSION = '1.4.3';
|
||||
|
||||
// Collection Functions
|
||||
// --------------------
|
||||
@@ -102,6 +101,8 @@
|
||||
return results;
|
||||
};
|
||||
|
||||
var reduceError = 'Reduce of empty array with no initial value';
|
||||
|
||||
// **Reduce** builds up a single result from a list of values, aka `inject`,
|
||||
// or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
|
||||
_.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
|
||||
@@ -119,7 +120,7 @@
|
||||
memo = iterator.call(context, memo, value, index, list);
|
||||
}
|
||||
});
|
||||
if (!initial) throw new TypeError('Reduce of empty array with no initial value');
|
||||
if (!initial) throw new TypeError(reduceError);
|
||||
return memo;
|
||||
};
|
||||
|
||||
@@ -146,7 +147,7 @@
|
||||
memo = iterator.call(context, memo, obj[index], index, list);
|
||||
}
|
||||
});
|
||||
if (!initial) throw new TypeError('Reduce of empty array with no initial value');
|
||||
if (!initial) throw new TypeError(reduceError);
|
||||
return memo;
|
||||
};
|
||||
|
||||
@@ -239,7 +240,7 @@
|
||||
if (_.isEmpty(attrs)) return [];
|
||||
return _.filter(obj, function(value) {
|
||||
for (var key in attrs) {
|
||||
if (_.has(attrs, key) && attrs[key] !== value[key]) return false;
|
||||
if (attrs[key] !== value[key]) return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
@@ -336,7 +337,7 @@
|
||||
// either a string attribute to count by, or a function that returns the
|
||||
// criterion.
|
||||
_.countBy = function(obj, value, context) {
|
||||
return group(obj, value, context, function(result, key, value) {
|
||||
return group(obj, value, context, function(result, key) {
|
||||
if (!_.has(result, key)) result[key] = 0;
|
||||
result[key]++;
|
||||
});
|
||||
@@ -961,7 +962,7 @@
|
||||
|
||||
// Is a given object a finite number?
|
||||
_.isFinite = function(obj) {
|
||||
return isFinite( obj ) && !isNaN( parseFloat(obj) );
|
||||
return isFinite(obj) && !isNaN(parseFloat(obj));
|
||||
};
|
||||
|
||||
// Is the given value `NaN`? (NaN is the only number which does not equal itself).
|
||||
|
||||
Reference in New Issue
Block a user