Function stride

  • Iterate over an iterable using a stepped increment.

    Type Parameters

    • T

    Parameters

    • object: Iterable<T>

      The iterable object of interest.

    • step: number

      The distance to step on each iteration. A value of less than 1 will behave the same as a value of 1.

    Returns IterableIterator<T>

    An iterator which traverses the iterable step-wise.

    Example

    import { stride } from '@lumino/algorithm';

    let data = [1, 2, 3, 4, 5, 6];

    let stream = stride(data, 2);

    Array.from(stream); // [1, 3, 5];