From 89491f349d2b1015365af5e239793de352f95114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Bou=C3=A7as?= Date: Tue, 11 Mar 2025 23:19:04 +0000 Subject: [PATCH] feat: export time interval constants --- packages/cache/src/constants.test.ts | 11 +++++++++++ packages/cache/src/constants.ts | 24 ++++++++++++++++++++++++ packages/cache/src/main.ts | 1 + 3 files changed, 36 insertions(+) create mode 100644 packages/cache/src/constants.test.ts create mode 100644 packages/cache/src/constants.ts diff --git a/packages/cache/src/constants.test.ts b/packages/cache/src/constants.test.ts new file mode 100644 index 00000000..566bbeb4 --- /dev/null +++ b/packages/cache/src/constants.test.ts @@ -0,0 +1,11 @@ +import { test, expect } from 'vitest' + +import { MINUTE, HOUR, DAY, WEEK, YEAR } from './main.js' + +test('Exports time interval constants', () => { + expect(MINUTE).toBe(60) + expect(HOUR).toBe(60 * 60) + expect(DAY).toBe(60 * 60 * 24) + expect(WEEK).toBe(60 * 60 * 24 * 7) + expect(YEAR).toBe(60 * 60 * 24 * 365) +}) diff --git a/packages/cache/src/constants.ts b/packages/cache/src/constants.ts new file mode 100644 index 00000000..9ac176da --- /dev/null +++ b/packages/cache/src/constants.ts @@ -0,0 +1,24 @@ +/** + * Number of seconds in one minute. + */ +export const MINUTE = 60 + +/** + * Number of seconds in one hour. + */ +export const HOUR = 60 * MINUTE + +/** + * Number of seconds in one day. + */ +export const DAY = 24 * HOUR + +/** + * Number of seconds in one week. + */ +export const WEEK = 7 * DAY + +/** + * Number of seconds in one year. + */ +export const YEAR = 365 * DAY diff --git a/packages/cache/src/main.ts b/packages/cache/src/main.ts index 881dfc05..9b9e3a99 100644 --- a/packages/cache/src/main.ts +++ b/packages/cache/src/main.ts @@ -1,3 +1,4 @@ export { setCacheHeaders } from './cache-headers/cache-headers.js' export { getCacheStatus } from './cache-status/cache-status.js' export { fetchWithCache } from './fetchwithcache.js' +export * from './constants.js'