Reduce deps in baseIsEqual, shimIsPlainObject, omit, & pick.

This commit is contained in:
John-David Dalton
2014-09-17 20:22:22 -07:00
parent c5841dccbb
commit 0350443810

View File

@@ -1739,15 +1739,14 @@
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
*/ */
function baseFor(object, iteratee, keysFunc) { function baseFor(object, iteratee, keysFunc) {
object = toObject(object);
var index = -1, var index = -1,
iterable = toObject(object),
props = keysFunc(object), props = keysFunc(object),
length = props.length; length = props.length;
while (++index < length) { while (++index < length) {
var key = props[index]; var key = props[index];
if (iteratee(object[key], key, object) === false) { if (iteratee(iterable[key], key, iterable) === false) {
break; break;
} }
} }
@@ -1765,14 +1764,13 @@
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
*/ */
function baseForRight(object, iteratee, keysFunc) { function baseForRight(object, iteratee, keysFunc) {
object = toObject(object); var iterable = toObject(object),
props = keysFunc(object),
var props = keysFunc(object),
length = props.length; length = props.length;
while (length--) { while (length--) {
var key = props[length]; var key = props[length];
if (iteratee(object[key], key, object) === false) { if (iteratee(iterable[key], key, iterable) === false) {
break; break;
} }
} }
@@ -1934,7 +1932,8 @@
if (!valHasCtor) { if (!valHasCtor) {
// non `Object` object instances with different constructors are not equal // non `Object` object instances with different constructors are not equal
if (valCtor != othCtor && if (valCtor != othCtor &&
!(isFunction(valCtor) && valCtor instanceof valCtor && isFunction(othCtor) && othCtor instanceof othCtor) && !(typeof valCtor == 'function' && valCtor instanceof valCtor &&
typeof othCtor == 'function' && othCtor instanceof othCtor) &&
('constructor' in value && 'constructor' in other) ('constructor' in value && 'constructor' in other)
) { ) {
return false; return false;
@@ -2924,7 +2923,7 @@
isArgs = className == argsClass || (!support.argsClass && isArguments(object)), isArgs = className == argsClass || (!support.argsClass && isArguments(object)),
isObj = className == objectClass; isObj = className == objectClass;
if (isObj && !(isFunction(Ctor) && (Ctor instanceof Ctor))) { if (isObj && !(typeof Ctor == 'function' && Ctor instanceof Ctor)) {
Ctor = Object; Ctor = Object;
} }
if (isArgs || isObj) { if (isArgs || isObj) {
@@ -2997,6 +2996,8 @@
* @returns {Object} Returns the new object. * @returns {Object} Returns the new object.
*/ */
function pickByArray(object, props) { function pickByArray(object, props) {
object = toObject(object);
var index = -1, var index = -1,
length = props.length, length = props.length,
result = {}; result = {};
@@ -3079,7 +3080,7 @@
if (!(value && typeof value == 'object' && if (!(value && typeof value == 'object' &&
toString.call(value) == objectClass && !isHostObject(value)) || toString.call(value) == objectClass && !isHostObject(value)) ||
(!hasOwnProperty.call(value, 'constructor') && (!hasOwnProperty.call(value, 'constructor') &&
(Ctor = value.constructor, isFunction(Ctor) && !(Ctor instanceof Ctor))) || (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor))) ||
(!support.argsClass && isArguments(value))) { (!support.argsClass && isArguments(value))) {
return false; return false;
} }
@@ -7623,18 +7624,16 @@
* // => ['x', 'y'] (iteration order is not guaranteed) * // => ['x', 'y'] (iteration order is not guaranteed)
*/ */
var keys = !nativeKeys ? shimKeys : function(object) { var keys = !nativeKeys ? shimKeys : function(object) {
if (object == null) { if (object) {
return []; var Ctor = object.constructor,
length = object.length;
} }
var Ctor = object.constructor,
length = object.length;
if ((Ctor && Ctor.prototype === object) || if ((Ctor && Ctor.prototype === object) ||
(typeof length == 'number' && length > 0) || (typeof length == 'number' && length > 0) ||
(support.enumPrototypes && typeof object == 'function')) { (support.enumPrototypes && typeof object == 'function')) {
return shimKeys(object); return shimKeys(object);
} }
return nativeKeys(toObject(object)); return isObject(object) ? nativeKeys(object) : [];
}; };
/** /**
@@ -7833,13 +7832,12 @@
if (object == null) { if (object == null) {
return {}; return {};
} }
var iterable = toObject(object);
if (typeof predicate != 'function') { if (typeof predicate != 'function') {
var props = arrayMap(baseFlatten(arguments, false, false, 1), String); var props = arrayMap(baseFlatten(arguments, false, false, 1), String);
return pickByArray(iterable, baseDifference(keysIn(iterable), props)); return pickByArray(object, baseDifference(keysIn(object), props));
} }
predicate = getCallback(predicate, thisArg, 3); predicate = getCallback(predicate, thisArg, 3);
return pickByCallback(iterable, function(value, key, object) { return pickByCallback(object, function(value, key, object) {
return !predicate(value, key, object); return !predicate(value, key, object);
}); });
} }
@@ -7902,10 +7900,9 @@
if (object == null) { if (object == null) {
return {}; return {};
} }
var iterable = toObject(object);
return typeof predicate == 'function' return typeof predicate == 'function'
? pickByCallback(iterable, getCallback(predicate, thisArg, 3)) ? pickByCallback(object, getCallback(predicate, thisArg, 3))
: pickByArray(iterable, baseFlatten(arguments, false, false, 1)); : pickByArray(object, baseFlatten(arguments, false, false, 1));
} }
/** /**