ixfx
    Preparing search index...

    Function unique

    • Combines the values of one or more arrays, removing duplicates. Compares based on a string representation of object. Uses a Set to avoid unnecessary comparisons, perhaps faster than uniqueDeep.

      const v = Arrays.unique([ [1, 2, 3, 4], [ 3, 4, 5, 6] ]);
      // [ 1, 2, 3, 4, 5, 6]

      A single array can be provided as well:

      const v = Arrays.unique([ 1, 2, 3, 1, 2, 3 ]);
      // [ 1, 2, 3 ]

      By default uses JSON.toString() to compare values.

      See also:

      • intersection: Overlap between two arrays
      • Iterables.additionalValues: Yield values from an iterable not present in the other
      • containsDuplicateValues: Returns true if array contains duplicates

      Type Parameters

      • V

      Parameters

      • arrays: V[] | V[][] | readonly V[] | readonly (readonly V[])[]

        Array (or array of arrays) to examine

      • toString: <V>(itemToMakeStringFor: V) => string = toStringDefault

        Function to convert values to a string for comparison purposes. By default uses JSON formatting.

          • <V>(itemToMakeStringFor: V): string
          • A default converter to string that uses JSON.stringify if its an object, or the thing itself if it's a string

            Type Parameters

            • V

            Parameters

            • itemToMakeStringFor: V

            Returns string

      Returns V[]