Home

function: uniqWith


uniqWith(array: Array, comparator: function): Array

This method is like `uniq` except that it accepts `comparator` which is invoked to compare elements of `array`. The order of result values is determined by the order they occur in the array.The comparator is invoked with two arguments: (arrVal, othVal).

Example(s):

const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]

uniqWith(objects, isEqual)
// => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]

Params:

Name Type Attribute Description
array The array to inspect.
comparator The comparator invoked per element.

Returns:

Array

  {
    "comment": "/**\r\n * This method is like `uniq` except that it accepts `comparator` which\r\n * is invoked to compare elements of `array`. The order of result values is\r\n * determined by the order they occur in the array.The comparator is invoked\r\n * with two arguments: (arrVal, othVal).\r\n *\r\n * @since 4.0.0\r\n * @category Array\r\n * @param {Array} array The array to inspect.\r\n * @param {Function} [comparator] The comparator invoked per element.\r\n * @returns {Array} Returns the new duplicate free array.\r\n * @see uniq, uniqBy\r\n * @example\r\n *\r\n * const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]\r\n *\r\n * uniqWith(objects, isEqual)\r\n * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]\r\n */",
    "meta": {
        "range": [
            754,
            966
        ],
        "filename": "uniqWith.js",
        "lineno": 22,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100011279",
            "name": "uniqWith",
            "type": "FunctionDeclaration",
            "paramnames": [
                "array",
                "comparator"
            ]
        },
        "vars": {
            "comparator": "uniqWith~comparator"
        }
    },
    "description": "This method is like `uniq` except that it accepts `comparator` which\ris invoked to compare elements of `array`. The order of result values is\rdetermined by the order they occur in the array.The comparator is invoked\rwith two arguments: (arrVal, othVal).",
    "since": "4.0.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "Array",
            "value": "Array"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "Array"
                ]
            },
            "description": "The array to inspect.",
            "name": "array"
        },
        {
            "type": {
                "names": [
                    "function"
                ]
            },
            "optional": true,
            "description": "The comparator invoked per element.",
            "name": "comparator"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "Array"
                ]
            },
            "description": "Returns the new duplicate free array."
        }
    ],
    "see": [
        "uniq, uniqBy"
    ],
    "examples": [
        "const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]\r\runiqWith(objects, isEqual)\r// => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]"
    ],
    "name": "uniqWith",
    "longname": "uniqWith",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R001025",
    "___s": true,
    "filepath": "uniqWith.js"
}