UNPKG

timeperiodjs

Version:
15 lines (14 loc) 774 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const ISorter_1 = require("../interfaces/ISorter"); const PeriodConstants_1 = require("../PeriodConstants"); class PeriodDateSorter extends ISorter_1.Sorter { sort(descending, byEndDate) { const sortingDate = byEndDate ? PeriodConstants_1.PeriodDateTypes.END : PeriodConstants_1.PeriodDateTypes.START; const sortingMethod = descending ? PeriodConstants_1.SortingMethods.SORT_DESCENDING : PeriodConstants_1.SortingMethods.SORT_ASCENDING; this._periods = this._periods .sort((a, b) => ISorter_1.Sorter[sortingMethod](a[sortingDate].getTime(), b[sortingDate].getTime())); return this._periods; } } exports.default = PeriodDateSorter;