UNPKG

1.31 kBPlain TextView Raw
1/**
2 * `DownloadPeriod` represents a time period
3 * for which downloads should be counted.
4 *
5 * @remarks
6 * The following time periods are supported:
7 *
8 * - a {@link DefaultDownloadPeriod} (for example, `last-week`)
9 *
10 * - a date for a single day (for example, `new Date('2020-01-01')`)
11 *
12 * - a {@link DateRange}
13 *
14 * @see {@link DefaultDownloadPeriod}
15 * @see {@link DateRange}
16 * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date}
17 */
18export type DownloadPeriod = DefaultDownloadPeriod | Date | DateRange;
19
20/**
21 * `DefaultDownloadPeriod` represents the default time periods
22 * supported by the npm registry.
23 */
24export type DefaultDownloadPeriod =
25 | 'last-day'
26 | 'last-week'
27 | 'last-month'
28 | 'last-year';
29
30/**
31 * `DateRange` represents a time period between two days
32 * where the `start` and `end` dates are inclusive.
33 *
34 * @example
35 * ```typescript
36 * const dateRange = {
37 * start: new Date('2019-01-01'),
38 * end: new Date('2020-01-01'),
39 * };
40 * ```
41 *
42 * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date}
43 */
44export interface DateRange {
45 /** Date of the first day (inclusive) */
46 readonly start: Date;
47
48 /** Date of the last day (inclusive) */
49 readonly end: Date;
50}