timeperiodjs
Version:
Time Period Library
16 lines (15 loc) • 649 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const ISorter_1 = require("../interfaces/ISorter");
const PeriodConstants_1 = require("../PeriodConstants");
class DateSorter extends ISorter_1.Sorter {
constructor(dates) {
super(undefined, dates);
}
sort(descending) {
const sortingMethod = descending ? PeriodConstants_1.SortingMethods.SORT_DESCENDING : PeriodConstants_1.SortingMethods.SORT_ASCENDING;
this._dates = this._dates.sort((a, b) => ISorter_1.Sorter[sortingMethod](a.getTime(), b.getTime()));
return this.dates;
}
}
exports.default = DateSorter;