@formatjs/intl-durationformat 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +3 -0
  3. package/index.d.ts +1 -0
  4. package/index.js +4 -0
  5. package/lib/index.d.ts +1 -0
  6. package/lib/index.js +1 -0
  7. package/lib/polyfill-force.d.ts +1 -0
  8. package/lib/polyfill-force.js +18 -0
  9. package/lib/polyfill.d.ts +1 -0
  10. package/lib/polyfill.js +21 -0
  11. package/lib/should-polyfill.d.ts +1 -0
  12. package/lib/should-polyfill.js +3 -0
  13. package/lib/src/abstract/DurationRecordSign.d.ts +2 -0
  14. package/lib/src/abstract/DurationRecordSign.js +13 -0
  15. package/lib/src/abstract/GetDurationUnitOptions.d.ts +4 -0
  16. package/lib/src/abstract/GetDurationUnitOptions.js +43 -0
  17. package/lib/src/abstract/IsValidDurationRecord.d.ts +2 -0
  18. package/lib/src/abstract/IsValidDurationRecord.js +18 -0
  19. package/lib/src/abstract/PartitionDurationFormatPattern.d.ts +3 -0
  20. package/lib/src/abstract/PartitionDurationFormatPattern.js +149 -0
  21. package/lib/src/abstract/ToDurationRecord.d.ts +2 -0
  22. package/lib/src/abstract/ToDurationRecord.js +68 -0
  23. package/lib/src/abstract/ToIntegerIfIntegral.d.ts +1 -0
  24. package/lib/src/abstract/ToIntegerIfIntegral.js +8 -0
  25. package/lib/src/constants.d.ts +63 -0
  26. package/lib/src/constants.js +84 -0
  27. package/lib/src/core.d.ts +14 -0
  28. package/lib/src/core.js +236 -0
  29. package/lib/src/get_internal_slots.d.ts +2 -0
  30. package/lib/src/get_internal_slots.js +9 -0
  31. package/lib/src/numbering-systems.generated.d.ts +1 -0
  32. package/lib/src/numbering-systems.generated.js +1 -0
  33. package/lib/src/time-separators.generated.d.ts +2123 -0
  34. package/lib/src/time-separators.generated.js +3541 -0
  35. package/lib/src/types.d.ts +108 -0
  36. package/lib/src/types.js +2 -0
  37. package/package.json +32 -0
  38. package/polyfill-force.d.ts +1 -0
  39. package/polyfill-force.js +20 -0
  40. package/polyfill.d.ts +1 -0
  41. package/polyfill.js +23 -0
  42. package/should-polyfill.d.ts +1 -0
  43. package/should-polyfill.js +7 -0
  44. package/src/abstract/DurationRecordSign.d.ts +2 -0
  45. package/src/abstract/DurationRecordSign.js +17 -0
  46. package/src/abstract/GetDurationUnitOptions.d.ts +4 -0
  47. package/src/abstract/GetDurationUnitOptions.js +47 -0
  48. package/src/abstract/IsValidDurationRecord.d.ts +2 -0
  49. package/src/abstract/IsValidDurationRecord.js +22 -0
  50. package/src/abstract/PartitionDurationFormatPattern.d.ts +3 -0
  51. package/src/abstract/PartitionDurationFormatPattern.js +153 -0
  52. package/src/abstract/ToDurationRecord.d.ts +2 -0
  53. package/src/abstract/ToDurationRecord.js +72 -0
  54. package/src/abstract/ToIntegerIfIntegral.d.ts +1 -0
  55. package/src/abstract/ToIntegerIfIntegral.js +12 -0
  56. package/src/constants.d.ts +63 -0
  57. package/src/constants.js +87 -0
  58. package/src/core.d.ts +14 -0
  59. package/src/core.js +239 -0
  60. package/src/get_internal_slots.d.ts +2 -0
  61. package/src/get_internal_slots.js +13 -0
  62. package/src/numbering-systems.generated.d.ts +1 -0
  63. package/src/numbering-systems.generated.js +4 -0
  64. package/src/time-separators.generated.d.ts +2123 -0
  65. package/src/time-separators.generated.js +3544 -0
  66. package/src/types.d.ts +108 -0
  67. package/src/types.js +3 -0
