Генератор диапазона дат
const rangeGenerator = function* (start, end, step = 1) { let i = start; while (i < end) { yield i; i += step; } };
const dateRangeGenerator = function* (start, end, step = 1) { let d = start; while (d < end) { yield new Date(d); d.setDate(d.getDate() + step); } };
for (let i of rangeGenerator(6, 10)) console.log(i); // Logs 6, 7, 8, 9
[…dateRangeGenerator(new Date('2021-06-01'), new Date('2021-06-04'))]; // [ 2021-06-01, 2021-06-02, 2021-06-03 ]