Bump to v3.8.0.

This commit is contained in:
jdalton
2015-04-29 21:07:42 -07:00
parent 5eb8db31d7
commit d7b2bedafc
58 changed files with 300 additions and 194 deletions

View File

@@ -4,7 +4,7 @@ import isNative from '../lang/isNative';
import keys from '../object/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() {
@@ -14,12 +14,19 @@ var nativeAssign = (function() {
//
// 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,5 +1,5 @@
import isArrayLike from './isArrayLike';
import isIndex from './isIndex';
import isLength from './isLength';
/**
* The base implementation of `_.at` without support for string collections
@@ -12,8 +12,9 @@ import isLength from './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);
@@ -22,7 +23,7 @@ function baseAt(collection, props) {
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,6 +1,6 @@
import isArguments from '../lang/isArguments';
import isArray from '../lang/isArray';
import isLength from './isLength';
import isArrayLike from './isArrayLike';
import isObjectLike from './isObjectLike';
/**
@@ -9,8 +9,8 @@ import isObjectLike from './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) {
@@ -21,8 +21,8 @@ function baseFlatten(array, isDeep, isStrict) {
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);
@@ -30,7 +30,6 @@ function baseFlatten(array, isDeep, isStrict) {
var valIndex = -1,
valLength = value.length;
result.length += valLength;
while (++valIndex < valLength) {
result[++resIndex] = value[valIndex];
}

View File

@@ -21,9 +21,9 @@ function baseGet(object, path, pathKey) {
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;
}
export default baseGet;

View File

@@ -16,8 +16,7 @@ import baseIsEqualDeep from './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,6 +1,5 @@
import baseEach from './baseEach';
import getLength from './getLength';
import isLength from './isLength';
import isArrayLike from './isArrayLike';
/**
* The base implementation of `_.map` without support for callback shorthands
@@ -13,8 +12,7 @@ import isLength from './isLength';
*/
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

@@ -2,7 +2,7 @@ import arrayEach from './arrayEach';
import baseMergeDeep from './baseMergeDeep';
import getSymbols from './getSymbols';
import isArray from '../lang/isArray';
import isLength from './isLength';
import isArrayLike from './isArrayLike';
import isObject from '../lang/isObject';
import isObjectLike from './isObjectLike';
import isTypedArray from '../lang/isTypedArray';
@@ -30,7 +30,7 @@ function baseMerge(object, source, customizer, stackA, stackB) {
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,8 +1,7 @@
import arrayCopy from './arrayCopy';
import getLength from './getLength';
import isArguments from '../lang/isArguments';
import isArray from '../lang/isArray';
import isLength from './isLength';
import isArrayLike from './isArrayLike';
import isPlainObject from '../lang/isPlainObject';
import isTypedArray from '../lang/isTypedArray';
import toPlainObject from '../lang/toPlainObject';
@@ -38,10 +37,10 @@ function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stack
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 @@ var splice = arrayProto.splice;
* @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

@@ -6,7 +6,7 @@ var nativeMin = Math.min;
/** 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

@@ -23,12 +23,12 @@ function composeArgsRight(args, partials, holders) {
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 @@ function createFind(eachFunc, fromRight) {
return index > -1 ? collection[index] : undefined;
}
return baseFind(collection, predicate, eachFunc);
}
};
}
export default createFind;

View File

@@ -4,6 +4,12 @@ import getFuncName from './getFuncName';
import isArray from '../lang/isArray';
import isLaziable from './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';
@@ -39,7 +45,7 @@ function createFlow(fromRight) {
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 @@
import baseCallback from './baseCallback';
import baseForOwn from './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;
};
}
export default createObjectMapper;

View File

@@ -11,7 +11,7 @@ import createPadding from './createPadding';
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

@@ -34,8 +34,7 @@ function equalByTag(object, other, tag) {
// 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 @@ import baseProperty from './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 @@
import getLength from './getLength';
import isLength from './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));
}
export default isArrayLike;

View File

@@ -1,6 +1,5 @@
import getLength from './getLength';
import isArrayLike from './isArrayLike';
import isIndex from './isIndex';
import isLength from './isLength';
import isObject from '../lang/isObject';
/**
@@ -17,13 +16,9 @@ function isIterateeCall(value, index, object) {
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

@@ -2,7 +2,7 @@ import isArray from '../lang/isArray';
import toObject from './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 @@ import isObject from '../lang/isObject';
* equality comparisons, else `false`.
*/
function isStrictComparable(value) {
return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value));
return value === value && !isObject(value);
}
export default isStrictComparable;

View File

@@ -1,7 +1,7 @@
import toObject from './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 @@
import baseForIn from './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,5 +1,4 @@
import getLength from './getLength';
import isLength from './isLength';
import isArrayLike from './isArrayLike';
import isObject from '../lang/isObject';
import values from '../object/values';
@@ -14,7 +13,7 @@ function toIterable(value) {
if (value == null) {
return [];
}
if (!isLength(getLength(value))) {
if (!isArrayLike(value)) {
return values(value);
}
return isObject(value) ? value : Object(value);