package/src/types.d.ts ADDED
@@ -0,0 +1,108 @@
1
+ export type DurationFormatOptions = Partial<ResolvedDurationFormatOptions>;
2
+ export interface ResolvedDurationFormatOptions {
3
+ localeMatcher: 'best fit' | 'lookup';
4
+ style: 'long' | 'short' | 'narrow' | 'digital';
5
+ years: 'long' | 'short' | 'narrow';
6
+ yearsDisplay: 'always' | 'auto';
7
+ months: 'long' | 'short' | 'narrow';
8
+ monthsDisplay: 'always' | 'auto';
9
+ weeks: 'long' | 'short' | 'narrow';
10
+ weeksDisplay: 'always' | 'auto';
11
+ days: 'long' | 'short' | 'narrow';
12
+ daysDisplay: 'always' | 'auto';
13
+ hours: 'long' | 'short' | 'narrow' | 'numeric';
14
+ hoursDisplay: 'always' | 'auto';
15
+ minutes: 'long' | 'short' | 'narrow' | 'numeric' | '2-digit';
16
+ minutesDisplay: 'always' | 'auto';
17
+ seconds: 'long' | 'short' | 'narrow' | 'numeric' | '2-digit';
18
+ secondsDisplay: 'always' | 'auto';
19
+ milliseconds: 'long' | 'short' | 'narrow' | 'numeric';
20
+ millisecondsDisplay: 'always' | 'auto';
21
+ microseconds: 'long' | 'short' | 'narrow' | 'numeric';
22
+ microsecondsDisplay: 'always' | 'auto';
23
+ nanoseconds: 'long' | 'short' | 'narrow' | 'numeric';
24
+ nanosecondsDisplay: 'always' | 'auto';
25
+ fractionalDigits?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
26
+ numberingSystem: string;
27
+ round: boolean;
28
+ }
29
+ export interface DurationFormatPart {
30
+ unit?: string;
31
+ type: unknown;
32
+ value: string;
33
+ }
34
+ export interface RawDurationLocaleData {
35
+ data: DurationFormatLocaleInternalData;
36
+ locale: string;
37
+ }
38
+ export interface DurationFormatLocaleInternalData {
39
+ nu: readonly string[];
40
+ digitalFormat: Record<string, string>;
41
+ }
42
+ export interface DurationFormat {
43
+ resolvedOptions(): ResolvedDurationFormatOptions;
44
+ formatToParts(duration: DurationInput): DurationFormatPart[];
45
+ format(duration: DurationInput): string;
46
+ }
47
+ export interface IntlDurationFormatInternal {
48
+ initializedDurationFormat: boolean;
49
+ fractionalDigits: number | undefined;
50
+ dataLocale: string;
51
+ locale: string;
52
+ numberingSystem: string;
53
+ style: DurationFormatOptions['style'];
54
+ years: 'long' | 'short' | 'narrow';
55
+ yearsDisplay: 'always' | 'auto';
56
+ months: 'long' | 'short' | 'narrow';
57
+ monthsDisplay: 'always' | 'auto';
58
+ weeks: 'long' | 'short' | 'narrow';
59
+ weeksDisplay: 'always' | 'auto';
60
+ days: 'long' | 'short' | 'narrow';
61
+ daysDisplay: 'always' | 'auto';
62
+ hours: 'long' | 'short' | 'narrow' | 'numeric';
63
+ hoursDisplay: 'always' | 'auto';
64
+ minutes: 'long' | 'short' | 'narrow' | 'numeric' | '2-digit';
65
+ minutesDisplay: 'always' | 'auto';
66
+ seconds: 'long' | 'short' | 'narrow' | 'numeric' | '2-digit';
67
+ secondsDisplay: 'always' | 'auto';
68
+ milliseconds: 'long' | 'short' | 'narrow' | 'numeric';
69
+ millisecondsDisplay: 'always' | 'auto';
70
+ microseconds: 'long' | 'short' | 'narrow' | 'numeric';
71
+ microsecondsDisplay: 'always' | 'auto';
72
+ nanoseconds: 'long' | 'short' | 'narrow' | 'numeric';
73
+ nanosecondsDisplay: 'always' | 'auto';
74
+ }
75
+ export interface DurationInput {
76
+ years?: number;
77
+ months?: number;
78
+ weeks?: number;
79
+ days?: number;
80
+ hours?: number;
81
+ minutes?: number;
82
+ seconds?: number;
83
+ milliseconds?: number;
84
+ microseconds?: number;
85
+ nanoseconds?: number;
86
+ }
87
+ export interface DurationRecord {
88
+ years: number;
89
+ months: number;
90
+ weeks: number;
91
+ days: number;
92
+ hours: number;
93
+ minutes: number;
94
+ seconds: number;
95
+ milliseconds: number;
96
+ microseconds: number;
97
+ nanoseconds: number;
98
+ }
99
+ export interface DurationFormatConstructor {
100
+ new (locales?: string | string[], options?: DurationFormatOptions): DurationFormat;
101
+ (locales?: string | string[], options?: DurationFormatOptions): DurationFormat;
102
+ supportedLocalesOf(locales: string | string[], options?: Pick<DurationFormatOptions, 'localeMatcher'>): string[];
103
+ getDefaultLocale(): string;
104
+ __defaultLocale: string;
105
+ localeData: Record<string, DurationFormatLocaleInternalData | undefined>;
106
+ availableLocales: Set<string>;
107
+ polyfilled: boolean;
108
+ }
package/src/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // Public --------------------------------------------------------------------------------------------------------------
3
+ Object.defineProperty(exports, "__esModule", { value: true });