@formatjs/intl-durationformat 0.9.1 → 0.9.2
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.
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +3 -3
- package/polyfill-force.js +9 -17
- package/polyfill.js +10 -18
- package/should-polyfill.js +1 -1
- package/src/abstract/DurationRecordSign.d.ts +1 -1
- package/src/abstract/DurationRecordSign.js +11 -11
- package/src/abstract/GetDurationUnitOptions.d.ts +2 -2
- package/src/abstract/GetDurationUnitOptions.js +34 -41
- package/src/abstract/IsValidDurationRecord.d.ts +1 -1
- package/src/abstract/IsValidDurationRecord.js +16 -16
- package/src/abstract/PartitionDurationFormatPattern.d.ts +2 -2
- package/src/abstract/PartitionDurationFormatPattern.js +127 -147
- package/src/abstract/ToDurationRecord.d.ts +1 -1
- package/src/abstract/ToDurationRecord.js +58 -66
- package/src/abstract/ToIntegerIfIntegral.js +4 -4
- package/src/constants.d.ts +60 -60
- package/src/constants.js +83 -82
- package/src/core.d.ts +15 -15
- package/src/core.js +298 -247
- package/src/get_internal_slots.d.ts +3 -1
- package/src/get_internal_slots.js +7 -7
- package/src/numbering-systems.generated.js +98 -98
- package/src/time-separators.generated.d.ts +2342 -2340
- package/src/time-separators.generated.js +809 -3905
- package/src/types.d.ts +91 -89
- package/src/types.js +0 -1
package/src/core.js
CHANGED
|
@@ -1,257 +1,308 @@
|
|
|
1
1
|
// Core implementation of Intl.DurationFormat polyfill
|
|
2
2
|
// Follows the TC39 Intl.DurationFormat proposal specification
|
|
3
|
-
import { CanonicalizeLocaleList, GetNumberOption, GetOption, OrdinaryHasInstance, SupportedLocales, ToObject, invariant
|
|
4
|
-
import { ResolveLocale } from
|
|
5
|
-
import { GetDurationUnitOptions } from
|
|
6
|
-
import { PartitionDurationFormatPattern } from
|
|
7
|
-
import { ToDurationRecord } from
|
|
8
|
-
import { getInternalSlots } from
|
|
9
|
-
import { numberingSystemNames } from
|
|
10
|
-
import { TIME_SEPARATORS } from
|
|
3
|
+
import { CanonicalizeLocaleList, GetNumberOption, GetOption, OrdinaryHasInstance, SupportedLocales, ToObject, invariant } from "@formatjs/ecma402-abstract";
|
|
4
|
+
import { ResolveLocale } from "@formatjs/intl-localematcher";
|
|
5
|
+
import { GetDurationUnitOptions } from "./abstract/GetDurationUnitOptions.js";
|
|
6
|
+
import { PartitionDurationFormatPattern } from "./abstract/PartitionDurationFormatPattern.js";
|
|
7
|
+
import { ToDurationRecord } from "./abstract/ToDurationRecord.js";
|
|
8
|
+
import { getInternalSlots } from "./get_internal_slots.js";
|
|
9
|
+
import { numberingSystemNames } from "./numbering-systems.generated.js";
|
|
10
|
+
import { TIME_SEPARATORS } from "./time-separators.generated.js";
|
|
11
|
+
import "./types.js";
|
|
11
12
|
// Keys that should be included in resolvedOptions() output
|
|
12
13
|
// These represent all the configurable options for duration formatting
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
14
|
+
const RESOLVED_OPTIONS_KEYS = [
|
|
15
|
+
"locale",
|
|
16
|
+
"style",
|
|
17
|
+
"years",
|
|
18
|
+
"yearsDisplay",
|
|
19
|
+
"months",
|
|
20
|
+
"monthsDisplay",
|
|
21
|
+
"weeks",
|
|
22
|
+
"weeksDisplay",
|
|
23
|
+
"days",
|
|
24
|
+
"daysDisplay",
|
|
25
|
+
"hours",
|
|
26
|
+
"hoursDisplay",
|
|
27
|
+
"minutes",
|
|
28
|
+
"minutesDisplay",
|
|
29
|
+
"seconds",
|
|
30
|
+
"secondsDisplay",
|
|
31
|
+
"milliseconds",
|
|
32
|
+
"millisecondsDisplay",
|
|
33
|
+
"microseconds",
|
|
34
|
+
"microsecondsDisplay",
|
|
35
|
+
"nanoseconds",
|
|
36
|
+
"nanosecondsDisplay",
|
|
37
|
+
"numberingSystem",
|
|
38
|
+
"fractionalDigits"
|
|
38
39
|
];
|
|
39
40
|
// Configuration table for all duration units (from spec Table 3)
|
|
40
41
|
// Defines the style and display options for each unit, along with their defaults
|
|
41
42
|
// Units are processed in order from largest (years) to smallest (nanoseconds)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
43
|
+
const TABLE_3 = [
|
|
44
|
+
{
|
|
45
|
+
styleSlot: "years",
|
|
46
|
+
displaySlot: "yearsDisplay",
|
|
47
|
+
unit: "years",
|
|
48
|
+
values: [
|
|
49
|
+
"long",
|
|
50
|
+
"short",
|
|
51
|
+
"narrow"
|
|
52
|
+
],
|
|
53
|
+
digitalDefault: "short"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
styleSlot: "months",
|
|
57
|
+
displaySlot: "monthsDisplay",
|
|
58
|
+
unit: "months",
|
|
59
|
+
values: [
|
|
60
|
+
"long",
|
|
61
|
+
"short",
|
|
62
|
+
"narrow"
|
|
63
|
+
],
|
|
64
|
+
digitalDefault: "short"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
styleSlot: "weeks",
|
|
68
|
+
displaySlot: "weeksDisplay",
|
|
69
|
+
unit: "weeks",
|
|
70
|
+
values: [
|
|
71
|
+
"long",
|
|
72
|
+
"short",
|
|
73
|
+
"narrow"
|
|
74
|
+
],
|
|
75
|
+
digitalDefault: "short"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
styleSlot: "days",
|
|
79
|
+
displaySlot: "daysDisplay",
|
|
80
|
+
unit: "days",
|
|
81
|
+
values: [
|
|
82
|
+
"long",
|
|
83
|
+
"short",
|
|
84
|
+
"narrow"
|
|
85
|
+
],
|
|
86
|
+
digitalDefault: "short"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
styleSlot: "hours",
|
|
90
|
+
displaySlot: "hoursDisplay",
|
|
91
|
+
unit: "hours",
|
|
92
|
+
values: [
|
|
93
|
+
"long",
|
|
94
|
+
"short",
|
|
95
|
+
"narrow",
|
|
96
|
+
"numeric",
|
|
97
|
+
"2-digit"
|
|
98
|
+
],
|
|
99
|
+
digitalDefault: "numeric"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
styleSlot: "minutes",
|
|
103
|
+
displaySlot: "minutesDisplay",
|
|
104
|
+
unit: "minutes",
|
|
105
|
+
values: [
|
|
106
|
+
"long",
|
|
107
|
+
"short",
|
|
108
|
+
"narrow",
|
|
109
|
+
"numeric",
|
|
110
|
+
"2-digit"
|
|
111
|
+
],
|
|
112
|
+
digitalDefault: "numeric"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
styleSlot: "seconds",
|
|
116
|
+
displaySlot: "secondsDisplay",
|
|
117
|
+
unit: "seconds",
|
|
118
|
+
values: [
|
|
119
|
+
"long",
|
|
120
|
+
"short",
|
|
121
|
+
"narrow",
|
|
122
|
+
"numeric",
|
|
123
|
+
"2-digit"
|
|
124
|
+
],
|
|
125
|
+
digitalDefault: "numeric"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
styleSlot: "milliseconds",
|
|
129
|
+
displaySlot: "millisecondsDisplay",
|
|
130
|
+
unit: "milliseconds",
|
|
131
|
+
values: [
|
|
132
|
+
"long",
|
|
133
|
+
"short",
|
|
134
|
+
"narrow",
|
|
135
|
+
"numeric"
|
|
136
|
+
],
|
|
137
|
+
digitalDefault: "numeric"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
styleSlot: "microseconds",
|
|
141
|
+
displaySlot: "microsecondsDisplay",
|
|
142
|
+
unit: "microseconds",
|
|
143
|
+
values: [
|
|
144
|
+
"long",
|
|
145
|
+
"short",
|
|
146
|
+
"narrow",
|
|
147
|
+
"numeric"
|
|
148
|
+
],
|
|
149
|
+
digitalDefault: "numeric"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
styleSlot: "nanoseconds",
|
|
153
|
+
displaySlot: "nanosecondsDisplay",
|
|
154
|
+
unit: "nanoseconds",
|
|
155
|
+
values: [
|
|
156
|
+
"long",
|
|
157
|
+
"short",
|
|
158
|
+
"narrow",
|
|
159
|
+
"numeric"
|
|
160
|
+
],
|
|
161
|
+
digitalDefault: "numeric"
|
|
162
|
+
}
|
|
113
163
|
];
|
|
114
164
|
/**
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
165
|
+
* DurationFormat provides locale-sensitive duration formatting
|
|
166
|
+
* Implements the Intl.DurationFormat API from the TC39 proposal
|
|
167
|
+
*/
|
|
168
|
+
export class DurationFormat {
|
|
169
|
+
constructor(locales, options) {
|
|
170
|
+
// Ensure constructor is called with 'new' keyword
|
|
171
|
+
// test262/test/intl402/ListFormat/constructor/constructor/newtarget-undefined.js
|
|
172
|
+
// Cannot use `new.target` bc of IE11 & TS transpiles it to something else
|
|
173
|
+
const newTarget = this && this instanceof DurationFormat ? this.constructor : void 0;
|
|
174
|
+
if (!newTarget) {
|
|
175
|
+
throw new TypeError("Intl.DurationFormat must be called with 'new'");
|
|
176
|
+
}
|
|
177
|
+
// Canonicalize the requested locales into a standard format
|
|
178
|
+
const requestedLocales = CanonicalizeLocaleList(locales);
|
|
179
|
+
const opt = Object.create(null);
|
|
180
|
+
const opts = options === undefined ? Object.create(null) : ToObject(options);
|
|
181
|
+
// Get locale matching algorithm preference ('best fit' or 'lookup')
|
|
182
|
+
const matcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
|
|
183
|
+
// Get numbering system (e.g., 'latn', 'arab', 'deva')
|
|
184
|
+
const numberingSystem = GetOption(opts, "numberingSystem", "string", undefined, undefined);
|
|
185
|
+
if (numberingSystem !== undefined && numberingSystemNames.indexOf(numberingSystem) < 0) {
|
|
186
|
+
// Validate that the numbering system is recognized
|
|
187
|
+
throw RangeError(`Invalid numberingSystems: ${numberingSystem}`);
|
|
188
|
+
}
|
|
189
|
+
opt.nu = numberingSystem;
|
|
190
|
+
opt.localeMatcher = matcher;
|
|
191
|
+
// Resolve the best matching locale from available locales
|
|
192
|
+
const { localeData, availableLocales } = DurationFormat;
|
|
193
|
+
const r = ResolveLocale(
|
|
194
|
+
availableLocales,
|
|
195
|
+
requestedLocales,
|
|
196
|
+
opt,
|
|
197
|
+
// [[RelevantExtensionKeys]] slot - only 'nu' (numbering system) is supported
|
|
198
|
+
["nu"],
|
|
199
|
+
localeData,
|
|
200
|
+
DurationFormat.getDefaultLocale
|
|
201
|
+
);
|
|
202
|
+
const locale = r.locale;
|
|
203
|
+
// Initialize internal slots for this formatter instance
|
|
204
|
+
const internalSlots = getInternalSlots(this);
|
|
205
|
+
internalSlots.initializedDurationFormat = true;
|
|
206
|
+
internalSlots.locale = locale;
|
|
207
|
+
internalSlots.numberingSystem = r.nu;
|
|
208
|
+
// Get overall formatting style: 'long' (3 hours), 'short' (3 hr), 'narrow' (3h), or 'digital' (3:00:00)
|
|
209
|
+
const style = GetOption(opts, "style", "string", [
|
|
210
|
+
"long",
|
|
211
|
+
"short",
|
|
212
|
+
"narrow",
|
|
213
|
+
"digital"
|
|
214
|
+
], "short");
|
|
215
|
+
internalSlots.style = style;
|
|
216
|
+
internalSlots.dataLocale = r.dataLocale;
|
|
217
|
+
// Process each duration unit (years through nanoseconds) to determine
|
|
218
|
+
// its display style and when to show it (always/auto/never)
|
|
219
|
+
let prevStyle = "";
|
|
220
|
+
TABLE_3.forEach((row) => {
|
|
221
|
+
const { styleSlot, displaySlot, unit, values: valueList, digitalDefault: digitalBase } = row;
|
|
222
|
+
// Get the style and display options for this unit
|
|
223
|
+
const unitOptions = GetDurationUnitOptions(unit, opts, style, valueList, digitalBase, prevStyle);
|
|
224
|
+
internalSlots[styleSlot] = unitOptions.style;
|
|
225
|
+
internalSlots[displaySlot] = unitOptions.display;
|
|
226
|
+
// Track the previous style for time units (hours through microseconds)
|
|
227
|
+
// This is used to ensure consistent digital formatting across related units
|
|
228
|
+
if (unit === "hours" || unit === "minutes" || unit === "seconds" || unit === "milliseconds" || unit === "microseconds") {
|
|
229
|
+
prevStyle = unitOptions.style;
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
// Get the number of fractional digits for sub-second precision (0-9)
|
|
233
|
+
internalSlots.fractionalDigits = GetNumberOption(opts, "fractionalDigits", 0, 9, undefined);
|
|
234
|
+
}
|
|
235
|
+
resolvedOptions() {
|
|
236
|
+
if (typeof this !== "object" || !OrdinaryHasInstance(DurationFormat, this)) {
|
|
237
|
+
throw TypeError("Method Intl.DurationFormat.prototype.resolvedOptions called on incompatible receiver");
|
|
238
|
+
}
|
|
239
|
+
const internalSlots = getInternalSlots(this);
|
|
240
|
+
const ro = {};
|
|
241
|
+
for (const key of RESOLVED_OPTIONS_KEYS) {
|
|
242
|
+
let v = internalSlots[key];
|
|
243
|
+
if (key === "fractionalDigits") {
|
|
244
|
+
if (v !== undefined) {
|
|
245
|
+
v = Number(v);
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
invariant(v !== undefined, `Missing internal slot ${key}`);
|
|
249
|
+
}
|
|
250
|
+
ro[key] = v;
|
|
251
|
+
}
|
|
252
|
+
return ro;
|
|
253
|
+
}
|
|
254
|
+
formatToParts(duration) {
|
|
255
|
+
const locInternalSlots = getInternalSlots(this);
|
|
256
|
+
if (locInternalSlots.initializedDurationFormat === undefined) {
|
|
257
|
+
throw new TypeError("Error uninitialized locale");
|
|
258
|
+
}
|
|
259
|
+
const record = ToDurationRecord(duration);
|
|
260
|
+
const parts = PartitionDurationFormatPattern(this, record);
|
|
261
|
+
const result = [];
|
|
262
|
+
for (const { type, unit, value } of parts) {
|
|
263
|
+
const obj = {
|
|
264
|
+
type,
|
|
265
|
+
value
|
|
266
|
+
};
|
|
267
|
+
if (unit) {
|
|
268
|
+
obj.unit = unit;
|
|
269
|
+
}
|
|
270
|
+
result.push(obj);
|
|
271
|
+
}
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
format(duration) {
|
|
275
|
+
const locInternalSlots = getInternalSlots(this);
|
|
276
|
+
if (locInternalSlots.initializedDurationFormat === undefined) {
|
|
277
|
+
throw new TypeError("Error uninitialized locale");
|
|
278
|
+
}
|
|
279
|
+
const record = ToDurationRecord(duration);
|
|
280
|
+
const parts = PartitionDurationFormatPattern(this, record);
|
|
281
|
+
let result = "";
|
|
282
|
+
for (const { value } of parts) {
|
|
283
|
+
result += value;
|
|
284
|
+
}
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
287
|
+
static supportedLocalesOf(locales, options) {
|
|
288
|
+
return SupportedLocales(DurationFormat.availableLocales, CanonicalizeLocaleList(locales), options);
|
|
289
|
+
}
|
|
290
|
+
static __defaultLocale = "en";
|
|
291
|
+
static availableLocales = new Set();
|
|
292
|
+
static localeData = Object.keys(TIME_SEPARATORS.localeData).reduce((all, locale) => {
|
|
293
|
+
DurationFormat.availableLocales.add(locale);
|
|
294
|
+
const nu = TIME_SEPARATORS.localeData[locale].nu;
|
|
295
|
+
all[locale] = {
|
|
296
|
+
nu,
|
|
297
|
+
digitalFormat: TIME_SEPARATORS.localeData[locale].separator || nu.reduce((separators, n) => {
|
|
298
|
+
separators[n] = TIME_SEPARATORS.default;
|
|
299
|
+
return separators;
|
|
300
|
+
}, {})
|
|
301
|
+
};
|
|
302
|
+
return all;
|
|
303
|
+
}, {});
|
|
304
|
+
static getDefaultLocale = () => {
|
|
305
|
+
return DurationFormat.__defaultLocale;
|
|
306
|
+
};
|
|
307
|
+
static polyfilled = true;
|
|
308
|
+
}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// Type-only circular import
|
|
2
|
+
// eslint-disable-next-line import/no-cycle
|
|
3
|
+
import type { DurationFormat, IntlDurationFormatInternal } from "./types.js";
|
|
2
4
|
export declare function getInternalSlots(x: DurationFormat): IntlDurationFormatInternal;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
const internalSlotMap = new WeakMap();
|
|
2
2
|
export function getInternalSlots(x) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
let internalSlots = internalSlotMap.get(x);
|
|
4
|
+
if (!internalSlots) {
|
|
5
|
+
internalSlots = Object.create(null);
|
|
6
|
+
internalSlotMap.set(x, internalSlots);
|
|
7
|
+
}
|
|
8
|
+
return internalSlots;
|
|
9
9
|
}
|