mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 03:47:50 +00:00
Fix perf regression in _.omit & _.reject.
This commit is contained in:
17
lodash.js
17
lodash.js
@@ -5437,8 +5437,12 @@
|
|||||||
* // => [{ 'name': 'fred', 'age': 40, 'blocked': true }]
|
* // => [{ 'name': 'fred', 'age': 40, 'blocked': true }]
|
||||||
*/
|
*/
|
||||||
function reject(collection, predicate, thisArg) {
|
function reject(collection, predicate, thisArg) {
|
||||||
|
var func = isArray(collection) ? arrayFilter : baseFilter;
|
||||||
|
|
||||||
predicate = getCallback(predicate, thisArg, 3);
|
predicate = getCallback(predicate, thisArg, 3);
|
||||||
return filter(collection, negate(predicate));
|
return func(collection, function(value, index, collection) {
|
||||||
|
return !predicate(value, index, collection);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -7732,9 +7736,14 @@
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
var iterable = toObject(object);
|
var iterable = toObject(object);
|
||||||
return typeof predicate == 'function'
|
if (typeof predicate != 'function') {
|
||||||
? pickByCallback(iterable, negate(getCallback(predicate, thisArg, 3)))
|
var props = arrayMap(baseFlatten(arguments, false, false, 1), String);
|
||||||
: pickByArray(iterable, baseDifference(keysIn(iterable), arrayMap(baseFlatten(arguments, false, false, 1), String)));
|
return pickByArray(iterable, baseDifference(keysIn(iterable), props));
|
||||||
|
}
|
||||||
|
predicate = getCallback(predicate, thisArg, 3);
|
||||||
|
return pickByCallback(iterable, function(value, key, object) {
|
||||||
|
return !predicate(value, key, object);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user