@pengzhanbo/utils - v3.7.3
    Preparing search index...

    Function uniqWith

    • Unique array with a custom equality function

      通过自定义相等函数实现数组去重

      Type Parameters

      • T

      Parameters

      • array: readonly T[]

        The array to remove duplicates from / 要去重的数组

      • equal: (a: T, b: T) => boolean

        The function to determine equality between elements / 判断元素是否相等的函数

      Returns T[]

      The array with duplicates removed / 去重后的数组

      Time complexity: O(n²). For large arrays, consider using uniqBy with a key function for O(n) performance.

      时间复杂度:O(n²)。对于大数组,建议使用 uniqBy 配合键函数以获得 O(n) 性能。

      uniqWith([1, 1, 2, 2, 3, 3], (a, b) => a === b)
      // => [1, 2, 3]