ts-iterable-functions
    Preparing search index...

    Function _toSet

    • Materializes a sequence into a set, optionally projecting each element to a key before insertion.

      Type Parameters

      • T

        Element type produced by the source iterable.

      Parameters

      • src: Iterable<T>

        Source iterable to materialize.

      • OptionalsetFactory: SetFactory<T>

        Optional factory controlling the concrete set implementation to instantiate.

      Returns Set<T>

      A set containing one entry per projected value.

      If keySelector produces the same key more than once.

      const lengths = _toSet(["a", "bb", "ccc"], (value) => value.length);
      console.log([...lengths]); // [1, 2, 3]
    • Materializes a sequence into a set, optionally projecting each element to a key before insertion.

      Type Parameters

      • T

        Element type produced by the source iterable.

      • TKey

        Key type returned by keySelector when supplied.

      Parameters

      • src: Iterable<T>

        Source iterable to materialize.

      • keySelector: IndexedSelector<T, TKey>

        Optional projection used to derive the value stored in the set; defaults to the element itself.

      • OptionalsetFactory: SetFactory<TKey>

        Optional factory controlling the concrete set implementation to instantiate.

      Returns Set<TKey>

      A set containing one entry per projected value.

      If keySelector produces the same key more than once.

      const lengths = _toSet(["a", "bb", "ccc"], (value) => value.length);
      console.log([...lengths]); // [1, 2, 3]