Function sliceSync

  • Slices an input sync iterable between the specified start and end indices. If both start and end indices are non-negative, the slicing is performed lazily. Otherwise, the slicing is performed greedily.

    Returns

    A function that accepts an input sync iterable and returns an iterable that yields the sliced values.

    Example

    const input = [1, 2, 3, 4, 5];
    const slicedSync = sliceSync(1, 4)(input);

    for (const value of slicedSync) {
    console.log(value); // Logs 2, 3, 4
    }

    Remarks

    Available as slice when imported from peter-piper/sync.

    Type Parameters

    • T

      The type of elements in the input sync iterable.

    Parameters

    • startIndex: number = 0

      Optional. The start index for the slice, defaults to 0.

    • endIndex: number = Number.POSITIVE_INFINITY

      Optional. The end index for the slice, defaults to Number.POSITIVE_INFINITY.

    Returns ((input: Iterable<T>) => Iterable<T>)

      • (input: Iterable<T>): Iterable<T>
      • Parameters

        • input: Iterable<T>

        Returns Iterable<T>

Generated using TypeDoc