• Generates a sequence of buffers over the source sequence, with specified length and possible overlap.

    Type Parameters

    • TSource

    Parameters

    • count: number

      Number of elements for allocated buffers.

    • Optional skip: number

      Number of elements to skip between the start of consecutive buffers. If not specified, defaults to the count.

    Returns OperatorFunction<TSource, TSource[]>

    Sequence of buffers containing source sequence elements

    Example

    Creates a sequence of buffers with and without skip

    const source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];

    // Without skip
    const result = buffer(source, 5);
    const result = Ix.Iterable.from(source).buffer(5);
    for (const item of result) {
    console.log(result);
    }
    // => [0, 1, 2, 3, 4]
    // => [5, 6, 7, 8, 9]

    // With skip
    const result = buffer(source, 3, 4);
    const result = Ix.Iterable.from(source).buffer(3, 4);
    for (const item of result) {
    console.log(result);
    }
    // => [0, 1, 2]
    // => [4, 5, 6]
    // => [8, 9]

Generated using TypeDoc