Creates a function that performs a partial deep comparison between a given object and `source`, returning `true` if the given object has equivalent property values, else `false`. **Note:** The created function is equivalent to `isMatch` with `source` partially applied. Partial comparisons will match empty array and empty object `source` values against any array or object value, respectively. See `isEqual` for a list of supported value comparisons.
const objects = [
{ 'a': 1, 'b': 2, 'c': 3 },
{ 'a': 4, 'b': 5, 'c': 6 }
]
filter(objects, matches({ 'a': 4, 'c': 6 }))
// => [{ 'a': 4, 'b': 5, 'c': 6 }]
| Name | Type | Attribute | Description |
|---|---|---|---|
| source | The object of property values to match. |
{
"comment": "/**\r\n * Creates a function that performs a partial deep comparison between a given\r\n * object and `source`, returning `true` if the given object has equivalent\r\n * property values, else `false`.\r\n *\r\n * **Note:** The created function is equivalent to `isMatch` with `source`\r\n * partially applied.\r\n *\r\n * Partial comparisons will match empty array and empty object `source`\r\n * values against any array or object value, respectively. See `isEqual`\r\n * for a list of supported value comparisons.\r\n *\r\n * @since 3.0.0\r\n * @category Util\r\n * @param {Object} source The object of property values to match.\r\n * @returns {Function} Returns the new spec function.\r\n * @example\r\n *\r\n * const objects = [\r\n * { 'a': 1, 'b': 2, 'c': 3 },\r\n * { 'a': 4, 'b': 5, 'c': 6 }\r\n * ]\r\n *\r\n * filter(objects, matches({ 'a': 4, 'c': 6 }))\r\n * // => [{ 'a': 4, 'b': 5, 'c': 6 }]\r\n */",
"meta": {
"range": [
1049,
1136
],
"filename": "matches.js",
"lineno": 33,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100005917",
"name": "matches",
"type": "FunctionDeclaration",
"paramnames": [
"source"
]
}
},
"description": "Creates a function that performs a partial deep comparison between a given\robject and `source`, returning `true` if the given object has equivalent\rproperty values, else `false`.\r\r**Note:** The created function is equivalent to `isMatch` with `source`\rpartially applied.\r\rPartial comparisons will match empty array and empty object `source`\rvalues against any array or object value, respectively. See `isEqual`\rfor a list of supported value comparisons.",
"since": "3.0.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "Util",
"value": "Util"
}
],
"params": [
{
"type": {
"names": [
"Object"
]
},
"description": "The object of property values to match.",
"name": "source"
}
],
"returns": [
{
"type": {
"names": [
"function"
]
},
"description": "Returns the new spec function."
}
],
"examples": [
"const objects = [\r { 'a': 1, 'b': 2, 'c': 3 },\r { 'a': 4, 'b': 5, 'c': 6 }\r]\r\rfilter(objects, matches({ 'a': 4, 'c': 6 }))\r// => [{ 'a': 4, 'b': 5, 'c': 6 }]"
],
"name": "matches",
"longname": "matches",
"kind": "function",
"scope": "global",
"___id": "T000002R000550",
"___s": true,
"filepath": "matches.js"
}