mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 01:17:50 +00:00
Bump to v3.6.0.
This commit is contained in:
@@ -2,19 +2,14 @@ import baseIsMatch from '../internal/baseIsMatch';
|
||||
import bindCallback from '../internal/bindCallback';
|
||||
import isStrictComparable from '../internal/isStrictComparable';
|
||||
import keys from '../object/keys';
|
||||
|
||||
/** Used for native method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
import toObject from '../internal/toObject';
|
||||
|
||||
/**
|
||||
* Performs a deep comparison between `object` and `source` to determine if
|
||||
* `object` contains equivalent property values. If `customizer` is provided
|
||||
* it is invoked to compare values. If `customizer` returns `undefined`
|
||||
* comparisons are handled by the method instead. The `customizer` is bound
|
||||
* to `thisArg` and invoked with three arguments; (value, other, index|key).
|
||||
* to `thisArg` and invoked with three arguments: (value, other, index|key).
|
||||
*
|
||||
* **Note:** This method supports comparing properties of arrays, booleans,
|
||||
* `Date` objects, numbers, `Object` objects, regexes, and strings. Functions
|
||||
@@ -52,13 +47,19 @@ function isMatch(object, source, customizer, thisArg) {
|
||||
var props = keys(source),
|
||||
length = props.length;
|
||||
|
||||
if (!length) {
|
||||
return true;
|
||||
}
|
||||
if (object == null) {
|
||||
return false;
|
||||
}
|
||||
customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3);
|
||||
if (!customizer && length == 1) {
|
||||
var key = props[0],
|
||||
value = source[key];
|
||||
|
||||
if (isStrictComparable(value)) {
|
||||
return object != null && value === object[key] && hasOwnProperty.call(object, key);
|
||||
return value === object[key] && (typeof value != 'undefined' || (key in toObject(object)));
|
||||
}
|
||||
}
|
||||
var values = Array(length),
|
||||
@@ -68,7 +69,7 @@ function isMatch(object, source, customizer, thisArg) {
|
||||
value = values[length] = source[props[length]];
|
||||
strictCompareFlags[length] = isStrictComparable(value);
|
||||
}
|
||||
return baseIsMatch(object, props, values, strictCompareFlags, customizer);
|
||||
return baseIsMatch(toObject(object), props, values, strictCompareFlags, customizer);
|
||||
}
|
||||
|
||||
export default isMatch;
|
||||
|
||||
Reference in New Issue
Block a user