mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-13 04:17: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
|
// clip snippet after the JSDoc comment block
|
||||||
match = match.replace(/^\s*(?:\/\/.*|\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)\n/, '');
|
match = match.replace(/^\s*(?:\/\/.*|\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)\n/, '');
|
||||||
source = source.replace(match, function() {
|
source = source.replace(match, function() {
|
||||||
return funcValue;
|
return funcValue.trimRight() + '\n';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return source;
|
return source;
|
||||||
@@ -1313,13 +1313,6 @@
|
|||||||
' }'
|
' }'
|
||||||
].join('\n'));
|
].join('\n'));
|
||||||
|
|
||||||
// replace `_.isFinite`
|
|
||||||
source = replaceFunction(source, 'isFinite', [
|
|
||||||
' function isFinite(value) {',
|
|
||||||
' return nativeIsFinite(value) && toString.call(value) == numberClass;',
|
|
||||||
' }'
|
|
||||||
].join('\n'));
|
|
||||||
|
|
||||||
// replace `_.omit`
|
// replace `_.omit`
|
||||||
source = replaceFunction(source, 'omit', [
|
source = replaceFunction(source, 'omit', [
|
||||||
' function omit(object) {',
|
' function omit(object) {',
|
||||||
@@ -1412,6 +1405,11 @@
|
|||||||
' result = [],',
|
' result = [],',
|
||||||
' seen = result;',
|
' seen = result;',
|
||||||
'',
|
'',
|
||||||
|
" if (typeof isSorted == 'function') {",
|
||||||
|
' thisArg = callback;',
|
||||||
|
' callback = isSorted;',
|
||||||
|
' isSorted = false;',
|
||||||
|
' }',
|
||||||
' if (callback) {',
|
' if (callback) {',
|
||||||
' seen = [];',
|
' seen = [];',
|
||||||
' callback = createCallback(callback, thisArg);',
|
' callback = createCallback(callback, thisArg);',
|
||||||
@@ -1437,7 +1435,7 @@
|
|||||||
// replace `_.uniqueId`
|
// replace `_.uniqueId`
|
||||||
source = replaceFunction(source, 'uniqueId', [
|
source = replaceFunction(source, 'uniqueId', [
|
||||||
' function uniqueId(prefix) {',
|
' function uniqueId(prefix) {',
|
||||||
' var id = idCounter++;',
|
" var id = ++idCounter + '';",
|
||||||
' return prefix ? prefix + id : id;',
|
' return prefix ? prefix + id : id;',
|
||||||
' }'
|
' }'
|
||||||
].join('\n'));
|
].join('\n'));
|
||||||
|
|||||||
@@ -679,7 +679,6 @@
|
|||||||
|
|
||||||
object = { 'length': 0, 'splice': Array.prototype.splice };
|
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.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 };
|
object = { 'a': 1, 'b': 2, 'c': 3 };
|
||||||
equal(lodash.isEqual(object, { 'a': 1, 'b': 0, 'c': 3 }), false, '_.isEqual: ' + basename);
|
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.some([false, true, false]), true, '_.some: ' + basename);
|
||||||
equal(lodash.template('${a}', object), '${a}', '_.template should ignore ES6 delimiters: ' + basename);
|
equal(lodash.template('${a}', object), '${a}', '_.template should ignore ES6 delimiters: ' + basename);
|
||||||
|
equal(lodash.uniqueId(0), '1', '_.uniqueId should ignore a prefix of `0`: ' + 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);
|
|
||||||
|
|
||||||
var wrapped = lodash(1);
|
var wrapped = lodash(1);
|
||||||
equal(wrapped.clone() instanceof lodash, false, '_(...) wrapped values are not chainable by default: ' + basename);
|
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
|
// http://underscorejs.org
|
||||||
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
||||||
// Underscore may be freely distributed under the MIT license.
|
// Underscore may be freely distributed under the MIT license.
|
||||||
@@ -24,7 +24,6 @@
|
|||||||
var push = ArrayProto.push,
|
var push = ArrayProto.push,
|
||||||
slice = ArrayProto.slice,
|
slice = ArrayProto.slice,
|
||||||
concat = ArrayProto.concat,
|
concat = ArrayProto.concat,
|
||||||
unshift = ArrayProto.unshift,
|
|
||||||
toString = ObjProto.toString,
|
toString = ObjProto.toString,
|
||||||
hasOwnProperty = ObjProto.hasOwnProperty;
|
hasOwnProperty = ObjProto.hasOwnProperty;
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Current version.
|
// Current version.
|
||||||
_.VERSION = '1.4.2';
|
_.VERSION = '1.4.3';
|
||||||
|
|
||||||
// Collection Functions
|
// Collection Functions
|
||||||
// --------------------
|
// --------------------
|
||||||
@@ -102,6 +101,8 @@
|
|||||||
return results;
|
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`,
|
// **Reduce** builds up a single result from a list of values, aka `inject`,
|
||||||
// or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
|
// or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
|
||||||
_.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
|
_.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
|
||||||
@@ -119,7 +120,7 @@
|
|||||||
memo = iterator.call(context, memo, value, index, list);
|
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;
|
return memo;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -146,7 +147,7 @@
|
|||||||
memo = iterator.call(context, memo, obj[index], index, list);
|
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;
|
return memo;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -239,7 +240,7 @@
|
|||||||
if (_.isEmpty(attrs)) return [];
|
if (_.isEmpty(attrs)) return [];
|
||||||
return _.filter(obj, function(value) {
|
return _.filter(obj, function(value) {
|
||||||
for (var key in attrs) {
|
for (var key in attrs) {
|
||||||
if (_.has(attrs, key) && attrs[key] !== value[key]) return false;
|
if (attrs[key] !== value[key]) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@@ -336,7 +337,7 @@
|
|||||||
// either a string attribute to count by, or a function that returns the
|
// either a string attribute to count by, or a function that returns the
|
||||||
// criterion.
|
// criterion.
|
||||||
_.countBy = function(obj, value, context) {
|
_.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;
|
if (!_.has(result, key)) result[key] = 0;
|
||||||
result[key]++;
|
result[key]++;
|
||||||
});
|
});
|
||||||
@@ -961,7 +962,7 @@
|
|||||||
|
|
||||||
// Is a given object a finite number?
|
// Is a given object a finite number?
|
||||||
_.isFinite = function(obj) {
|
_.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).
|
// Is the given value `NaN`? (NaN is the only number which does not equal itself).
|
||||||
|
|||||||
Reference in New Issue
Block a user