Compare commits

...

4 Commits

Author SHA1 Message Date
John-David Dalton
b58a63eff1 Bump to v4.16.5. 2016-10-30 20:06:57 -07:00
John-David Dalton
52a75b18e4 Bump to v4.16.4. 2016-10-05 19:29:32 -07:00
John-David Dalton
0961d6edde Bump to v4.16.3. 2016-10-02 21:51:40 -07:00
John-David Dalton
2f8450b523 Bump to v4.16.2. 2016-09-25 13:37:46 -07:00
149 changed files with 905 additions and 713 deletions

View File

@@ -1,4 +1,4 @@
Copyright jQuery Foundation and other contributors <https://jquery.org/>
Copyright JS Foundation and other contributors <https://js.foundation/>
Based on Underscore.js, copyright Jeremy Ashkenas,
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>

View File

@@ -1,4 +1,4 @@
# lodash-amd v4.16.1
# lodash-amd v4.16.5
The [Lodash](https://lodash.com/) library exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
@@ -27,4 +27,4 @@ require({
});
```
See the [package source](https://github.com/lodash/lodash/tree/4.16.1-amd) for more details.
See the [package source](https://github.com/lodash/lodash/tree/4.16.5-amd) for more details.

View File

@@ -9,7 +9,7 @@ define(['./_hashClear', './_hashDelete', './_hashGet', './_hashHas', './_hashSet
*/
function Hash(entries) {
var index = -1,
length = entries ? entries.length : 0;
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {

View File

@@ -9,7 +9,7 @@ define(['./_listCacheClear', './_listCacheDelete', './_listCacheGet', './_listCa
*/
function ListCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {

View File

@@ -9,7 +9,7 @@ define(['./_mapCacheClear', './_mapCacheDelete', './_mapCacheGet', './_mapCacheH
*/
function MapCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {

View File

@@ -10,7 +10,7 @@ define(['./_MapCache', './_setCacheAdd', './_setCacheHas'], function(MapCache, s
*/
function SetCache(values) {
var index = -1,
length = values ? values.length : 0;
length = values == null ? 0 : values.length;
this.__data__ = new MapCache;
while (++index < length) {

View File

@@ -12,7 +12,7 @@ define([], function() {
*/
function arrayAggregator(array, setter, iteratee, accumulator) {
var index = -1,
length = array ? array.length : 0;
length = array == null ? 0 : array.length;
while (++index < length) {
var value = array[index];

View File

@@ -11,7 +11,7 @@ define([], function() {
*/
function arrayEach(array, iteratee) {
var index = -1,
length = array ? array.length : 0;
length = array == null ? 0 : array.length;
while (++index < length) {
if (iteratee(array[index], index, array) === false) {

View File

@@ -10,7 +10,7 @@ define([], function() {
* @returns {Array} Returns `array`.
*/
function arrayEachRight(array, iteratee) {
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
while (length--) {
if (iteratee(array[length], length, array) === false) {

View File

@@ -12,7 +12,7 @@ define([], function() {
*/
function arrayEvery(array, predicate) {
var index = -1,
length = array ? array.length : 0;
length = array == null ? 0 : array.length;
while (++index < length) {
if (!predicate(array[index], index, array)) {

View File

@@ -11,7 +11,7 @@ define([], function() {
*/
function arrayFilter(array, predicate) {
var index = -1,
length = array ? array.length : 0,
length = array == null ? 0 : array.length,
resIndex = 0,
result = [];

View File

@@ -10,7 +10,7 @@ define(['./_baseIndexOf'], function(baseIndexOf) {
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludes(array, value) {
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
return !!length && baseIndexOf(array, value, 0) > -1;
}

View File

@@ -11,7 +11,7 @@ define([], function() {
*/
function arrayIncludesWith(array, value, comparator) {
var index = -1,
length = array ? array.length : 0;
length = array == null ? 0 : array.length;
while (++index < length) {
if (comparator(value, array[index])) {

View File

@@ -1,4 +1,4 @@
define(['./_baseTimes', './isArguments', './isArray', './_isIndex'], function(baseTimes, isArguments, isArray, isIndex) {
define(['./_baseTimes', './isArguments', './isArray', './isBuffer', './_isIndex', './isTypedArray'], function(baseTimes, isArguments, isArray, isBuffer, isIndex, isTypedArray) {
/** Used for built-in method references. */
var objectProto = Object.prototype;
@@ -15,18 +15,26 @@ define(['./_baseTimes', './isArguments', './isArray', './_isIndex'], function(ba
* @returns {Array} Returns the array of property names.
*/
function arrayLikeKeys(value, inherited) {
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
// Safari 9 makes `arguments.length` enumerable in strict mode.
var result = (isArray(value) || isArguments(value))
? baseTimes(value.length, String)
: [];
var length = result.length,
skipIndexes = !!length;
var isArr = isArray(value),
isArg = !isArr && isArguments(value),
isBuff = !isArr && !isArg && isBuffer(value),
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
skipIndexes = isArr || isArg || isBuff || isType,
result = skipIndexes ? baseTimes(value.length, String) : [],
length = result.length;
for (var key in value) {
if ((inherited || hasOwnProperty.call(value, key)) &&
!(skipIndexes && (key == 'length' || isIndex(key, length)))) {
!(skipIndexes && (
// Safari 9 has enumerable `arguments.length` in strict mode.
key == 'length' ||
// Node.js 0.10 has enumerable non-index properties on buffers.
(isBuff && (key == 'offset' || key == 'parent')) ||
// PhantomJS 2 has enumerable non-index properties on typed arrays.
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
// Skip index properties.
isIndex(key, length)
))) {
result.push(key);
}
}

View File

@@ -11,7 +11,7 @@ define([], function() {
*/
function arrayMap(array, iteratee) {
var index = -1,
length = array ? array.length : 0,
length = array == null ? 0 : array.length,
result = Array(length);
while (++index < length) {

View File

@@ -14,7 +14,7 @@ define([], function() {
*/
function arrayReduce(array, iteratee, accumulator, initAccum) {
var index = -1,
length = array ? array.length : 0;
length = array == null ? 0 : array.length;
if (initAccum && length) {
accumulator = array[++index];

View File

@@ -13,7 +13,7 @@ define([], function() {
* @returns {*} Returns the accumulated value.
*/
function arrayReduceRight(array, iteratee, accumulator, initAccum) {
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
if (initAccum && length) {
accumulator = array[--length];
}

View File

@@ -4,8 +4,7 @@ define(['./_baseRandom'], function(baseRandom) {
var undefined;
/**
* A specialized version of `_.sample` for arrays without support for iteratee
* shorthands.
* A specialized version of `_.sample` for arrays.
*
* @private
* @param {Array} array The array to sample.

View File

@@ -1,4 +1,4 @@
define(['./_arrayShuffle', './_baseClamp'], function(arrayShuffle, baseClamp) {
define(['./_baseClamp', './_copyArray', './_shuffleSelf'], function(baseClamp, copyArray, shuffleSelf) {
/**
* A specialized version of `_.sampleSize` for arrays.
@@ -9,9 +9,7 @@ define(['./_arrayShuffle', './_baseClamp'], function(arrayShuffle, baseClamp) {
* @returns {Array} Returns the random elements.
*/
function arraySampleSize(array, n) {
var result = arrayShuffle(array);
result.length = baseClamp(n, 0, result.length);
return result;
return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
}
return arraySampleSize;

View File

@@ -12,7 +12,7 @@ define([], function() {
*/
function arraySome(array, predicate) {
var index = -1,
length = array ? array.length : 0;
length = array == null ? 0 : array.length;
while (++index < length) {
if (predicate(array[index], index, array)) {

View File

@@ -14,7 +14,7 @@ define(['./_baseAssignValue', './eq'], function(baseAssignValue, eq) {
*/
function assignMergeValue(object, key, value) {
if ((value !== undefined && !eq(object[key], value)) ||
(typeof key == 'number' && value === undefined && !(key in object))) {
(value === undefined && !(key in object))) {
baseAssignValue(object, key, value);
}
}

View File

@@ -1,7 +1,4 @@
define([], function() {
/** Built-in value references. */
var defineProperty = Object.defineProperty;
define(['./_defineProperty'], function(defineProperty) {
/**
* The base implementation of `assignValue` and `assignMergeValue` without

View File

@@ -13,12 +13,12 @@ define(['./get'], function(get) {
*/
function baseAt(object, paths) {
var index = -1,
isNil = object == null,
length = paths.length,
result = Array(length);
result = Array(length),
skip = object == null;
while (++index < length) {
result[index] = isNil ? undefined : get(object, paths[index]);
result[index] = skip ? undefined : get(object, paths[index]);
}
return result;
}

View File

@@ -106,9 +106,7 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_clone
}
stack.set(value, result);
if (!isArr) {
var props = isFull ? getAllKeys(value) : keys(value);
}
var props = isArr ? undefined : (isFull ? getAllKeys : keys)(value);
arrayEach(props || value, function(subValue, key) {
if (props) {
key = subValue;

View File

@@ -1,5 +1,8 @@
define(['./isObject'], function(isObject) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Built-in value references. */
var objectCreate = Object.create;
@@ -8,12 +11,24 @@ define(['./isObject'], function(isObject) {
* properties to the created object.
*
* @private
* @param {Object} prototype The object to inherit from.
* @param {Object} proto The object to inherit from.
* @returns {Object} Returns the new object.
*/
function baseCreate(proto) {
return isObject(proto) ? objectCreate(proto) : {};
}
var baseCreate = (function() {
function object() {}
return function(proto) {
if (!isObject(proto)) {
return {};
}
if (objectCreate) {
return objectCreate(proto);
}
object.prototype = proto;
var result = new object;
object.prototype = undefined;
return result;
};
}());
return baseCreate;
});

View File

@@ -3,7 +3,7 @@ define([], function() {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -40,7 +40,7 @@ define(['./_SetCache', './_arrayIncludes', './_arrayIncludesWith', './_arrayMap'
outer:
while (++index < length) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
computed = iteratee == null ? value : iteratee(value);
value = (comparator || value !== 0) ? value : 0;
if (isCommon && computed === computed) {

View File

@@ -1,24 +1,30 @@
define([], function() {
define(['./_Symbol', './_getRawTag', './_objectToString'], function(Symbol, getRawTag, objectToString) {
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** `Object#toString` result references. */
var nullTag = '[object Null]',
undefinedTag = '[object Undefined]';
/** Built-in value references. */
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* The base implementation of `getTag`.
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
return objectToString.call(value);
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
value = Object(value);
return (symToStringTag && symToStringTag in value)
? getRawTag(value)
: objectToString(value);
}
return baseGetTag;

