Ambil Semua Tanggal dalam Jangka A - B Pake Moment

Kalo kita punya Date A & Date B, gimana caranya ambil semua tanggal dari A - B.

import moment from 'moment';

function getAllDaysInRange(startDate, endDate) {
  let now = moment(startDate);
  let days = [];

  while (now.isSameOrBefore(endDate)) {
    days.push(now.clone());

    now = now.add(1, "day");
  }

  return days.map((mmt) => mmt.toDate());
}

console.log(getAllDaysInRange(new Date("2021-12-13"), new Date("2021-12-15")));

Outputnya:

0: Mon Dec 13 2021 07:00:00 GMT+0700 (Western Indonesia Time)
1: Tue Dec 14 2021 07:00:00 GMT+0700 (Western Indonesia Time)
2: Wed Dec 15 2021 07:00:00 GMT+0700 (Western Indonesia Time)