@szilanor/stream
    Preparing search index...

    Function permutations

    • Returns a Stream that yields the permutations of the specified iterable.

      Type Parameters

      • T

        Type of items in the Stream.

      Parameters

      • iterable: Iterable<T>

        Iterable to create the Stream from.

      • Optionalr: number

        Number of items to yield.

      Returns Stream<T[]>

      Stream that yields the permutations of the specified iterable.

      const result = permutations([1, 2, 3], 2);
      console.log([...result]); // [[1, 2], [1, 3], [2, 1], [2, 3], [3, 1], [3, 2]]