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

    Function unionBy

    • Union two arrays by predicate

      两个数组的并集,根据 predicate 函数进行比较

      Type Parameters

      • T
      • U

      Parameters

      • a: readonly T[]

        The first array to union / 第一个数组

      • b: readonly T[]

        The second array to union / 第二个数组

      • predicate: (item: T) => U

        The function to use to transform each element for deduplication / 用于每个元素的 predicate 函数以进行去重

      Returns T[]

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

      unionBy([1, 2, 3], [2, 4, 5, 6], (item) => item % 2) // => [1, 2]
      unionBy([1, 2], [3, 4], (item) => item % 2) // => [1, 2]