@mirei/ts-collections
    Preparing search index...

    Function toSet

    • Materialises source into a native Set.

      Type Parameters

      • TElement

        Type of elements within source.

      Parameters

      • source: Iterable<TElement>

        The source iterable.

      Returns Set<TElement>

      A set containing the distinct elements from source.

      The entire sequence is enumerated immediately and duplicate elements are collapsed using JavaScript's SameValueZero semantics.

      const numbers = [1, 2, 2, 3, 1];
      const set = toSet(numbers);
      console.log(Array.from(set)); // [1, 2, 3]