core.js 449 B

1234567891011121314151617181920212223
  1. /**
  2. * Core logic for the Period component.
  3. */
  4. export const PERIODS = {
  5. DAY: 'day',
  6. WEEK: 'week',
  7. MONTH: 'month',
  8. YEAR: 'year'
  9. };
  10. /**
  11. * Returns all available periods.
  12. * @returns {string[]}
  13. */
  14. export const getAvailablePeriods = () => Object.values(PERIODS);
  15. /**
  16. * Validates if a period is supported.
  17. * @param {string} period
  18. * @returns {boolean}
  19. */
  20. export const isValidPeriod = (period) => getAvailablePeriods().includes(period);