mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Rebuild dist.
This commit is contained in:
464
dist/lodash.compat.js
vendored
464
dist/lodash.compat.js
vendored
@@ -116,10 +116,10 @@
|
||||
/** Used to assign default `context` object properties */
|
||||
var contextProps = [
|
||||
'Array', 'ArrayBuffer', 'Date', 'Error', 'Float32Array', 'Float64Array',
|
||||
'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number', 'Object',
|
||||
'RegExp', 'Set', 'String', '_', 'clearTimeout', 'document', 'isFinite', 'isNaN',
|
||||
'parseInt', 'setTimeout', 'TypeError', 'Uint8Array', 'Uint8ClampedArray',
|
||||
'Uint16Array', 'Uint32Array', 'window', 'WinRTError'
|
||||
'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number',
|
||||
'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'document',
|
||||
'isFinite', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array',
|
||||
'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'window', 'WinRTError'
|
||||
];
|
||||
|
||||
/** Used to fix the JScript `[[DontEnum]]` bug */
|
||||
@@ -586,7 +586,7 @@
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Create a new `lodash` function using the given `context` object.
|
||||
* Create a new pristine `lodash` function using the given `context` object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -595,19 +595,22 @@
|
||||
* @returns {Function} Returns a new `lodash` function.
|
||||
* @example
|
||||
*
|
||||
* _.mixin({ 'add': function(a, b) { return a + b; } }, false);
|
||||
*
|
||||
* var lodash = _.runInContext();
|
||||
* lodash.mixin({ 'sub': function(a, b) { return a - b; } }, false);
|
||||
*
|
||||
* lodash.mixin({
|
||||
* 'exists': function(value) {
|
||||
* return value != null;
|
||||
* }
|
||||
* }, false);
|
||||
*
|
||||
* _.isFunction(lodash.exists);
|
||||
* _.isFunction(_.add);
|
||||
* // => true
|
||||
*
|
||||
* _.isFunction(_.exists);
|
||||
* _.isFunction(_.sub);
|
||||
* // => false
|
||||
*
|
||||
* lodash.isFunction(lodash.add);
|
||||
* // => false
|
||||
*
|
||||
* lodash.isFunction(lodash.sub);
|
||||
* // => true
|
||||
*/
|
||||
function runInContext(context) {
|
||||
// Avoid issues with some ES3 environments that attempt to use values, named
|
||||
@@ -1193,7 +1196,7 @@
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @param {Function} iterator The function called per iteration.
|
||||
* @param {*} [accumulator] The initial value.
|
||||
* @param {boolean} [initFromArray=false] Specify using the first element of
|
||||
* @param {boolean} [initFromArray=false] Specify using the last element of
|
||||
* `array` as the initial value.
|
||||
* @returns {*} Returns the accumulated value.
|
||||
*/
|
||||
@@ -1299,51 +1302,57 @@
|
||||
* @returns {Function} Returns the new function.
|
||||
*/
|
||||
function baseCallback(func, thisArg, argCount) {
|
||||
if (typeof func != 'function') {
|
||||
var type = typeof func;
|
||||
|
||||
if (type == 'function') {
|
||||
if (typeof thisArg == 'undefined') {
|
||||
return func;
|
||||
}
|
||||
var data = func[EXPANDO];
|
||||
if (typeof data == 'undefined') {
|
||||
if (support.funcNames) {
|
||||
data = !func.name;
|
||||
}
|
||||
data = data || !support.funcDecomp;
|
||||
if (!data) {
|
||||
var source = fnToString.call(func);
|
||||
if (!support.funcNames) {
|
||||
data = !reFuncName.test(source);
|
||||
}
|
||||
if (!data) {
|
||||
// checks if `func` references the `this` keyword and stores the result
|
||||
data = reThis.test(source) || isNative(func);
|
||||
setData(func, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
// exit early if there are no `this` references or `func` is bound
|
||||
if (data === false || (data !== true && data[1] & BIND_FLAG)) {
|
||||
return func;
|
||||
}
|
||||
switch (argCount) {
|
||||
case 1: return function(value) {
|
||||
return func.call(thisArg, value);
|
||||
};
|
||||
case 3: return function(value, index, collection) {
|
||||
return func.call(thisArg, value, index, collection);
|
||||
};
|
||||
case 4: return function(accumulator, value, index, collection) {
|
||||
return func.call(thisArg, accumulator, value, index, collection);
|
||||
};
|
||||
case 5: return function(value, other, key, object, source) {
|
||||
return func.call(thisArg, value, other, key, object, source);
|
||||
};
|
||||
}
|
||||
return function() {
|
||||
return func.apply(thisArg, arguments);
|
||||
};
|
||||
}
|
||||
if (func == null) {
|
||||
return identity;
|
||||
}
|
||||
if (typeof thisArg == 'undefined') {
|
||||
return func;
|
||||
}
|
||||
var data = func[EXPANDO];
|
||||
if (typeof data == 'undefined') {
|
||||
if (support.funcNames) {
|
||||
data = !func.name;
|
||||
}
|
||||
data = data || !support.funcDecomp;
|
||||
if (!data) {
|
||||
var source = fnToString.call(func);
|
||||
if (!support.funcNames) {
|
||||
data = !reFuncName.test(source);
|
||||
}
|
||||
if (!data) {
|
||||
// checks if `func` references the `this` keyword and stores the result
|
||||
data = reThis.test(source) || isNative(func);
|
||||
setData(func, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
// exit early if there are no `this` references or `func` is bound
|
||||
if (data === false || (data !== true && data[1] & BIND_FLAG)) {
|
||||
return func;
|
||||
}
|
||||
switch (argCount) {
|
||||
case 1: return function(value) {
|
||||
return func.call(thisArg, value);
|
||||
};
|
||||
case 3: return function(value, index, collection) {
|
||||
return func.call(thisArg, value, index, collection);
|
||||
};
|
||||
case 4: return function(accumulator, value, index, collection) {
|
||||
return func.call(thisArg, accumulator, value, index, collection);
|
||||
};
|
||||
case 5: return function(value, other, key, object, source) {
|
||||
return func.call(thisArg, value, other, key, object, source);
|
||||
};
|
||||
}
|
||||
return function() {
|
||||
return func.apply(thisArg, arguments);
|
||||
};
|
||||
// handle "_.pluck" and "_.where" style callback shorthands
|
||||
return type == 'object' ? matches(func) : property(func);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1418,7 +1427,7 @@
|
||||
if (Ctor instanceof Ctor) {
|
||||
Ctor = ctorByClass[className];
|
||||
}
|
||||
return new Ctor(cloneBuffer(value.buffer));
|
||||
return new Ctor(cloneBuffer(value.buffer), value.byteOffset, value.length);
|
||||
|
||||
case numberClass:
|
||||
case stringClass:
|
||||
@@ -1607,7 +1616,7 @@
|
||||
}
|
||||
var index = -1,
|
||||
indexOf = getIndexOf(),
|
||||
prereq = indexOf === baseIndexOf,
|
||||
prereq = indexOf == baseIndexOf,
|
||||
isLarge = prereq && createCache && values && values.length >= 200,
|
||||
isCommon = prereq && !isLarge,
|
||||
result = [],
|
||||
@@ -2306,7 +2315,7 @@
|
||||
* @param {Array|Object|string} collection The collection to iterate over.
|
||||
* @param {Function} iterator The function called per iteration.
|
||||
* @param {*} accumulator The initial value.
|
||||
* @param {boolean} initFromCollection Specify using the first element
|
||||
* @param {boolean} initFromCollection Specify using the first or last element
|
||||
* of `collection` as the initial value.
|
||||
* @param {Function} eachFunc The function to iterate over `collection`.
|
||||
* @returns {*} Returns the accumulated value.
|
||||
@@ -2377,18 +2386,14 @@
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {boolean} [isSorted=false] Specify the array is sorted.
|
||||
* @param {Function} [iterator] The function called per iteration.
|
||||
* @returns {Array} Returns the new duplicate-value-free array.
|
||||
*/
|
||||
function baseUniq(array, isSorted, iterator) {
|
||||
var length = array ? array.length : 0;
|
||||
if (!length) {
|
||||
return [];
|
||||
}
|
||||
function baseUniq(array, iterator) {
|
||||
var index = -1,
|
||||
indexOf = getIndexOf(),
|
||||
prereq = !isSorted && indexOf === baseIndexOf,
|
||||
length = array.length,
|
||||
prereq = indexOf == baseIndexOf,
|
||||
isLarge = prereq && createCache && length >= 200,
|
||||
isCommon = prereq && !isLarge,
|
||||
result = [];
|
||||
@@ -2397,7 +2402,7 @@
|
||||
var seen = createCache();
|
||||
indexOf = cacheIndexOf;
|
||||
} else {
|
||||
seen = (iterator && !isSorted) ? [] : result;
|
||||
seen = iterator ? [] : result;
|
||||
}
|
||||
outer:
|
||||
while (++index < length) {
|
||||
@@ -2416,12 +2421,6 @@
|
||||
}
|
||||
result.push(value);
|
||||
}
|
||||
else if (isSorted) {
|
||||
if (!index || seen !== computed) {
|
||||
seen = computed;
|
||||
result.push(value);
|
||||
}
|
||||
}
|
||||
else if (indexOf(seen, computed) < 0) {
|
||||
if (iterator || isLarge) {
|
||||
seen.push(computed);
|
||||
@@ -2531,7 +2530,7 @@
|
||||
function createAggregator(setter, initializer) {
|
||||
return function(collection, iterator, thisArg) {
|
||||
var result = initializer ? initializer() : {};
|
||||
iterator = lodash.callback(iterator, thisArg, 3);
|
||||
iterator = getCallback(iterator, thisArg, 3);
|
||||
|
||||
if (isArray(collection)) {
|
||||
var index = -1,
|
||||
@@ -2808,6 +2807,21 @@
|
||||
return baseCreateWrapper([func, bitmask, arity, thisArg, partialArgs, partialRightArgs, partialHolders, partialRightHolders]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the appropriate "callback" function. If the `_.callback` method is
|
||||
* customized this function returns the custom method, otherwise it returns
|
||||
* the `baseCallback` function. If arguments are provided the chosen function
|
||||
* is executed with the arguments and its result is returned.
|
||||
*
|
||||
* @private
|
||||
* @returns {Function} Returns the chosen function or its result.
|
||||
*/
|
||||
function getCallback(func, thisArg, argCount) {
|
||||
var result = lodash.callback || callback;
|
||||
result = result === callback ? baseCallback : result;
|
||||
return arguments.length ? result(func, thisArg, argCount) : result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the indexes of all placeholder elements in `array`.
|
||||
*
|
||||
@@ -2831,14 +2845,16 @@
|
||||
/**
|
||||
* Gets the appropriate "indexOf" function. If the `_.indexOf` method is
|
||||
* customized this function returns the custom method, otherwise it returns
|
||||
* the `baseIndexOf` function.
|
||||
* the `baseIndexOf` function. If arguments are provided the chosen function
|
||||
* is executed with the arguments and its result is returned.
|
||||
*
|
||||
* @private
|
||||
* @returns {Function} Returns the "indexOf" function.
|
||||
* @returns {Function|number} Returns the chosen function or its result.
|
||||
*/
|
||||
function getIndexOf() {
|
||||
function getIndexOf(collection, target, fromIndex) {
|
||||
var result = lodash.indexOf || indexOf;
|
||||
return result === indexOf ? baseIndexOf : result;
|
||||
result = result === indexOf ? baseIndexOf : result;
|
||||
return collection ? result(collection, target, fromIndex) : result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2867,6 +2883,18 @@
|
||||
: (value && type == 'object' && reHostCtor.test(toString.call(value))) || false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` if suitable for strict
|
||||
* equality comparisons, else `false`.
|
||||
*/
|
||||
function isStrictComparable(value) {
|
||||
return value === value && (value === 0 ? (1 / value > 0) : !isObject(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of the given array buffer.
|
||||
*
|
||||
@@ -2983,6 +3011,33 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* An implementation of `_.uniq` optimized for sorted arrays without support
|
||||
* for callback shorthands and `this` binding.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {Function} [iterator] The function called per iteration.
|
||||
* @returns {Array} Returns the new duplicate-value-free array.
|
||||
*/
|
||||
function sortedUniq(array, iterator) {
|
||||
var seen,
|
||||
index = -1,
|
||||
length = array.length,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index],
|
||||
computed = iterator ? iterator(value, index, array) : value;
|
||||
|
||||
if (!index || seen !== computed) {
|
||||
seen = computed;
|
||||
result.push(value);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts `collection` to an array if it is not an array-like value.
|
||||
*
|
||||
@@ -3196,7 +3251,7 @@
|
||||
var length = array ? array.length : 0,
|
||||
index = length;
|
||||
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
while (index-- && predicate(array[index], index, array)) { }
|
||||
return slice(array, 0, index + 1);
|
||||
}
|
||||
@@ -3244,7 +3299,7 @@
|
||||
var index = -1,
|
||||
length = array ? array.length : 0;
|
||||
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
while (++index < length && predicate(array[index], index, array)) { }
|
||||
return slice(array, index);
|
||||
}
|
||||
@@ -3294,7 +3349,7 @@
|
||||
var index = -1,
|
||||
length = array ? array.length : 0;
|
||||
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
while (++index < length) {
|
||||
if (predicate(array[index], index, array)) {
|
||||
return index;
|
||||
@@ -3347,7 +3402,7 @@
|
||||
function findLastIndex(array, predicate, thisArg) {
|
||||
var length = array ? array.length : 0;
|
||||
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
while (length--) {
|
||||
if (predicate(array[length], length, array)) {
|
||||
return length;
|
||||
@@ -3487,7 +3542,7 @@
|
||||
argsLength = arguments.length,
|
||||
caches = [],
|
||||
indexOf = getIndexOf(),
|
||||
prereq = createCache && indexOf === baseIndexOf;
|
||||
prereq = createCache && indexOf == baseIndexOf;
|
||||
|
||||
while (++argsIndex < argsLength) {
|
||||
var value = arguments[argsIndex];
|
||||
@@ -3691,7 +3746,7 @@
|
||||
length = array ? array.length : 0,
|
||||
result = [];
|
||||
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
if (predicate(value, index, array)) {
|
||||
@@ -3806,7 +3861,7 @@
|
||||
* // => 1
|
||||
*/
|
||||
function sortedIndex(array, value, iterator, thisArg) {
|
||||
iterator = iterator == null ? identity : lodash.callback(iterator, thisArg, 1);
|
||||
iterator = iterator == null ? identity : getCallback(iterator, thisArg, 1);
|
||||
return baseSortedIndex(array, value, iterator);
|
||||
}
|
||||
|
||||
@@ -3832,7 +3887,7 @@
|
||||
* // => 4
|
||||
*/
|
||||
function sortedLastIndex(array, value, iterator, thisArg) {
|
||||
iterator = iterator == null ? identity : lodash.callback(iterator, thisArg, 1);
|
||||
iterator = iterator == null ? identity : getCallback(iterator, thisArg, 1);
|
||||
return baseSortedIndex(array, value, iterator, true);
|
||||
}
|
||||
|
||||
@@ -3941,7 +3996,7 @@
|
||||
var length = array ? array.length : 0,
|
||||
index = length;
|
||||
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
while (index-- && predicate(array[index], index, array)) { }
|
||||
return slice(array, index + 1);
|
||||
}
|
||||
@@ -3989,7 +4044,7 @@
|
||||
var index = -1,
|
||||
length = array ? array.length : 0;
|
||||
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
while (++index < length && predicate(array[index], index, array)) { }
|
||||
return slice(array, 0, index);
|
||||
}
|
||||
@@ -4073,9 +4128,11 @@
|
||||
}
|
||||
}
|
||||
if (iterator != null) {
|
||||
iterator = lodash.callback(iterator, thisArg, 3);
|
||||
iterator = getCallback(iterator, thisArg, 3);
|
||||
}
|
||||
return baseUniq(array, isSorted, iterator);
|
||||
return (isSorted && getIndexOf() == baseIndexOf)
|
||||
? sortedUniq(array, iterator)
|
||||
: baseUniq(array, iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4180,7 +4237,7 @@
|
||||
|
||||
/**
|
||||
* Creates an object composed from arrays of property names and values. Provide
|
||||
* either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`
|
||||
* either a single two dimensional array, e.g. `[[key1, value1], [key2, value2]]`
|
||||
* or two arrays, one of property names and one of corresponding values.
|
||||
*
|
||||
* @static
|
||||
@@ -4413,8 +4470,7 @@
|
||||
? nativeContains.call(collection, target, fromIndex)
|
||||
: collection.indexOf(target, fromIndex) > -1;
|
||||
}
|
||||
var indexOf = getIndexOf();
|
||||
return indexOf(collection, target, fromIndex) > -1;
|
||||
return getIndexOf(collection, target, fromIndex) > -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4498,7 +4554,7 @@
|
||||
*/
|
||||
function every(collection, predicate, thisArg) {
|
||||
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
}
|
||||
var func = isArray(collection) ? arrayEvery : baseEvery;
|
||||
return func(collection, predicate);
|
||||
@@ -4545,7 +4601,7 @@
|
||||
* // => [{ 'name': 'barney', 'age': 36 }]
|
||||
*/
|
||||
function filter(collection, predicate, thisArg) {
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
|
||||
var func = isArray(collection) ? arrayFilter : baseFilter;
|
||||
return func(collection, predicate);
|
||||
@@ -4599,7 +4655,7 @@
|
||||
var index = findIndex(collection, predicate, thisArg);
|
||||
return index > -1 ? collection[index] : undefined;
|
||||
}
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
return baseFind(collection, predicate, baseEach);
|
||||
}
|
||||
|
||||
@@ -4622,7 +4678,7 @@
|
||||
* // => 3
|
||||
*/
|
||||
function findLast(collection, predicate, thisArg) {
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
return baseFind(collection, predicate, baseEachRight);
|
||||
}
|
||||
|
||||
@@ -4861,7 +4917,7 @@
|
||||
* // => ['barney', 'fred']
|
||||
*/
|
||||
function map(collection, iterator, thisArg) {
|
||||
iterator = lodash.callback(iterator, thisArg, 3);
|
||||
iterator = getCallback(iterator, thisArg, 3);
|
||||
|
||||
var func = isArray(collection) ? arrayMap : baseMap;
|
||||
return func(collection, iterator);
|
||||
@@ -4919,20 +4975,25 @@
|
||||
if ((type == 'number' || type == 'string') && thisArg && thisArg[iterator] === collection) {
|
||||
iterator = null;
|
||||
}
|
||||
if (iterator == null && isArray(collection)) {
|
||||
var noIterator = iterator == null,
|
||||
isArr = noIterator && isArray(collection),
|
||||
isStr = !isArr && isString(collection);
|
||||
|
||||
if (noIterator && !isStr) {
|
||||
var index = -1,
|
||||
length = collection.length;
|
||||
iterable = toIterable(collection),
|
||||
length = iterable.length;
|
||||
|
||||
while (++index < length) {
|
||||
var value = collection[index];
|
||||
var value = iterable[index];
|
||||
if (value > result) {
|
||||
result = value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
iterator = (iterator == null && isString(collection))
|
||||
iterator = (noIterator && isStr)
|
||||
? charAtCallback
|
||||
: lodash.callback(iterator, thisArg, 3);
|
||||
: getCallback(iterator, thisArg, 3);
|
||||
|
||||
baseEach(collection, function(value, index, collection) {
|
||||
var current = iterator(value, index, collection);
|
||||
@@ -4997,20 +5058,25 @@
|
||||
if ((type == 'number' || type == 'string') && thisArg && thisArg[iterator] === collection) {
|
||||
iterator = null;
|
||||
}
|
||||
if (iterator == null && isArray(collection)) {
|
||||
var noIterator = iterator == null,
|
||||
isArr = noIterator && isArray(collection),
|
||||
isStr = !isArr && isString(collection);
|
||||
|
||||
if (noIterator && !isStr) {
|
||||
var index = -1,
|
||||
length = collection.length;
|
||||
iterable = toIterable(collection),
|
||||
length = iterable.length;
|
||||
|
||||
while (++index < length) {
|
||||
var value = collection[index];
|
||||
var value = iterable[index];
|
||||
if (value < result) {
|
||||
result = value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
iterator = (iterator == null && isString(collection))
|
||||
iterator = (noIterator && isStr)
|
||||
? charAtCallback
|
||||
: lodash.callback(iterator, thisArg, 3);
|
||||
: getCallback(iterator, thisArg, 3);
|
||||
|
||||
baseEach(collection, function(value, index, collection) {
|
||||
var current = iterator(value, index, collection);
|
||||
@@ -5124,7 +5190,7 @@
|
||||
*/
|
||||
function reduce(collection, iterator, accumulator, thisArg) {
|
||||
var func = isArray(collection) ? arrayReduce : baseReduce;
|
||||
return func(collection, lodash.callback(iterator, thisArg, 4), accumulator, arguments.length < 3, baseEach);
|
||||
return func(collection, getCallback(iterator, thisArg, 4), accumulator, arguments.length < 3, baseEach);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5148,7 +5214,7 @@
|
||||
*/
|
||||
function reduceRight(collection, iterator, accumulator, thisArg) {
|
||||
var func = isArray(collection) ? arrayReduceRight : baseReduce;
|
||||
return func(collection, lodash.callback(iterator, thisArg, 4), accumulator, arguments.length < 3, baseEachRight);
|
||||
return func(collection, getCallback(iterator, thisArg, 4), accumulator, arguments.length < 3, baseEachRight);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5190,7 +5256,7 @@
|
||||
* // => [{ 'name': 'fred', 'age': 40, 'blocked': true }]
|
||||
*/
|
||||
function reject(collection, predicate, thisArg) {
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
return filter(collection, negate(predicate));
|
||||
}
|
||||
|
||||
@@ -5327,7 +5393,7 @@
|
||||
*/
|
||||
function some(collection, predicate, thisArg) {
|
||||
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
}
|
||||
var func = isArray(collection) ? arraySome : baseSome;
|
||||
return func(collection, predicate);
|
||||
@@ -5392,7 +5458,7 @@
|
||||
result.length = length;
|
||||
}
|
||||
if (!multi) {
|
||||
iterator = lodash.callback(iterator, thisArg, 3);
|
||||
iterator = getCallback(iterator, thisArg, 3);
|
||||
}
|
||||
baseEach(collection, function(value, key, collection) {
|
||||
if (multi) {
|
||||
@@ -6488,7 +6554,7 @@
|
||||
* // => 'fred'
|
||||
*/
|
||||
function findKey(object, predicate, thisArg) {
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
return baseFind(object, predicate, baseForOwn, true);
|
||||
}
|
||||
|
||||
@@ -6534,7 +6600,7 @@
|
||||
* // => 'pebbles'
|
||||
*/
|
||||
function findLastKey(object, predicate, thisArg) {
|
||||
predicate = lodash.callback(predicate, thisArg, 3);
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
return baseFind(object, predicate, baseForOwnRight, true);
|
||||
}
|
||||
|
||||
@@ -6740,7 +6806,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is an `arguments` object.
|
||||
* Checks if `value` is classified as an `arguments` object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -6762,19 +6828,20 @@
|
||||
// fallback for environments without a `[[Class]]` for `arguments` objects
|
||||
if (!support.argsClass) {
|
||||
isArguments = function(value) {
|
||||
return (value && typeof value == 'object' && typeof value.length == 'number' &&
|
||||
var length = (value && typeof value == 'object') ? value.length : undefined;
|
||||
return (typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER &&
|
||||
hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee')) || false;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is an array.
|
||||
* Checks if `value` is classified as an `Array` object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isArray([1, 2, 3]);
|
||||
@@ -6789,13 +6856,13 @@
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if `value` is a boolean value.
|
||||
* Checks if `value` is classified as a boolean primitive or object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a boolean value, else `false`.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isBoolean(false);
|
||||
@@ -6810,13 +6877,13 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is a `Date` object.
|
||||
* Checks if `value` is classified as a `Date` object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a date object, else `false`.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isDate(new Date);
|
||||
@@ -6938,23 +7005,9 @@
|
||||
*/
|
||||
function isEqual(value, other, customizer, thisArg) {
|
||||
customizer = typeof customizer == 'function' && baseCallback(customizer, thisArg, 3);
|
||||
|
||||
if (!customizer) {
|
||||
// exit early for identical values
|
||||
if (value === other) {
|
||||
// treat `-0` vs. `+0` as not equal
|
||||
return value !== 0 || (1 / value == 1 / other);
|
||||
}
|
||||
var valType = typeof value,
|
||||
othType = typeof other;
|
||||
|
||||
// exit early for unlike primitive values
|
||||
if (value === value && (value == null || other == null ||
|
||||
(valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object'))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return baseIsEqual(value, other, customizer);
|
||||
return (!customizer && isStrictComparable(value) && isStrictComparable(other))
|
||||
? value === other
|
||||
: baseIsEqual(value, other, customizer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6979,7 +7032,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is a finite number.
|
||||
* Checks if `value` is a finite primitive number.
|
||||
*
|
||||
* Note: This method is based on ES6 `Number.isFinite`. See the
|
||||
* [ES6 spec](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite)
|
||||
@@ -6989,7 +7042,7 @@
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is finite, else `false`.
|
||||
* @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isFinite(10);
|
||||
@@ -7012,13 +7065,13 @@
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if `value` is a function.
|
||||
* Checks if `value` is classified as a `Function` object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isFunction(_);
|
||||
@@ -7121,16 +7174,16 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is a `Number` primitive or object.
|
||||
* Checks if `value` is classified as a `Number` primitive or object.
|
||||
*
|
||||
* Note: `NaN` is considered a number. See the [ES5 spec](http://es5.github.io/#x8.5)
|
||||
* for more details.
|
||||
* Note: To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified
|
||||
* as numbers, use the `_.isFinite` method.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a number, else `false`.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isNumber(8.4);
|
||||
@@ -7192,13 +7245,13 @@
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if `value` is a `RegExp` object.
|
||||
* Checks if `value` is classified as a `RegExp` object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a regexp object, else `false`.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isRegExp(/abc/);
|
||||
@@ -7212,13 +7265,13 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is a `String` primitive or object.
|
||||
* Checks if `value` is classified as a `String` primitive or object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a string, else `false`.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isString('abc');
|
||||
@@ -7398,7 +7451,7 @@
|
||||
*/
|
||||
function mapValues(object, iterator, thisArg) {
|
||||
var result = {};
|
||||
iterator = lodash.callback(iterator, thisArg, 3);
|
||||
iterator = getCallback(iterator, thisArg, 3);
|
||||
|
||||
baseForOwn(object, function(value, key, object) {
|
||||
result[key] = iterator(value, key, object);
|
||||
@@ -7491,7 +7544,7 @@
|
||||
return {};
|
||||
}
|
||||
if (typeof predicate == 'function') {
|
||||
return basePick(object, negate(lodash.callback(predicate, thisArg, 3)));
|
||||
return basePick(object, negate(getCallback(predicate, thisArg, 3)));
|
||||
}
|
||||
var omitProps = baseFlatten(arguments, false, false, 1);
|
||||
return basePick(Object(object), baseDifference(keysIn(object), arrayMap(omitProps, String)));
|
||||
@@ -7499,7 +7552,7 @@
|
||||
|
||||
/**
|
||||
* Creates a two dimensional array of a given object's key-value pairs,
|
||||
* i.e. `[[key1, value1], [key2, value2]]`.
|
||||
* e.g. `[[key1, value1], [key2, value2]]`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -7557,7 +7610,7 @@
|
||||
}
|
||||
return basePick(Object(object),
|
||||
typeof predicate == 'function'
|
||||
? lodash.callback(predicate, thisArg, 3)
|
||||
? getCallback(predicate, thisArg, 3)
|
||||
: baseFlatten(arguments, false, false, 1)
|
||||
);
|
||||
}
|
||||
@@ -7608,7 +7661,7 @@
|
||||
}
|
||||
}
|
||||
if (iterator) {
|
||||
iterator = lodash.callback(iterator, thisArg, 4);
|
||||
iterator = getCallback(iterator, thisArg, 4);
|
||||
(isArr ? arrayEach : baseForOwn)(object, function(value, index, object) {
|
||||
return iterator(accumulator, value, index, object);
|
||||
});
|
||||
@@ -7768,7 +7821,11 @@
|
||||
* // => 'fred, barney, & pebbles'
|
||||
*/
|
||||
function escape(string) {
|
||||
return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar);
|
||||
// reset `lastIndex` because in IE < 9 `String#replace` does not
|
||||
string = string == null ? '' : String(string);
|
||||
return (reUnescapedHtml.lastIndex = 0, reUnescapedHtml.test(string))
|
||||
? string.replace(reUnescapedHtml, escapeHtmlChar)
|
||||
: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -7786,7 +7843,10 @@
|
||||
* // => '\[lodash\]\(http://lodash\.com\)'
|
||||
*/
|
||||
function escapeRegExp(string) {
|
||||
return string == null ? '' : String(string).replace(reRegExpChars, '\\$&');
|
||||
string = string == null ? '' : String(string);
|
||||
return (reRegExpChars.lastIndex = 0, reRegExpChars.test(string))
|
||||
? string.replace(reRegExpChars, '\\$&')
|
||||
: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -7937,6 +7997,9 @@
|
||||
return result;
|
||||
}
|
||||
string = String(string);
|
||||
|
||||
// leverage the exponentiation by squaring algorithm for a faster repeat
|
||||
// http://en.wikipedia.org/wiki/Exponentiation_by_squaring
|
||||
do {
|
||||
if (n % 2) {
|
||||
result += string;
|
||||
@@ -8007,7 +8070,7 @@
|
||||
* properties may be accessed as free variables in the template. If a setting
|
||||
* object is provided it overrides `_.templateSettings` for the template.
|
||||
*
|
||||
* Note: In the development build, `_.template` utilizes sourceURLs for easier debugging.
|
||||
* Note: In the development build `_.template` utilizes sourceURLs for easier debugging.
|
||||
* See the [HTML5 Rocks article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
|
||||
* for more details.
|
||||
*
|
||||
@@ -8046,22 +8109,27 @@
|
||||
* compiled({ 'people': ['fred', 'barney'] });
|
||||
* // => '<li>fred</li><li>barney</li>'
|
||||
*
|
||||
* // using the ES6 delimiter as an alternative to the default "interpolate" delimiter
|
||||
* var compiled = _.template('hello ${ name }');
|
||||
* compiled({ 'name': 'pebbles' });
|
||||
* // => 'hello pebbles'
|
||||
*
|
||||
* // using the internal `print` function in "evaluate" delimiters
|
||||
* var compiled = _.template('<% print("hello " + name); %>!');
|
||||
* compiled({ 'name': 'barney' });
|
||||
* // => 'hello barney!'
|
||||
*
|
||||
* // using a custom template delimiters
|
||||
* // using the ES6 delimiter as an alternative to the default "interpolate" delimiter
|
||||
* var compiled = _.template('hello ${ name }');
|
||||
* compiled({ 'name': 'pebbles' });
|
||||
* // => 'hello pebbles'
|
||||
*
|
||||
* // using custom template delimiters
|
||||
* _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
|
||||
* var compiled = _.template('hello {{ name }}!');
|
||||
* compiled({ 'name': 'mustache' });
|
||||
* // => 'hello mustache!'
|
||||
*
|
||||
* // using backslashes to treat delimiters as plain text
|
||||
* var compiled = _.template('<%= "\\<%- value %\\>" %>');
|
||||
* compiled({ 'value': 'ignored' });
|
||||
* // => '<%- value %>'
|
||||
*
|
||||
* // using the `imports` option to import `jQuery` as `jq`
|
||||
* var text = '<% jq.each(people, function(name) { %><li><%- name %></li><% }); %>';
|
||||
* var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
|
||||
@@ -8377,11 +8445,10 @@
|
||||
* // => 'fred, barney & pebbles'
|
||||
*/
|
||||
function unescape(string) {
|
||||
if (string == null) {
|
||||
return '';
|
||||
}
|
||||
string = String(string);
|
||||
return string.indexOf(';') < 0 ? string : string.replace(reEscapedHtml, unescapeHtmlChar);
|
||||
string = string == null ? '' : String(string);
|
||||
return (reEscapedHtml.lastIndex = 0, reEscapedHtml.test(string))
|
||||
? string.replace(reEscapedHtml, unescapeHtmlChar)
|
||||
: string;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -8425,7 +8492,6 @@
|
||||
* @category Utility
|
||||
* @param {*} [func=identity] The value to convert to a callback.
|
||||
* @param {*} [thisArg] The `this` binding of the created callback.
|
||||
* @param {number} [argCount] The number of arguments the callback accepts.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
@@ -8435,9 +8501,12 @@
|
||||
* ];
|
||||
*
|
||||
* // wrap to create custom callback shorthands
|
||||
* _.callback = _.wrap(_.callback, function(func, callback, thisArg) {
|
||||
* var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
|
||||
* return !match ? func(callback, thisArg) : function(object) {
|
||||
* _.callback = _.wrap(_.callback, function(callback, func, thisArg) {
|
||||
* var match = /^(.+?)__([gl]t)(.+)$/.exec(func);
|
||||
* if (!match) {
|
||||
* return callback(func, thisArg);
|
||||
* }
|
||||
* return function(object) {
|
||||
* return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
|
||||
* };
|
||||
* });
|
||||
@@ -8445,18 +8514,8 @@
|
||||
* _.filter(characters, 'age__gt38');
|
||||
* // => [{ 'name': 'fred', 'age': 40 }]
|
||||
*/
|
||||
function callback(func, thisArg, argCount) {
|
||||
var type = typeof func,
|
||||
isFunc = type == 'function';
|
||||
|
||||
if (isFunc && typeof thisArg == 'undefined') {
|
||||
return func;
|
||||
}
|
||||
if (isFunc || func == null) {
|
||||
return baseCallback(func, thisArg, argCount);
|
||||
}
|
||||
// handle "_.pluck" and "_.where" style callback shorthands
|
||||
return type == 'object' ? matches(func) : property(func);
|
||||
function callback(func, thisArg) {
|
||||
return baseCallback(func, thisArg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -8525,17 +8584,28 @@
|
||||
*/
|
||||
function matches(source) {
|
||||
var props = keys(source),
|
||||
length = props.length,
|
||||
index = length,
|
||||
modes = Array(length),
|
||||
length = props.length;
|
||||
|
||||
if (length == 1) {
|
||||
var key = props[0],
|
||||
value = source[key];
|
||||
|
||||
if (isStrictComparable(value)) {
|
||||
return function(object) {
|
||||
return object != null && value === object[key] && hasOwnProperty.call(object, key);
|
||||
};
|
||||
}
|
||||
}
|
||||
var index = length,
|
||||
flags = Array(length),
|
||||
vals = Array(length);
|
||||
|
||||
while (index--) {
|
||||
var value = source[props[index]],
|
||||
isDeep = value !== value || (value === 0 && 1 / value < 0) || isObject(value);
|
||||
value = source[props[index]];
|
||||
var isStrict = isStrictComparable(value);
|
||||
|
||||
modes[index] = isDeep;
|
||||
vals[index] = isDeep ? baseClone(value, isDeep) : value;
|
||||
flags[index] = isStrict;
|
||||
vals[index] = isStrict ? value : baseClone(value, false);
|
||||
}
|
||||
return function(object) {
|
||||
index = length;
|
||||
@@ -8543,13 +8613,13 @@
|
||||
return !index;
|
||||
}
|
||||
while (index--) {
|
||||
if (modes[index] ? !hasOwnProperty.call(object, props[index]) : vals[index] !== object[props[index]]) {
|
||||
if (flags[index] ? vals[index] !== object[props[index]] : !hasOwnProperty.call(object, props[index])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
index = length;
|
||||
while (index--) {
|
||||
if (modes[index] ? !baseIsEqual(vals[index], object[props[index]], null, true) : !hasOwnProperty.call(object, props[index])) {
|
||||
if (flags[index] ? !hasOwnProperty.call(object, props[index]) : !baseIsEqual(vals[index], object[props[index]], null, true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user