Function range

  • Create and iterator for looping over a date period, e.g. every date between begin and end. Both begin and end will be included.

    Since this is an iterator remember evaluation is lazy and to use Array.from(..) if you need a proper array.

    Type Parameters

    Parameters

    • begin: T

      First date (inclusive)

    • end: T

      Last date (inclusive)

    Returns Generator<T>

    Loop over every date between begin and end:

    for (const date of range(begin, end)) {
    // do something with date
    }

    Save an array with all dates between begin and end:

    const dates = Array.from(range(begin, end))