Hyperlinkv0.8.0-beta.28

Array

Array.unionconsteffect/Array.ts:3154
<T extends Iterable<any>>(that: T): <S extends Iterable<any>>(
  self: S
) => ReadonlyArray.OrNonEmpty<
  S,
  T,
  ReadonlyArray.Infer<S> | ReadonlyArray.Infer<T>
>
<A, B>(
  self: NonEmptyReadonlyArray<A>,
  that: ReadonlyArray<B>
): NonEmptyArray<A | B>
<A, B>(
  self: ReadonlyArray<A>,
  that: NonEmptyReadonlyArray<B>
): NonEmptyArray<A | B>
<A, B>(self: Iterable<A>, that: Iterable<B>): Array<A | B>

Computes the union of two arrays, removing duplicates using Equal.equivalence().

Example (Computing array unions)

import { Array } from "effect"

console.log(Array.union([1, 2], [2, 3])) // [1, 2, 3]
Source effect/Array.ts:315413 lines
export const union: {
  <T extends Iterable<any>>(
    that: T
  ): <S extends Iterable<any>>(
    self: S
  ) => ReadonlyArray.OrNonEmpty<S, T, ReadonlyArray.Infer<S> | ReadonlyArray.Infer<T>>
  <A, B>(self: NonEmptyReadonlyArray<A>, that: ReadonlyArray<B>): NonEmptyArray<A | B>
  <A, B>(self: ReadonlyArray<A>, that: NonEmptyReadonlyArray<B>): NonEmptyArray<A | B>
  <A, B>(self: Iterable<A>, that: Iterable<B>): Array<A | B>
} = dual(
  2,
  <A, B>(self: Iterable<A>, that: Iterable<B>): Array<A | B> => unionWith(self, that, Equal.asEquivalence<A | B>())
)
Referenced by 1 symbols