Bump to v3.8.0.

This commit is contained in:
John-David Dalton
2015-12-16 17:50:05 -08:00
parent fec213a98c
commit 26837e7fe2
58 changed files with 531 additions and 385 deletions

View File

@@ -1,7 +1,7 @@
define(['./baseCopy', './getSymbols', '../lang/isNative', '../object/keys'], function(baseCopy, getSymbols, isNative, keys) {
/** Native method references. */
var preventExtensions = isNative(Object.preventExtensions = Object.preventExtensions) && preventExtensions;
var preventExtensions = isNative(preventExtensions = Object.preventExtensions) && preventExtensions;
/** Used as `baseAssign`. */
var nativeAssign = (function() {
@@ -11,12 +11,19 @@ define(['./baseCopy', './getSymbols', '../lang/isNative', '../object/keys'], fun
//
// Use `Object.preventExtensions` on a plain object instead of simply using
// `Object('x')` because Chrome and IE fail to throw an error when attempting
// to assign values to readonly indexes of strings in strict mode.
var object = { '1': 0 },
func = preventExtensions && isNative(func = Object.assign) && func;
try { func(preventExtensions(object), 'xo'); } catch(e) {}
return !object[1] && func;
// to assign values to readonly indexes of strings.
var func = preventExtensions && isNative(func = Object.assign) && func;
try {
if (func) {
var object = preventExtensions({ '1': 0 });
object[0] = 1;
}
} catch(e) {
// Only attempt in strict mode.
try { func(object, 'xo'); } catch(e) {}
return !object[1] && func;
}
return false;
}());
/**

View File

@@ -1,4 +1,4 @@
define(['./isIndex', './isLength'], function(isIndex, isLength) {
define(['./isArrayLike', './isIndex'], function(isArrayLike, isIndex) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -14,8 +14,9 @@ define(['./isIndex', './isLength'], function(isIndex, isLength) {
*/
function baseAt(collection, props) {
var index = -1,
length = collection.length,
isArr = isLength(length),
isNil = collection == null,
isArr = !isNil && isArrayLike(collection),
length = isArr && collection.length,
propsLength = props.length,
result = Array(propsLength);
@@ -24,7 +25,7 @@ define(['./isIndex', './isLength'], function(isIndex, isLength) {
if (isArr) {
result[index] = isIndex(key, length) ? collection[key] : undefined;
} else {
result[index] = collection[key];
result[index] = isNil ? undefined : collection[key];
}
}
return result;

View File

@@ -1,4 +1,4 @@
define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'], function(isArguments, isArray, isLength, isObjectLike) {
define(['../lang/isArguments', '../lang/isArray', './isArrayLike', './isObjectLike'], function(isArguments, isArray, isArrayLike, isObjectLike) {
/**
* The base implementation of `_.flatten` with added support for restricting
@@ -6,8 +6,8 @@ define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'
*
* @private
* @param {Array} array The array to flatten.
* @param {boolean} isDeep Specify a deep flatten.
* @param {boolean} isStrict Restrict flattening to arrays and `arguments` objects.
* @param {boolean} [isDeep] Specify a deep flatten.
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
* @returns {Array} Returns the new flattened array.
*/
function baseFlatten(array, isDeep, isStrict) {
@@ -18,8 +18,8 @@ define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'
while (++index < length) {
var value = array[index];
if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) {
if (isObjectLike(value) && isArrayLike(value) &&
(isStrict || isArray(value) || isArguments(value))) {
if (isDeep) {
// Recursively flatten arrays (susceptible to call stack limits).
value = baseFlatten(value, isDeep, isStrict);
@@ -27,7 +27,6 @@ define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'
var valIndex = -1,
valLength = value.length;
result.length += valLength;
while (++valIndex < valLength) {
result[++resIndex] = value[valIndex];
}

View File

@@ -24,9 +24,9 @@ define(['./toObject'], function(toObject) {
length = path.length;
while (object != null && ++index < length) {
var result = object = object[path[index]];
object = object[path[index]];
}
return result;
return (index && index == length) ? object : undefined;
}
return baseGet;

View File

@@ -16,8 +16,7 @@ define(['./baseIsEqualDeep'], function(baseIsEqualDeep) {
function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
// Exit early for identical values.
if (value === other) {
// Treat `+0` vs. `-0` as not equal.
return value !== 0 || (1 / value == 1 / other);
return true;
}
var valType = typeof value,
othType = typeof other;

View File

@@ -1,4 +1,4 @@
define(['./baseEach', './getLength', './isLength'], function(baseEach, getLength, isLength) {
define(['./baseEach', './isArrayLike'], function(baseEach, isArrayLike) {
/**
* The base implementation of `_.map` without support for callback shorthands
@@ -11,8 +11,7 @@ define(['./baseEach', './getLength', './isLength'], function(baseEach, getLength
*/
function baseMap(collection, iteratee) {
var index = -1,
length = getLength(collection),
result = isLength(length) ? Array(length) : [];
result = isArrayLike(collection) ? Array(collection.length) : [];
baseEach(collection, function(value, key, collection) {
result[++index] = iteratee(value, key, collection);

View File

@@ -1,4 +1,4 @@
define(['./arrayEach', './baseMergeDeep', './getSymbols', '../lang/isArray', './isLength', '../lang/isObject', './isObjectLike', '../lang/isTypedArray', '../object/keys'], function(arrayEach, baseMergeDeep, getSymbols, isArray, isLength, isObject, isObjectLike, isTypedArray, keys) {
define(['./arrayEach', './baseMergeDeep', './getSymbols', '../lang/isArray', './isArrayLike', '../lang/isObject', './isObjectLike', '../lang/isTypedArray', '../object/keys'], function(arrayEach, baseMergeDeep, getSymbols, isArray, isArrayLike, isObject, isObjectLike, isTypedArray, keys) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -25,7 +25,7 @@ define(['./arrayEach', './baseMergeDeep', './getSymbols', '../lang/isArray', './
if (!isObject(object)) {
return object;
}
var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source));
var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source));
if (!isSrcArr) {
var props = keys(source);
push.apply(props, getSymbols(source));

View File

@@ -1,4 +1,4 @@
define(['./arrayCopy', './getLength', '../lang/isArguments', '../lang/isArray', './isLength', '../lang/isPlainObject', '../lang/isTypedArray', '../lang/toPlainObject'], function(arrayCopy, getLength, isArguments, isArray, isLength, isPlainObject, isTypedArray, toPlainObject) {
define(['./arrayCopy', '../lang/isArguments', '../lang/isArray', './isArrayLike', '../lang/isPlainObject', '../lang/isTypedArray', '../lang/toPlainObject'], function(arrayCopy, isArguments, isArray, isArrayLike, isPlainObject, isTypedArray, toPlainObject) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -34,10 +34,10 @@ define(['./arrayCopy', './getLength', '../lang/isArguments', '../lang/isArray',
if (isCommon) {
result = srcValue;
if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) {
if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {
result = isArray(value)
? value
: (getLength(value) ? arrayCopy(value) : []);
: (isArrayLike(value) ? arrayCopy(value) : []);
}
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
result = isArguments(value)

View File

@@ -16,7 +16,7 @@ define(['./isIndex'], function(isIndex) {
* @returns {Array} Returns `array`.
*/
function basePullAt(array, indexes) {
var length = indexes.length;
var length = array ? indexes.length : 0;
while (length--) {
var index = parseFloat(indexes[length]);
if (index != previous && isIndex(index)) {

View File

@@ -11,7 +11,7 @@ define([], function() {
/** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1,
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1;
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1;
/**
* This function is like `binaryIndex` except that it invokes `iteratee` for

View File

@@ -25,12 +25,12 @@ define([], function() {
while (++argsIndex < argsLength) {
result[argsIndex] = args[argsIndex];
}
var pad = argsIndex;
var offset = argsIndex;
while (++rightIndex < rightLength) {
result[pad + rightIndex] = partials[rightIndex];
result[offset + rightIndex] = partials[rightIndex];
}
while (++holdersIndex < holdersLength) {
result[pad + holders[holdersIndex]] = args[argsIndex++];
result[offset + holders[holdersIndex]] = args[argsIndex++];
}
return result;
}

View File

@@ -19,7 +19,7 @@ define(['./baseCallback', './baseFind', './baseFindIndex', '../lang/isArray'], f
return index > -1 ? collection[index] : undefined;
}
return baseFind(collection, predicate, eachFunc);
}
};
}
return createFind;

View File

@@ -1,5 +1,11 @@
define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './isLaziable'], function(LodashWrapper, getData, getFuncName, isArray, isLaziable) {
/** Used to compose bitmasks for wrapper metadata. */
var CURRY_FLAG = 8,
PARTIAL_FLAG = 32,
ARY_FLAG = 128,
REARG_FLAG = 256;
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
@@ -35,7 +41,7 @@ define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './i
funcName = getFuncName(func);
var data = funcName == 'wrapper' ? getData(func) : null;
if (data && isLaziable(data[0])) {
if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
} else {
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);

View File

@@ -0,0 +1,26 @@
define(['./baseCallback', './baseForOwn'], function(baseCallback, baseForOwn) {
/**
* Creates a function for `_.mapKeys` or `_.mapValues`.
*
* @private
* @param {boolean} [isMapKeys] Specify mapping keys instead of values.
* @returns {Function} Returns the new map function.
*/
function createObjectMapper(isMapKeys) {
return function(object, iteratee, thisArg) {
var result = {};
iteratee = baseCallback(iteratee, thisArg, 3);
baseForOwn(object, function(value, key, object) {
var mapped = iteratee(value, key, object);
key = isMapKeys ? mapped : key;
value = isMapKeys ? value : mapped;
result[key] = value;
});
return result;
};
}
return createObjectMapper;
});

View File

@@ -10,7 +10,7 @@ define(['./baseToString', './createPadding'], function(baseToString, createPaddi
function createPadDir(fromRight) {
return function(string, length, chars) {
string = baseToString(string);
return string && ((fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string));
return (fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string);
};
}

View File

@@ -36,8 +36,7 @@ define([], function() {
// Treat `NaN` vs. `NaN` as equal.
return (object != +object)
? other != +other
// But, treat `-0` vs. `+0` as not equal.
: (object == 0 ? ((1 / object) == (1 / other)) : object == +other);
: object == +other;
case regexpTag:
case stringTag:

View File

@@ -4,7 +4,7 @@ define(['./baseProperty'], function(baseProperty) {
* Gets the "length" property value of `object`.
*
* **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
* in Safari on iOS 8.1 ARM64.
* that affects Safari on at least iOS 8.1-8.3 ARM64.
*
* @private
* @param {Object} object The object to query.

15
internal/isArrayLike.js Normal file
View File

@@ -0,0 +1,15 @@
define(['./getLength', './isLength'], function(getLength, isLength) {
/**
* Checks if `value` is array-like.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
*/
function isArrayLike(value) {
return value != null && isLength(getLength(value));
}
return isArrayLike;
});

View File

@@ -1,4 +1,4 @@
define(['./getLength', './isIndex', './isLength', '../lang/isObject'], function(getLength, isIndex, isLength, isObject) {
define(['./isArrayLike', './isIndex', '../lang/isObject'], function(isArrayLike, isIndex, isObject) {
/**
* Checks if the provided arguments are from an iteratee call.
@@ -14,13 +14,9 @@ define(['./getLength', './isIndex', './isLength', '../lang/isObject'], function(
return false;
}
var type = typeof index;
if (type == 'number') {
var length = getLength(object),
prereq = isLength(length) && isIndex(index, length);
} else {
prereq = type == 'string' && index in object;
}
if (prereq) {
if (type == 'number'
? (isArrayLike(object) && isIndex(index, object.length))
: (type == 'string' && index in object)) {
var other = object[index];
return value === value ? (value === other) : (other !== other);
}

View File

@@ -1,7 +1,7 @@
define(['../lang/isArray', './toObject'], function(isArray, toObject) {
/** Used to match property names within property paths. */
var reIsDeepProp = /\.|\[(?:[^[\]]+|(["'])(?:(?!\1)[^\n\\]|\\.)*?)\1\]/,
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,
reIsPlainProp = /^\w*$/;
/**

View File

@@ -9,7 +9,7 @@ define(['../lang/isObject'], function(isObject) {
* equality comparisons, else `false`.
*/
function isStrictComparable(value) {
return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value));
return value === value && !isObject(value);
}
return isStrictComparable;

View File

@@ -1,7 +1,7 @@
define(['./toObject'], function(toObject) {
/**
* A specialized version of `_.pick` that picks `object` properties specified
* A specialized version of `_.pick` which picks `object` properties specified
* by `props`.
*
* @private

View File

@@ -1,7 +1,7 @@
define(['./baseForIn'], function(baseForIn) {
/**
* A specialized version of `_.pick` that picks `object` properties `predicate`
* A specialized version of `_.pick` which picks `object` properties `predicate`
* returns truthy for.
*
* @private

View File

@@ -1,4 +1,4 @@
define(['./getLength', './isLength', '../lang/isObject', '../object/values'], function(getLength, isLength, isObject, values) {
define(['./isArrayLike', '../lang/isObject', '../object/values'], function(isArrayLike, isObject, values) {
/**
* Converts `value` to an array-like object if it is not one.
@@ -11,7 +11,7 @@ define(['./getLength', './isLength', '../lang/isObject', '../object/values'], fu
if (value == null) {
return [];
}
if (!isLength(getLength(value))) {
if (!isArrayLike(value)) {
return values(value);
}
return isObject(value) ? value : Object(value);