18
_baseIsArguments.js Normal file
View File

@@ -0,0 +1,18 @@
define(['./_baseGetTag', './isObjectLike'], function(baseGetTag, isObjectLike) {
/** `Object#toString` result references. */
var argsTag = '[object Arguments]';
/**
* The base implementation of `_.isArguments`.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
*/
function baseIsArguments(value) {
return isObjectLike(value) && baseGetTag(value) == argsTag;
}
return baseIsArguments;
});

View File

@@ -1,17 +1,7 @@
define(['./isObjectLike'], function(isObjectLike) {
define(['./_baseGetTag', './isObjectLike'], function(baseGetTag, isObjectLike) {
var arrayBufferTag = '[object ArrayBuffer]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* The base implementation of `_.isArrayBuffer` without Node.js optimizations.
*
@@ -20,7 +10,7 @@ define(['./isObjectLike'], function(isObjectLike) {
* @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
*/
function baseIsArrayBuffer(value) {
return isObjectLike(value) && objectToString.call(value) == arrayBufferTag;
return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
}
return baseIsArrayBuffer;

View File

@@ -1,18 +1,8 @@
define(['./isObjectLike'], function(isObjectLike) {
define(['./_baseGetTag', './isObjectLike'], function(baseGetTag, isObjectLike) {
/** `Object#toString` result references. */
var dateTag = '[object Date]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* The base implementation of `_.isDate` without Node.js optimizations.
*
@@ -21,7 +11,7 @@ define(['./isObjectLike'], function(isObjectLike) {
* @returns {boolean} Returns `true` if `value` is a date object, else `false`.
*/
function baseIsDate(value) {
return isObjectLike(value) && objectToString.call(value) == dateTag;
return isObjectLike(value) && baseGetTag(value) == dateTag;
}
return baseIsDate;

View File

@@ -1,4 +1,4 @@
define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_getTag', './isArray', './isTypedArray'], function(Stack, equalArrays, equalByTag, equalObjects, getTag, isArray, isTypedArray) {
define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_getTag', './isArray', './isBuffer', './isTypedArray'], function(Stack, equalArrays, equalByTag, equalObjects, getTag, isArray, isBuffer, isTypedArray) {
/** Used to compose bitmasks for comparison styles. */
var PARTIAL_COMPARE_FLAG = 2;
@@ -47,6 +47,13 @@ define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_ge
othIsObj = othTag == objectTag,
isSameTag = objTag == othTag;
if (isSameTag && isBuffer(object)) {
if (!isBuffer(other)) {
return false;
}
objIsArr = true;
objIsObj = false;
}
if (isSameTag && !objIsObj) {
stack || (stack = new Stack);
return (objIsArr || isTypedArray(object))

View File

@@ -1,18 +1,8 @@
define(['./isObject'], function(isObject) {
define(['./_baseGetTag', './isObjectLike'], function(baseGetTag, isObjectLike) {
/** `Object#toString` result references. */
var regexpTag = '[object RegExp]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* The base implementation of `_.isRegExp` without Node.js optimizations.
*
@@ -21,7 +11,7 @@ define(['./isObject'], function(isObject) {
* @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
*/
function baseIsRegExp(value) {
return isObject(value) && objectToString.call(value) == regexpTag;
return isObjectLike(value) && baseGetTag(value) == regexpTag;
}
return baseIsRegExp;

View File

@@ -1,4 +1,4 @@
define(['./isLength', './isObjectLike'], function(isLength, isObjectLike) {
define(['./_baseGetTag', './isLength', './isObjectLike'], function(baseGetTag, isLength, isObjectLike) {
/** `Object#toString` result references. */
var argsTag = '[object Arguments]',
@@ -43,16 +43,6 @@ define(['./isLength', './isObjectLike'], function(isLength, isObjectLike) {
typedArrayTags[setTag] = typedArrayTags[stringTag] =
typedArrayTags[weakMapTag] = false;
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* The base implementation of `_.isTypedArray` without Node.js optimizations.
*
@@ -62,7 +52,7 @@ define(['./isLength', './isObjectLike'], function(isLength, isObjectLike) {
*/
function baseIsTypedArray(value) {
return isObjectLike(value) &&
isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
}
return baseIsTypedArray;

View File

@@ -13,7 +13,7 @@ define(['./_baseSum'], function(baseSum) {
* @returns {number} Returns the mean.
*/
function baseMean(array, iteratee) {
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
return length ? (baseSum(array, iteratee) / length) : NAN;
}

View File

@@ -1,4 +1,4 @@
define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseKeysIn', './_baseMergeDeep', './isArray', './isObject', './isTypedArray'], function(Stack, arrayEach, assignMergeValue, baseKeysIn, baseMergeDeep, isArray, isObject, isTypedArray) {
define(['./_Stack', './_assignMergeValue', './_baseFor', './_baseMergeDeep', './isObject', './keysIn'], function(Stack, assignMergeValue, baseFor, baseMergeDeep, isObject, keysIn) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -18,14 +18,7 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseKeysIn', './_
if (object === source) {
return;
}
if (!(isArray(source) || isTypedArray(source))) {
var props = baseKeysIn(source);
}
arrayEach(props || source, function(srcValue, key) {
if (props) {
key = srcValue;
srcValue = source[key];
}
baseFor(source, function(srcValue, key) {
if (isObject(srcValue)) {
stack || (stack = new Stack);
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
@@ -40,7 +33,7 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseKeysIn', './_
}
assignMergeValue(object, key, newValue);
}
});
}, keysIn);
}
return baseMerge;

View File

@@ -1,4 +1,4 @@
define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments', './isArray', './isArrayLikeObject', './isFunction', './isObject', './isPlainObject', './isTypedArray', './toPlainObject'], function(assignMergeValue, baseClone, copyArray, isArguments, isArray, isArrayLikeObject, isFunction, isObject, isPlainObject, isTypedArray, toPlainObject) {
define(['./_assignMergeValue', './_cloneBuffer', './_cloneTypedArray', './_copyArray', './_initCloneObject', './isArguments', './isArray', './isArrayLikeObject', './isBuffer', './isFunction', './isObject', './isPlainObject', './isTypedArray', './toPlainObject'], function(assignMergeValue, cloneBuffer, cloneTypedArray, copyArray, initCloneObject, isArguments, isArray, isArrayLikeObject, isBuffer, isFunction, isObject, isPlainObject, isTypedArray, toPlainObject) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -34,29 +34,37 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
var isCommon = newValue === undefined;
if (isCommon) {
var isArr = isArray(srcValue),
isBuff = !isArr && isBuffer(srcValue),
isTyped = !isArr && !isBuff && isTypedArray(srcValue);
newValue = srcValue;
if (isArray(srcValue) || isTypedArray(srcValue)) {
if (isArr || isBuff || isTyped) {
if (isArray(objValue)) {
newValue = objValue;
}
else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue);
}
else {
else if (isBuff) {
isCommon = false;
newValue = baseClone(srcValue, true);
newValue = cloneBuffer(srcValue, true);
}
else if (isTyped) {
isCommon = false;
newValue = cloneTypedArray(srcValue, true);
}
else {
newValue = [];
}
}
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
newValue = objValue;
if (isArguments(objValue)) {
newValue = toPlainObject(objValue);
}
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
isCommon = false;
newValue = baseClone(srcValue, true);
}
else {
newValue = objValue;
newValue = initCloneObject(srcValue);
}
}
else {

15
_baseSample.js Normal file
View File

@@ -0,0 +1,15 @@
define(['./_arraySample', './values'], function(arraySample, values) {
/**
* The base implementation of `_.sample`.
*
* @private
* @param {Array|Object} collection The collection to sample.
* @returns {*} Returns the random element.
*/
function baseSample(collection) {
return arraySample(values(collection));
}
return baseSample;
});

17
_baseSampleSize.js Normal file
View File

@@ -0,0 +1,17 @@
define(['./_baseClamp', './_shuffleSelf', './values'], function(baseClamp, shuffleSelf, values) {
/**
* The base implementation of `_.sampleSize` without param guards.
*
* @private
* @param {Array|Object} collection The collection to sample.
* @param {number} n The number of elements to sample.
* @returns {Array} Returns the random elements.
*/
function baseSampleSize(collection, n) {
var array = values(collection);
return shuffleSelf(array, baseClamp(n, 0, array.length));
}
return baseSampleSize;
});

View File

@@ -1,4 +1,4 @@
define(['./constant', './identity', './_nativeDefineProperty'], function(constant, identity, nativeDefineProperty) {
define(['./constant', './_defineProperty', './identity'], function(constant, defineProperty, identity) {
/**
* The base implementation of `setToString` without support for hot loop shorting.
@@ -8,8 +8,8 @@ define(['./constant', './identity', './_nativeDefineProperty'], function(constan
* @param {Function} string The `toString` result.
* @returns {Function} Returns `func`.
*/
var baseSetToString = !nativeDefineProperty ? identity : function(func, string) {
return nativeDefineProperty(func, 'toString', {
var baseSetToString = !defineProperty ? identity : function(func, string) {
return defineProperty(func, 'toString', {
'configurable': true,
'enumerable': false,
'value': constant(string),

15
_baseShuffle.js Normal file
View File

@@ -0,0 +1,15 @@
define(['./_shuffleSelf', './values'], function(shuffleSelf, values) {
/**
* The base implementation of `_.shuffle`.
*
* @private
* @param {Array|Object} collection The collection to shuffle.
* @returns {Array} Returns the new shuffled array.
*/
function baseShuffle(collection) {
return shuffleSelf(values(collection));
}
return baseShuffle;
});

View File

@@ -18,7 +18,7 @@ define(['./_baseSortedIndexBy', './identity', './isSymbol'], function(baseSorted
*/
function baseSortedIndex(array, value, retHighest) {
var low = 0,
high = array ? array.length : low;
high = array == null ? low : array.length;
if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
while (low < high) {

View File

@@ -28,7 +28,7 @@ define(['./isSymbol'], function(isSymbol) {
value = iteratee(value);
var low = 0,
high = array ? array.length : 0,
high = array == null ? 0 : array.length,
valIsNaN = value !== value,
valIsNull = value === null,
valIsSymbol = isSymbol(value),

View File

@@ -1,4 +1,4 @@
define(['./_Symbol', './isSymbol'], function(Symbol, isSymbol) {
define(['./_Symbol', './_arrayMap', './isArray', './isSymbol'], function(Symbol, arrayMap, isArray, isSymbol) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -23,6 +23,10 @@ define(['./_Symbol', './isSymbol'], function(Symbol, isSymbol) {
if (typeof value == 'string') {
return value;
}
if (isArray(value)) {
// Recursively convert values (susceptible to call stack limits).
return arrayMap(value, baseToString) + '';
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : '';
}

View File

@@ -1,4 +1,4 @@
define(['./_arrayPush', './_baseDifference', './_baseUniq'], function(arrayPush, baseDifference, baseUniq) {
define(['./_baseDifference', './_baseFlatten', './_baseUniq'], function(baseDifference, baseFlatten, baseUniq) {
/**
* The base implementation of methods like `_.xor`, without support for
@@ -11,18 +11,25 @@ define(['./_arrayPush', './_baseDifference', './_baseUniq'], function(arrayPush,
* @returns {Array} Returns the new array of values.
*/
function baseXor(arrays, iteratee, comparator) {
var length = arrays.length;
if (length < 2) {
return length ? baseUniq(arrays[0]) : [];
}
var index = -1,
length = arrays.length;
result = Array(length);
while (++index < length) {
var result = result
? arrayPush(
baseDifference(result, arrays[index], iteratee, comparator),
baseDifference(arrays[index], result, iteratee, comparator)
)
: arrays[index];
var array = arrays[index],
othIndex = -1;
while (++othIndex < length) {
var othArray = arrays[othIndex];
if (othArray !== array) {
result[index] = baseDifference(result[index] || array, othArray, iteratee, comparator);
}
}
}
return (result && result.length) ? baseUniq(result, iteratee, comparator) : [];
return baseUniq(baseFlatten(result, 1), iteratee, comparator);
}
return baseXor;

View File

@@ -1,4 +1,20 @@
define([], function() {
define(['./_root'], function(root) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Detect free variable `exports`. */
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = freeModule && freeModule.exports === freeExports;
/** Built-in value references. */
var Buffer = moduleExports ? root.Buffer : undefined,
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
/**
* Creates a clone of `buffer`.
@@ -12,7 +28,9 @@ define([], function() {
if (isDeep) {
return buffer.slice();
}
var result = new buffer.constructor(buffer.length);
var length = buffer.length,
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
buffer.copy(result);
return result;
}

View File

@@ -6,7 +6,7 @@ define(['./_LodashWrapper', './_flatRest', './_getData', './_getFuncName', './is
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to compose bitmasks for function metadata. */

View File

@@ -3,7 +3,7 @@ define(['./_baseSetData', './_createBind', './_createCurry', './_createHybrid',
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to compose bitmasks for function metadata. */

12
_defineProperty.js Normal file
View File

@@ -0,0 +1,12 @@
define(['./_getNative'], function(getNative) {
var defineProperty = (function() {
try {
var func = getNative(Object, 'defineProperty');
func({}, '', {});
return func;
} catch (e) {}
}());
return defineProperty;
});

50
_getRawTag.js Normal file
View File

@@ -0,0 +1,50 @@
define(['./_Symbol'], function(Symbol) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = objectProto.toString;
/** Built-in value references. */
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
/**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/
function getRawTag(value) {
var isOwn = hasOwnProperty.call(value, symToStringTag),
tag = value[symToStringTag];
try {
value[symToStringTag] = undefined;
var unmasked = true;
} catch (e) {}
var result = nativeObjectToString.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag] = tag;
} else {
delete value[symToStringTag];
}
}
return result;
}
return getRawTag;
});

View File

@@ -12,16 +12,6 @@ define(['./_DataView', './_Map', './_Promise', './_Set', './_WeakMap', './_baseG
var dataViewTag = '[object DataView]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/** Used to detect maps, sets, and weakmaps. */
var dataViewCtorString = toSource(DataView),
mapCtorString = toSource(Map),
@@ -45,9 +35,9 @@ define(['./_DataView', './_Map', './_Promise', './_Set', './_WeakMap', './_baseG
(Set && getTag(new Set) != setTag) ||
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
getTag = function(value) {
var result = objectToString.call(value),
var result = baseGetTag(value),
Ctor = result == objectTag ? value.constructor : undefined,
ctorString = Ctor ? toSource(Ctor) : undefined;
ctorString = Ctor ? toSource(Ctor) : '';
if (ctorString) {
switch (ctorString) {

View File

@@ -26,7 +26,7 @@ define(['./_castPath', './isArguments', './isArray', './_isIndex', './_isKey', '
if (result || ++index != length) {
return result;
}
length = object ? object.length : 0;
length = object == null ? 0 : object.length;
return !!length && isLength(length) && isIndex(key, length) &&
(isArray(object) || isArguments(object));
}

View File

@@ -1,7 +0,0 @@
define(['./_getNative'], function(getNative) {
/* Built-in method references that are verified to be native. */
var nativeDefineProperty = getNative(Object, 'defineProperty');
return nativeDefineProperty;
});

25
_objectToString.js Normal file
View File

@@ -0,0 +1,25 @@
define([], function() {
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = objectProto.toString;
/**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/
function objectToString(value) {
return nativeObjectToString.call(value);
}
return objectToString;
});

View File

@@ -4,7 +4,7 @@ define([], function() {
var undefined;
/** Used to detect hot functions by number of calls within a span of milliseconds. */
var HOT_COUNT = 500,
var HOT_COUNT = 800,
HOT_SPAN = 16;
/* Built-in method references for those with the same name as other `lodash` methods. */

View File

@@ -1,24 +1,30 @@
define(['./_baseRandom'], function(baseRandom) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* A specialized version of `arrayShuffle` which mutates `array`.
* A specialized version of `_.shuffle` which mutates and sets the size of `array`.
*
* @private
* @param {Array} array The array to shuffle.
* @param {number} [size=array.length] The size of `array`.
* @returns {Array} Returns `array`.
*/
function shuffleSelf(array) {
function shuffleSelf(array, size) {
var index = -1,
length = array.length,
lastIndex = length - 1;
while (++index < length) {
size = size === undefined ? length : size;
while (++index < size) {
var rand = baseRandom(index, lastIndex),
value = array[rand];
array[rand] = array[index];
array[index] = value;
}
array.length = size;
return array;
}

View File

@@ -10,7 +10,7 @@ define([], function() {
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to process.
* @param {Function} func The function to convert.
* @returns {string} Returns the source code.
*/
function toSource(func) {

View File

@@ -31,22 +31,26 @@ define([], function() {
rsZWJ = '\\u200d';
/** Used to compose unicode regexes. */
var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
reOptMod = rsModifier + '?',
rsOptVar = '[' + rsVarRange + ']?',
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',
rsSeq = rsOptVar + reOptMod + rsOptJoin,
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
/** Used to match complex or compound words. */
var reUnicodeWord = RegExp([
rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr,
rsUpper + '+' + rsOptUpperContr,
rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
rsUpper + '+' + rsOptContrUpper,
rsOrdUpper,
rsOrdLower,
rsDigits,
rsEmoji
].join('|'), 'g');

View File

@@ -1,6 +1,6 @@
define(['./toInteger'], function(toInteger) {
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -3,7 +3,7 @@ define(['./toInteger'], function(toInteger) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -34,7 +34,7 @@ define(['./_baseSlice', './_isIterateeCall', './toInteger'], function(baseSlice,
} else {
size = nativeMax(toInteger(size), 0);
}
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
if (!length || size < 1) {
return [];
}

View File

@@ -1,5 +1,8 @@
define(['./_baseClone'], function(baseClone) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* This method is like `_.cloneWith` except that it recursively clones `value`.
*
@@ -29,6 +32,7 @@ define(['./_baseClone'], function(baseClone) {
* // => 20
*/
function cloneDeepWith(value, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
return baseClone(value, true, true, customizer);
}

View File

@@ -1,5 +1,8 @@
define(['./_baseClone'], function(baseClone) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* This method is like `_.clone` except that it accepts `customizer` which
* is invoked to produce the cloned value. If `customizer` returns `undefined`,
@@ -32,6 +35,7 @@ define(['./_baseClone'], function(baseClone) {
* // => 0
*/
function cloneWith(value, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
return baseClone(value, false, true, customizer);
}

View File

@@ -17,7 +17,7 @@ define([], function() {
*/
function compact(array) {
var index = -1,
length = array ? array.length : 0,
length = array == null ? 0 : array.length,
resIndex = 0,
result = [];

View File

@@ -1,6 +1,6 @@
define(['./_apply', './_arrayMap', './_baseIteratee', './_baseRest'], function(apply, arrayMap, baseIteratee, baseRest) {
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**
@@ -33,7 +33,7 @@ define(['./_apply', './_arrayMap', './_baseIteratee', './_baseRest'], function(a
* // => 'no match'
*/
function cond(pairs) {
var length = pairs ? pairs.length : 0,
var length = pairs == null ? 0 : pairs.length,
toIteratee = baseIteratee;
pairs = !length ? [] : arrayMap(pairs, function(pair) {

View File

@@ -17,8 +17,7 @@ define(['./_baseAssignValue', './_createAggregator'], function(baseAssignValue,
* @since 0.5.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity]
* The iteratee to transform keys.
* @param {Function} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*

View File

@@ -36,7 +36,7 @@ define(['./_baseAssign', './_baseCreate'], function(baseAssign, baseCreate) {
*/
function create(prototype, properties) {
var result = baseCreate(prototype);
return properties ? baseAssign(result, properties) : result;
return properties == null ? result : baseAssign(result, properties);
}
return create;

View File

@@ -3,7 +3,7 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/* Built-in method references for those with the same name as other `lodash` methods. */

View File

@@ -29,7 +29,7 @@ define(['./_baseSlice', './toInteger'], function(baseSlice, toInteger) {
* // => [1, 2, 3]
*/
function drop(array, n, guard) {
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}

View File

@@ -29,7 +29,7 @@ define(['./_baseSlice', './toInteger'], function(baseSlice, toInteger) {
* // => [1, 2, 3]
*/
function dropRight(array, n, guard) {
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}

View File

@@ -10,8 +10,7 @@ define(['./_baseIteratee', './_baseWhile'], function(baseIteratee, baseWhile) {
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
* @param {Function} [predicate=_.identity]
* The function invoked per iteration.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the slice of `array`.
* @example
*

View File

@@ -18,8 +18,7 @@ define(['./_arrayEvery', './_baseEvery', './_baseIteratee', './isArray', './_isI
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [predicate=_.identity]
* The function invoked per iteration.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {boolean} Returns `true` if all elements pass the predicate check,
* else `false`.

View File

@@ -30,7 +30,7 @@ define(['./_baseFill', './_isIterateeCall'], function(baseFill, isIterateeCall)
* // => [4, '*', '*', 10]
*/
function fill(array, value, start, end) {
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}

View File

@@ -12,8 +12,7 @@ define(['./_arrayFilter', './_baseFilter', './_baseIteratee', './isArray'], func
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [predicate=_.identity]
* The function invoked per iteration.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new filtered array.
* @see _.reject
* @example

View File

@@ -10,8 +10,7 @@ define(['./_createFind', './findIndex'], function(createFind, findIndex) {
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to inspect.
* @param {Function} [predicate=_.identity]
* The function invoked per iteration.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param {number} [fromIndex=0] The index to search from.
* @returns {*} Returns the matched element, else `undefined`.
* @example

View File

@@ -12,8 +12,7 @@ define(['./_baseFindIndex', './_baseIteratee', './toInteger'], function(baseFind
* @since 1.1.0
* @category Array
* @param {Array} array The array to inspect.
* @param {Function} [predicate=_.identity]
* The function invoked per iteration.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param {number} [fromIndex=0] The index to search from.
* @returns {number} Returns the index of the found element, else `-1`.
* @example
@@ -40,7 +39,7 @@ define(['./_baseFindIndex', './_baseIteratee', './toInteger'], function(baseFind
* // => 2
*/
function findIndex(array, predicate, fromIndex) {
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}

View File

@@ -9,8 +9,7 @@ define(['./_createFind', './findLastIndex'], function(createFind, findLastIndex)
* @since 2.0.0
* @category Collection
* @param {Array|Object} collection The collection to inspect.
* @param {Function} [predicate=_.identity]
* The function invoked per iteration.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param {number} [fromIndex=collection.length-1] The index to search from.
* @returns {*} Returns the matched element, else `undefined`.
* @example

View File

@@ -16,8 +16,7 @@ define(['./_baseFindIndex', './_baseIteratee', './toInteger'], function(baseFind
* @since 2.0.0
* @category Array
* @param {Array} array The array to inspect.
* @param {Function} [predicate=_.identity]
* The function invoked per iteration.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param {number} [fromIndex=array.length-1] The index to search from.
* @returns {number} Returns the index of the found element, else `-1`.
* @example
@@ -44,7 +43,7 @@ define(['./_baseFindIndex', './_baseIteratee', './toInteger'], function(baseFind
* // => 0
*/
function findLastIndex(array, predicate, fromIndex) {
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}

View File

@@ -10,8 +10,7 @@ define(['./_baseFlatten', './map'], function(baseFlatten, map) {
* @since 4.0.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity]
* The function invoked per iteration.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new flattened array.
* @example
*

View File

@@ -12,8 +12,7 @@ define(['./_baseFlatten', './map'], function(baseFlatten, map) {
* @since 4.7.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity]
* The function invoked per iteration.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new flattened array.
* @example
*

View File

@@ -12,8 +12,7 @@ define(['./_baseFlatten', './map', './toInteger'], function(baseFlatten, map, to
* @since 4.7.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity]
* The function invoked per iteration.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @param {number} [depth=1] The maximum recursion depth.
* @returns {Array} Returns the new flattened array.
* @example

View File

@@ -15,7 +15,7 @@ define(['./_baseFlatten'], function(baseFlatten) {
* // => [1, 2, [3, [4]], 5]
*/
function flatten(array) {
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
return length ? baseFlatten(array, 1) : [];
}

View File

@@ -18,7 +18,7 @@ define(['./_baseFlatten'], function(baseFlatten) {
* // => [1, 2, 3, 4, 5]
*/
function flattenDeep(array) {
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
return length ? baseFlatten(array, INFINITY) : [];
}

View File

@@ -24,7 +24,7 @@ define(['./_baseFlatten', './toInteger'], function(baseFlatten, toInteger) {
* // => [1, 2, 3, [4], 5]
*/
function flattenDepth(array, depth) {
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}

View File

@@ -1,4 +1,4 @@
define(['./_arrayEach', './_baseEach', './_baseIteratee', './isArray'], function(arrayEach, baseEach, baseIteratee, isArray) {
define(['./_arrayEach', './_baseEach', './_castFunction', './isArray'], function(arrayEach, baseEach, castFunction, isArray) {
/**
* Iterates over elements of `collection` and invokes `iteratee` for each element.
@@ -32,7 +32,7 @@ define(['./_arrayEach', './_baseEach', './_baseIteratee', './isArray'], function
*/
function forEach(collection, iteratee) {
var func = isArray(collection) ? arrayEach : baseEach;
return func(collection, baseIteratee(iteratee, 3));
return func(collection, castFunction(iteratee));
}
return forEach;

View File

@@ -1,4 +1,4 @@
define(['./_arrayEachRight', './_baseEachRight', './_baseIteratee', './isArray'], function(arrayEachRight, baseEachRight, baseIteratee, isArray) {
define(['./_arrayEachRight', './_baseEachRight', './_castFunction', './isArray'], function(arrayEachRight, baseEachRight, castFunction, isArray) {
/**
* This method is like `_.forEach` except that it iterates over elements of
@@ -22,7 +22,7 @@ define(['./_arrayEachRight', './_baseEachRight', './_baseIteratee', './isArray']
*/
function forEachRight(collection, iteratee) {
var func = isArray(collection) ? arrayEachRight : baseEachRight;
return func(collection, baseIteratee(iteratee, 3));
return func(collection, castFunction(iteratee));
}
return forEachRight;

View File

@@ -1,4 +1,4 @@
define(['./_baseFor', './_baseIteratee', './keysIn'], function(baseFor, baseIteratee, keysIn) {
define(['./_baseFor', './_castFunction', './keysIn'], function(baseFor, castFunction, keysIn) {
/**
* Iterates over own and inherited enumerable string keyed properties of an
@@ -31,7 +31,7 @@ define(['./_baseFor', './_baseIteratee', './keysIn'], function(baseFor, baseIter
function forIn(object, iteratee) {
return object == null
? object
: baseFor(object, baseIteratee(iteratee, 3), keysIn);
: baseFor(object, castFunction(iteratee), keysIn);
}
return forIn;

View File

@@ -1,4 +1,4 @@
define(['./_baseForRight', './_baseIteratee', './keysIn'], function(baseForRight, baseIteratee, keysIn) {
define(['./_baseForRight', './_castFunction', './keysIn'], function(baseForRight, castFunction, keysIn) {
/**
* This method is like `_.forIn` except that it iterates over properties of
@@ -29,7 +29,7 @@ define(['./_baseForRight', './_baseIteratee', './keysIn'], function(baseForRight
function forInRight(object, iteratee) {
return object == null
? object
: baseForRight(object, baseIteratee(iteratee, 3), keysIn);
: baseForRight(object, castFunction(iteratee), keysIn);
}
return forInRight;

View File

@@ -1,4 +1,4 @@
define(['./_baseForOwn', './_baseIteratee'], function(baseForOwn, baseIteratee) {
define(['./_baseForOwn', './_castFunction'], function(baseForOwn, castFunction) {
/**
* Iterates over own enumerable string keyed properties of an object and
@@ -29,7 +29,7 @@ define(['./_baseForOwn', './_baseIteratee'], function(baseForOwn, baseIteratee)
* // => Logs 'a' then 'b' (iteration order is not guaranteed).
*/
function forOwn(object, iteratee) {
return object && baseForOwn(object, baseIteratee(iteratee, 3));
return object && baseForOwn(object, castFunction(iteratee));
}
return forOwn;

View File

@@ -1,4 +1,4 @@
define(['./_baseForOwnRight', './_baseIteratee'], function(baseForOwnRight, baseIteratee) {
define(['./_baseForOwnRight', './_castFunction'], function(baseForOwnRight, castFunction) {
/**
* This method is like `_.forOwn` except that it iterates over properties of
@@ -27,7 +27,7 @@ define(['./_baseForOwnRight', './_baseIteratee'], function(baseForOwnRight, base
* // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
*/
function forOwnRight(object, iteratee) {
return object && baseForOwnRight(object, baseIteratee(iteratee, 3));
return object && baseForOwnRight(object, castFunction(iteratee));
}
return forOwnRight;

View File

@@ -17,7 +17,7 @@ define([], function() {
*/
function fromPairs(pairs) {
var index = -1,
length = pairs ? pairs.length : 0,
length = pairs == null ? 0 : pairs.length,
result = {};
while (++index < length) {

View File

@@ -18,8 +18,7 @@ define(['./_baseAssignValue', './_createAggregator'], function(baseAssignValue,
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity]
* The iteratee to transform keys.
* @param {Function} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*

View File

@@ -27,7 +27,7 @@ define(['./_baseIndexOf', './toInteger'], function(baseIndexOf, toInteger) {
* // => 3
*/
function indexOf(array, value, fromIndex) {
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}

View File

@@ -15,7 +15,7 @@ define(['./_baseSlice'], function(baseSlice) {
* // => [1, 2]
*/
function initial(array) {
var length = array ? array.length : 0;
var length = array == null ? 0 : array.length;
return length ? baseSlice(array, 0, -1) : [];
}

View File

@@ -28,9 +28,8 @@ define(['./_arrayMap', './_baseIntersection', './_baseRest', './_castArrayLikeOb
var comparator = last(arrays),
mapped = arrayMap(arrays, castArrayLikeObject);
if (comparator === last(mapped)) {
comparator = undefined;
} else {
comparator = typeof comparator == 'function' ? comparator : undefined;
if (comparator) {
mapped.pop();
}
return (mapped.length && mapped[0] === arrays[0])

View File

@@ -1,7 +1,4 @@
define(['./isArrayLikeObject'], function(isArrayLikeObject) {
/** `Object#toString` result references. */
var argsTag = '[object Arguments]';
define(['./_baseIsArguments', './isObjectLike'], function(baseIsArguments, isObjectLike) {
/** Used for built-in method references. */
var objectProto = Object.prototype;
@@ -9,13 +6,6 @@ define(['./isArrayLikeObject'], function(isArrayLikeObject) {
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/** Built-in value references. */
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
@@ -37,11 +27,10 @@ define(['./isArrayLikeObject'], function(isArrayLikeObject) {
* _.isArguments([1, 2, 3]);
* // => false
*/
function isArguments(value) {
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
(!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
}
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
!propertyIsEnumerable.call(value, 'callee');
};
return isArguments;
});

View File

@@ -1,18 +1,8 @@
define(['./isObjectLike'], function(isObjectLike) {
define(['./_baseGetTag', './isObjectLike'], function(baseGetTag, isObjectLike) {
/** `Object#toString` result references. */
var boolTag = '[object Boolean]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* Checks if `value` is classified as a boolean primitive or object.
*
@@ -32,7 +22,7 @@ define(['./isObjectLike'], function(isObjectLike) {
*/
function isBoolean(value) {
return value === true || value === false ||
(isObjectLike(value) && objectToString.call(value) == boolTag);
(isObjectLike(value) && baseGetTag(value) == boolTag);
}
return isBoolean;

View File

@@ -18,7 +18,7 @@ define(['./isObjectLike', './isPlainObject'], function(isObjectLike, isPlainObje
* // => false
*/
function isElement(value) {
return value != null && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
}
return isElement;

View File

@@ -1,4 +1,4 @@
define(['./_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer', './_isPrototype', './_nativeKeys'], function(getTag, isArguments, isArray, isArrayLike, isBuffer, isPrototype, nativeKeys) {
define(['./_baseKeys', './_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer', './_isPrototype', './isTypedArray'], function(baseKeys, getTag, isArguments, isArray, isArrayLike, isBuffer, isPrototype, isTypedArray) {
/** `Object#toString` result references. */
var mapTag = '[object Map]',
@@ -44,9 +44,12 @@ define(['./_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer'
* // => false
*/
function isEmpty(value) {
if (value == null) {
return true;
}
if (isArrayLike(value) &&
(isArray(value) || typeof value == 'string' ||
typeof value.splice == 'function' || isBuffer(value) || isArguments(value))) {
(isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
isBuffer(value) || isTypedArray(value) || isArguments(value))) {
return !value.length;
}
var tag = getTag(value);
@@ -54,7 +57,7 @@ define(['./_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer'
return !value.size;
}
if (isPrototype(value)) {
return !nativeKeys(value).length;
return !baseKeys(value).length;
}
for (var key in value) {
if (hasOwnProperty.call(value, key)) {

View File

@@ -1,17 +1,8 @@
define(['./isObjectLike'], function(isObjectLike) {
define(['./_baseGetTag', './isObjectLike', './isPlainObject'], function(baseGetTag, isObjectLike, isPlainObject) {
/** `Object#toString` result references. */
var errorTag = '[object Error]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
var domExcTag = '[object DOMException]',
errorTag = '[object Error]';
/**
* Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
@@ -35,8 +26,9 @@ define(['./isObjectLike'], function(isObjectLike) {
if (!isObjectLike(value)) {
return false;
}
return (objectToString.call(value) == errorTag) ||
(typeof value.message == 'string' && typeof value.name == 'string');
var tag = baseGetTag(value);
return tag == errorTag || tag == domExcTag ||
(typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
}
return isError;

Some files were not shown because too many files have changed in this diff Show More