Home

function: matchesProperty


matchesProperty(path: Array, string, srcValue: *): function

Creates a function that performs a partial deep comparison between the value at `path` of a given object to `srcValue`, returning `true` if the object value is equivalent, else `false`. **Note:** Partial comparisons will match empty array and empty object `srcValue` values against any array or object value, respectively. See `isEqual` for a list of supported value comparisons.

Example(s):

const objects = [
  { 'a': 1, 'b': 2, 'c': 3 },
  { 'a': 4, 'b': 5, 'c': 6 }
]

find(objects, matchesProperty('a', 4))
// => { 'a': 4, 'b': 5, 'c': 6 }

Params:

Name Type Attribute Description
path The path of the property to get.
srcValue The value to match.

Returns:

function

  {
    "comment": "/**\r\n * Creates a function that performs a partial deep comparison between the\r\n * value at `path` of a given object to `srcValue`, returning `true` if the\r\n * object value is equivalent, else `false`.\r\n *\r\n * **Note:** Partial comparisons will match empty array and empty object\r\n * `srcValue` values against any array or object value, respectively. See\r\n * `isEqual` for a list of supported value comparisons.\r\n *\r\n * @since 3.2.0\r\n * @category Util\r\n * @param {Array|string} path The path of the property to get.\r\n * @param {*} srcValue The value 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 * find(objects, matchesProperty('a', 4))\r\n * // => { 'a': 4, 'b': 5, 'c': 6 }\r\n */",
    "meta": {
        "range": [
            1014,
            1133
        ],
        "filename": "matchesProperty.js",
        "lineno": 31,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100005943",
            "name": "matchesProperty",
            "type": "FunctionDeclaration",
            "paramnames": [
                "path",
                "srcValue"
            ]
        }
    },
    "description": "Creates a function that performs a partial deep comparison between the\rvalue at `path` of a given object to `srcValue`, returning `true` if the\robject value is equivalent, else `false`.\r\r**Note:** Partial comparisons will match empty array and empty object\r`srcValue` values against any array or object value, respectively. See\r`isEqual` for a list of supported value comparisons.",
    "since": "3.2.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "Util",
            "value": "Util"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "Array",
                    "string"
                ]
            },
            "description": "The path of the property to get.",
            "name": "path"
        },
        {
            "type": {
                "names": [
                    "*"
                ]
            },
            "description": "The value to match.",
            "name": "srcValue"
        }
    ],
    "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\rfind(objects, matchesProperty('a', 4))\r// => { 'a': 4, 'b': 5, 'c': 6 }"
    ],
    "name": "matchesProperty",
    "longname": "matchesProperty",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000553",
    "___s": true,
    "filepath": "matchesProperty.js"
}