@formatjs/intl-locale 3.4.6 → 4.0.1
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/get_internal_slots.d.ts +1 -1
- package/get_internal_slots.js +10 -2
- package/index.d.ts +4 -30
- package/index.js +65 -141
- package/lib/get_internal_slots.d.ts +1 -1
- package/lib/get_internal_slots.js +10 -2
- package/lib/index.d.ts +4 -30
- package/lib/index.js +66 -142
- package/package.json +3 -3
- package/polyfill.iife.js +23222 -16032
package/get_internal_slots.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import Locale, { IntlLocaleInternal } from '.';
|
|
2
|
-
export default function getInternalSlots(x: Locale): IntlLocaleInternal;
|
|
2
|
+
export default function getInternalSlots(x: Locale, internalSlotsList?: string[]): IntlLocaleInternal;
|
package/get_internal_slots.js
CHANGED
|
@@ -3,10 +3,18 @@
|
|
|
3
3
|
// eslint-disable-next-line import/no-cycle
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
var internalSlotMap = new WeakMap();
|
|
6
|
-
function getInternalSlots(x) {
|
|
6
|
+
function getInternalSlots(x, internalSlotsList) {
|
|
7
|
+
if (internalSlotsList === void 0) { internalSlotsList = []; }
|
|
7
8
|
var internalSlots = internalSlotMap.get(x);
|
|
8
9
|
if (!internalSlots) {
|
|
9
|
-
internalSlots = Object.create(null)
|
|
10
|
+
internalSlots = Object.create(null, internalSlotsList.reduce(function (all, prop) {
|
|
11
|
+
all[prop] = {
|
|
12
|
+
enumerable: false,
|
|
13
|
+
writable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
};
|
|
16
|
+
return all;
|
|
17
|
+
}, {}));
|
|
10
18
|
internalSlotMap.set(x, internalSlots);
|
|
11
19
|
}
|
|
12
20
|
return internalSlots;
|
package/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface IntlLocaleOptions {
|
|
|
8
8
|
caseFirst?: 'upper' | 'lower' | 'false';
|
|
9
9
|
numberingSystem?: string;
|
|
10
10
|
numeric?: boolean;
|
|
11
|
+
firstDayOfWeek?: string;
|
|
11
12
|
}
|
|
12
13
|
export interface IntlLocaleInternal extends IntlLocaleOptions {
|
|
13
14
|
locale: string;
|
|
@@ -27,7 +28,6 @@ export declare class Locale {
|
|
|
27
28
|
get baseName(): string;
|
|
28
29
|
get calendar(): string | undefined;
|
|
29
30
|
get collation(): string | undefined;
|
|
30
|
-
get hourCycle(): "h11" | "h12" | "h23" | "h24" | undefined;
|
|
31
31
|
get caseFirst(): "upper" | "lower" | "false" | undefined;
|
|
32
32
|
get numeric(): boolean | undefined;
|
|
33
33
|
get numberingSystem(): string | undefined;
|
|
@@ -43,70 +43,44 @@ export declare class Locale {
|
|
|
43
43
|
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.region
|
|
44
44
|
*/
|
|
45
45
|
get region(): string | undefined;
|
|
46
|
+
get firstDayOfWeek(): string | undefined;
|
|
47
|
+
get hourCycle(): "h11" | "h12" | "h23" | "h24" | undefined;
|
|
46
48
|
/**
|
|
47
49
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getCalendars
|
|
48
50
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getCalendars
|
|
49
51
|
*/
|
|
50
52
|
getCalendars(): string[];
|
|
51
|
-
/**
|
|
52
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.calendars
|
|
53
|
-
*/
|
|
54
|
-
get calendars(): string[];
|
|
55
53
|
/**
|
|
56
54
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getCollations
|
|
57
55
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getCollations
|
|
58
56
|
*/
|
|
59
57
|
getCollations(): string[];
|
|
60
|
-
/**
|
|
61
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.collations
|
|
62
|
-
*/
|
|
63
|
-
get collations(): string[];
|
|
64
58
|
/**
|
|
65
59
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getHourCycles
|
|
66
60
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getHourCycles
|
|
67
61
|
*/
|
|
68
62
|
getHourCycles(): string[];
|
|
69
|
-
/**
|
|
70
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.hourCycles
|
|
71
|
-
*/
|
|
72
|
-
get hourCycles(): string[];
|
|
73
63
|
/**
|
|
74
64
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getNumberingSystems
|
|
75
65
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getNumberingSystems
|
|
76
66
|
*/
|
|
77
67
|
getNumberingSystems(): string[];
|
|
78
|
-
/**
|
|
79
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.numberingSystems
|
|
80
|
-
*/
|
|
81
|
-
get numberingSystems(): string[];
|
|
82
68
|
/**
|
|
83
69
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTimeZones
|
|
84
70
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getTimeZones
|
|
85
71
|
*/
|
|
86
72
|
getTimeZones(): string[] | undefined;
|
|
87
|
-
/**
|
|
88
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.timeZones
|
|
89
|
-
*/
|
|
90
|
-
get timeZones(): string[] | undefined;
|
|
91
73
|
/**
|
|
92
74
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo
|
|
93
75
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getTextInfo
|
|
94
76
|
*/
|
|
95
77
|
getTextInfo(): any;
|
|
96
|
-
/**
|
|
97
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.textInfo
|
|
98
|
-
*/
|
|
99
|
-
get textInfo(): any;
|
|
100
78
|
/**
|
|
101
79
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo
|
|
102
80
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getWeekInfo
|
|
103
81
|
*/
|
|
104
82
|
getWeekInfo(): any;
|
|
105
|
-
|
|
106
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.weekInfo
|
|
107
|
-
*/
|
|
108
|
-
get weekInfo(): any;
|
|
109
|
-
static relevantExtensionKeys: readonly ["ca", "co", "hc", "kf", "kn", "nu"];
|
|
83
|
+
static relevantExtensionKeys: readonly ["ca", "co", "hc", "kf", "kn", "nu", "fw"];
|
|
110
84
|
static readonly polyfilled = true;
|
|
111
85
|
}
|
|
112
86
|
export default Locale;
|
package/index.js
CHANGED
|
@@ -2,14 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Locale = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var intl_enumerator_1 = require("@formatjs/intl-enumerator");
|
|
6
5
|
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
6
|
+
var intl_enumerator_1 = require("@formatjs/intl-enumerator");
|
|
7
7
|
var intl_getcanonicallocales_1 = require("@formatjs/intl-getcanonicallocales");
|
|
8
|
-
var get_internal_slots_1 = tslib_1.__importDefault(require("./get_internal_slots"));
|
|
9
|
-
var preference_data_1 = require("./preference-data");
|
|
10
8
|
var character_orders_generated_1 = require("./character-orders.generated");
|
|
9
|
+
var get_internal_slots_1 = tslib_1.__importDefault(require("./get_internal_slots"));
|
|
11
10
|
var numbering_systems_generated_1 = require("./numbering-systems.generated");
|
|
12
|
-
var
|
|
11
|
+
var preference_data_1 = require("./preference-data");
|
|
12
|
+
var ALPHANUM_3_8 = /^[a-z0-9]{3,8}$/i;
|
|
13
|
+
var RELEVANT_EXTENSION_KEYS = [
|
|
14
|
+
'ca',
|
|
15
|
+
'co',
|
|
16
|
+
'hc',
|
|
17
|
+
'kf',
|
|
18
|
+
'kn',
|
|
19
|
+
'nu',
|
|
20
|
+
'fw',
|
|
21
|
+
];
|
|
13
22
|
var UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
|
|
14
23
|
function applyOptionsToTag(tag, options) {
|
|
15
24
|
(0, ecma402_abstract_1.invariant)(typeof tag === 'string', 'language tag must be a string');
|
|
@@ -254,6 +263,10 @@ function weekInfoOfLocale(loc) {
|
|
|
254
263
|
}
|
|
255
264
|
return (0, preference_data_1.getWeekDataForRegion)(region);
|
|
256
265
|
}
|
|
266
|
+
var TABLE_1 = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
|
|
267
|
+
function weekdayToString(fw) {
|
|
268
|
+
return TABLE_1[+fw];
|
|
269
|
+
}
|
|
257
270
|
var Locale = /** @class */ (function () {
|
|
258
271
|
function Locale(tag, opts) {
|
|
259
272
|
// test262/test/intl402/RelativeTimeFormat/constructor/constructor/newtarget-undefined.js
|
|
@@ -283,16 +296,16 @@ var Locale = /** @class */ (function () {
|
|
|
283
296
|
if (typeof tag !== 'string' && typeof tag !== 'object') {
|
|
284
297
|
throw new TypeError('tag must be a string or object');
|
|
285
298
|
}
|
|
286
|
-
var
|
|
299
|
+
var tagInternalSlots;
|
|
287
300
|
if (typeof tag === 'object' &&
|
|
288
|
-
(
|
|
289
|
-
|
|
290
|
-
tag =
|
|
301
|
+
(tagInternalSlots = (0, get_internal_slots_1.default)(tag)) &&
|
|
302
|
+
(0, ecma402_abstract_1.HasOwnProperty)(tagInternalSlots, 'initializedLocale')) {
|
|
303
|
+
tag = tagInternalSlots.locale;
|
|
291
304
|
}
|
|
292
305
|
else {
|
|
293
306
|
tag = tag.toString();
|
|
294
307
|
}
|
|
295
|
-
internalSlots = (0, get_internal_slots_1.default)(this);
|
|
308
|
+
var internalSlots = (0, get_internal_slots_1.default)(this, internalSlotsList);
|
|
296
309
|
var options = (0, ecma402_abstract_1.CoerceOptionsToObject)(opts);
|
|
297
310
|
tag = applyOptionsToTag(tag, options);
|
|
298
311
|
var opt = Object.create(null);
|
|
@@ -310,6 +323,14 @@ var Locale = /** @class */ (function () {
|
|
|
310
323
|
}
|
|
311
324
|
}
|
|
312
325
|
opt.co = collation;
|
|
326
|
+
var fw = (0, ecma402_abstract_1.GetOption)(options, 'firstDayOfWeek', 'string', undefined, undefined);
|
|
327
|
+
if (fw !== undefined) {
|
|
328
|
+
fw = weekdayToString(fw);
|
|
329
|
+
if (!ALPHANUM_3_8.test(fw)) {
|
|
330
|
+
throw new RangeError('Invalid firstDayOfWeek');
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
opt.fw = fw;
|
|
313
334
|
var hc = (0, ecma402_abstract_1.GetOption)(options, 'hourCycle', 'string', ['h11', 'h12', 'h23', 'h24'], undefined);
|
|
314
335
|
opt.hc = hc;
|
|
315
336
|
var kf = (0, ecma402_abstract_1.GetOption)(options, 'caseFirst', 'string', ['upper', 'lower', 'false'], undefined);
|
|
@@ -331,6 +352,7 @@ var Locale = /** @class */ (function () {
|
|
|
331
352
|
internalSlots.locale = r.locale;
|
|
332
353
|
internalSlots.calendar = r.ca;
|
|
333
354
|
internalSlots.collation = r.co;
|
|
355
|
+
internalSlots.firstDayOfWeek = r.fw;
|
|
334
356
|
internalSlots.hourCycle = r.hc;
|
|
335
357
|
if (relevantExtensionKeys.indexOf('kf') > -1) {
|
|
336
358
|
internalSlots.caseFirst = r.kf;
|
|
@@ -391,13 +413,6 @@ var Locale = /** @class */ (function () {
|
|
|
391
413
|
enumerable: false,
|
|
392
414
|
configurable: true
|
|
393
415
|
});
|
|
394
|
-
Object.defineProperty(Locale.prototype, "hourCycle", {
|
|
395
|
-
get: function () {
|
|
396
|
-
return (0, get_internal_slots_1.default)(this).hourCycle;
|
|
397
|
-
},
|
|
398
|
-
enumerable: false,
|
|
399
|
-
configurable: true
|
|
400
|
-
});
|
|
401
416
|
Object.defineProperty(Locale.prototype, "caseFirst", {
|
|
402
417
|
get: function () {
|
|
403
418
|
return (0, get_internal_slots_1.default)(this).caseFirst;
|
|
@@ -452,6 +467,28 @@ var Locale = /** @class */ (function () {
|
|
|
452
467
|
enumerable: false,
|
|
453
468
|
configurable: true
|
|
454
469
|
});
|
|
470
|
+
Object.defineProperty(Locale.prototype, "firstDayOfWeek", {
|
|
471
|
+
get: function () {
|
|
472
|
+
var internalSlots = (0, get_internal_slots_1.default)(this);
|
|
473
|
+
if (!(0, ecma402_abstract_1.HasOwnProperty)(internalSlots, 'initializedLocale')) {
|
|
474
|
+
throw new TypeError('Error uninitialized locale');
|
|
475
|
+
}
|
|
476
|
+
return internalSlots.firstDayOfWeek;
|
|
477
|
+
},
|
|
478
|
+
enumerable: false,
|
|
479
|
+
configurable: true
|
|
480
|
+
});
|
|
481
|
+
Object.defineProperty(Locale.prototype, "hourCycle", {
|
|
482
|
+
get: function () {
|
|
483
|
+
var internalSlots = (0, get_internal_slots_1.default)(this);
|
|
484
|
+
if (!(0, ecma402_abstract_1.HasOwnProperty)(internalSlots, 'initializedLocale')) {
|
|
485
|
+
throw new TypeError('Error uninitialized locale');
|
|
486
|
+
}
|
|
487
|
+
return internalSlots.hourCycle;
|
|
488
|
+
},
|
|
489
|
+
enumerable: false,
|
|
490
|
+
configurable: true
|
|
491
|
+
});
|
|
455
492
|
/**
|
|
456
493
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getCalendars
|
|
457
494
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getCalendars
|
|
@@ -459,16 +496,6 @@ var Locale = /** @class */ (function () {
|
|
|
459
496
|
Locale.prototype.getCalendars = function () {
|
|
460
497
|
return calendarsOfLocale(this);
|
|
461
498
|
};
|
|
462
|
-
Object.defineProperty(Locale.prototype, "calendars", {
|
|
463
|
-
/**
|
|
464
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.calendars
|
|
465
|
-
*/
|
|
466
|
-
get: function () {
|
|
467
|
-
return calendarsOfLocale(this);
|
|
468
|
-
},
|
|
469
|
-
enumerable: false,
|
|
470
|
-
configurable: true
|
|
471
|
-
});
|
|
472
499
|
/**
|
|
473
500
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getCollations
|
|
474
501
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getCollations
|
|
@@ -476,37 +503,17 @@ var Locale = /** @class */ (function () {
|
|
|
476
503
|
Locale.prototype.getCollations = function () {
|
|
477
504
|
return collationsOfLocale(this);
|
|
478
505
|
};
|
|
479
|
-
Object.defineProperty(Locale.prototype, "collations", {
|
|
480
|
-
/**
|
|
481
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.collations
|
|
482
|
-
*/
|
|
483
|
-
get: function () {
|
|
484
|
-
return collationsOfLocale(this);
|
|
485
|
-
},
|
|
486
|
-
enumerable: false,
|
|
487
|
-
configurable: true
|
|
488
|
-
});
|
|
489
506
|
/**
|
|
490
507
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getHourCycles
|
|
491
508
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getHourCycles
|
|
492
509
|
*/
|
|
493
510
|
Locale.prototype.getHourCycles = function () {
|
|
494
|
-
var
|
|
495
|
-
if (
|
|
511
|
+
var internalSlots = (0, get_internal_slots_1.default)(this);
|
|
512
|
+
if (!(0, ecma402_abstract_1.HasOwnProperty)(internalSlots, 'initializedLocale')) {
|
|
496
513
|
throw new TypeError('Error uninitialized locale');
|
|
497
514
|
}
|
|
498
515
|
return hourCyclesOfLocale(this);
|
|
499
516
|
};
|
|
500
|
-
Object.defineProperty(Locale.prototype, "hourCycles", {
|
|
501
|
-
/**
|
|
502
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.hourCycles
|
|
503
|
-
*/
|
|
504
|
-
get: function () {
|
|
505
|
-
return hourCyclesOfLocale(this);
|
|
506
|
-
},
|
|
507
|
-
enumerable: false,
|
|
508
|
-
configurable: true
|
|
509
|
-
});
|
|
510
517
|
/**
|
|
511
518
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getNumberingSystems
|
|
512
519
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getNumberingSystems
|
|
@@ -514,16 +521,6 @@ var Locale = /** @class */ (function () {
|
|
|
514
521
|
Locale.prototype.getNumberingSystems = function () {
|
|
515
522
|
return numberingSystemsOfLocale(this);
|
|
516
523
|
};
|
|
517
|
-
Object.defineProperty(Locale.prototype, "numberingSystems", {
|
|
518
|
-
/**
|
|
519
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.numberingSystems
|
|
520
|
-
*/
|
|
521
|
-
get: function () {
|
|
522
|
-
return numberingSystemsOfLocale(this);
|
|
523
|
-
},
|
|
524
|
-
enumerable: false,
|
|
525
|
-
configurable: true
|
|
526
|
-
});
|
|
527
524
|
/**
|
|
528
525
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTimeZones
|
|
529
526
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getTimeZones
|
|
@@ -531,16 +528,6 @@ var Locale = /** @class */ (function () {
|
|
|
531
528
|
Locale.prototype.getTimeZones = function () {
|
|
532
529
|
return timeZonesOfLocale(this);
|
|
533
530
|
};
|
|
534
|
-
Object.defineProperty(Locale.prototype, "timeZones", {
|
|
535
|
-
/**
|
|
536
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.timeZones
|
|
537
|
-
*/
|
|
538
|
-
get: function () {
|
|
539
|
-
return timeZonesOfLocale(this);
|
|
540
|
-
},
|
|
541
|
-
enumerable: false,
|
|
542
|
-
configurable: true
|
|
543
|
-
});
|
|
544
531
|
/**
|
|
545
532
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo
|
|
546
533
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getTextInfo
|
|
@@ -548,93 +535,30 @@ var Locale = /** @class */ (function () {
|
|
|
548
535
|
Locale.prototype.getTextInfo = function () {
|
|
549
536
|
var info = Object.create(Object.prototype);
|
|
550
537
|
var dir = characterDirectionOfLocale(this);
|
|
551
|
-
(0, ecma402_abstract_1.
|
|
552
|
-
value: dir,
|
|
553
|
-
});
|
|
538
|
+
(0, ecma402_abstract_1.createDataProperty)(info, 'direction', dir);
|
|
554
539
|
return info;
|
|
555
540
|
};
|
|
556
|
-
Object.defineProperty(Locale.prototype, "textInfo", {
|
|
557
|
-
/**
|
|
558
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.textInfo
|
|
559
|
-
*/
|
|
560
|
-
get: function () {
|
|
561
|
-
try {
|
|
562
|
-
var info = Object.create(Object.prototype);
|
|
563
|
-
var dir = characterDirectionOfLocale(this);
|
|
564
|
-
Object.defineProperty(info, 'direction', {
|
|
565
|
-
value: dir,
|
|
566
|
-
writable: true,
|
|
567
|
-
enumerable: true,
|
|
568
|
-
configurable: true,
|
|
569
|
-
});
|
|
570
|
-
return info;
|
|
571
|
-
}
|
|
572
|
-
catch (e) {
|
|
573
|
-
throw new TypeError('Error retrieving textInfo');
|
|
574
|
-
}
|
|
575
|
-
},
|
|
576
|
-
enumerable: false,
|
|
577
|
-
configurable: true
|
|
578
|
-
});
|
|
579
541
|
/**
|
|
580
542
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo
|
|
581
543
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getWeekInfo
|
|
582
544
|
*/
|
|
583
545
|
Locale.prototype.getWeekInfo = function () {
|
|
584
546
|
var info = Object.create(Object.prototype);
|
|
585
|
-
var
|
|
586
|
-
if (
|
|
547
|
+
var internalSlots = (0, get_internal_slots_1.default)(this);
|
|
548
|
+
if (!(0, ecma402_abstract_1.HasOwnProperty)(internalSlots, 'initializedLocale')) {
|
|
587
549
|
throw new TypeError('Error uninitialized locale');
|
|
588
550
|
}
|
|
589
551
|
var wi = weekInfoOfLocale(this);
|
|
590
552
|
var we = wi.weekend;
|
|
591
|
-
(0, ecma402_abstract_1.
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
value: wi.minimalDays,
|
|
599
|
-
});
|
|
553
|
+
(0, ecma402_abstract_1.createDataProperty)(info, 'firstDay', wi.firstDay);
|
|
554
|
+
(0, ecma402_abstract_1.createDataProperty)(info, 'weekend', we);
|
|
555
|
+
(0, ecma402_abstract_1.createDataProperty)(info, 'minimalDays', wi.minimalDays);
|
|
556
|
+
var fw = internalSlots.firstDayOfWeek;
|
|
557
|
+
if (fw !== undefined) {
|
|
558
|
+
info.firstDay = fw;
|
|
559
|
+
}
|
|
600
560
|
return info;
|
|
601
561
|
};
|
|
602
|
-
Object.defineProperty(Locale.prototype, "weekInfo", {
|
|
603
|
-
/**
|
|
604
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.weekInfo
|
|
605
|
-
*/
|
|
606
|
-
get: function () {
|
|
607
|
-
try {
|
|
608
|
-
var info = Object.create(Object.prototype);
|
|
609
|
-
var wi = weekInfoOfLocale(this);
|
|
610
|
-
var we = wi.weekend;
|
|
611
|
-
Object.defineProperty(info, 'firstDay', {
|
|
612
|
-
value: wi.firstDay,
|
|
613
|
-
writable: true,
|
|
614
|
-
enumerable: true,
|
|
615
|
-
configurable: true,
|
|
616
|
-
});
|
|
617
|
-
Object.defineProperty(info, 'weekend', {
|
|
618
|
-
value: we,
|
|
619
|
-
writable: true,
|
|
620
|
-
enumerable: true,
|
|
621
|
-
configurable: true,
|
|
622
|
-
});
|
|
623
|
-
Object.defineProperty(info, 'minimalDays', {
|
|
624
|
-
value: wi.minimalDays,
|
|
625
|
-
writable: true,
|
|
626
|
-
enumerable: true,
|
|
627
|
-
configurable: true,
|
|
628
|
-
});
|
|
629
|
-
return info;
|
|
630
|
-
}
|
|
631
|
-
catch (e) {
|
|
632
|
-
throw new TypeError('Error retrieving weekInfo');
|
|
633
|
-
}
|
|
634
|
-
},
|
|
635
|
-
enumerable: false,
|
|
636
|
-
configurable: true
|
|
637
|
-
});
|
|
638
562
|
Locale.relevantExtensionKeys = RELEVANT_EXTENSION_KEYS;
|
|
639
563
|
Locale.polyfilled = true;
|
|
640
564
|
return Locale;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import Locale, { IntlLocaleInternal } from '.';
|
|
2
|
-
export default function getInternalSlots(x: Locale): IntlLocaleInternal;
|
|
2
|
+
export default function getInternalSlots(x: Locale, internalSlotsList?: string[]): IntlLocaleInternal;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
// Type-only circular import
|
|
2
2
|
// eslint-disable-next-line import/no-cycle
|
|
3
3
|
var internalSlotMap = new WeakMap();
|
|
4
|
-
export default function getInternalSlots(x) {
|
|
4
|
+
export default function getInternalSlots(x, internalSlotsList) {
|
|
5
|
+
if (internalSlotsList === void 0) { internalSlotsList = []; }
|
|
5
6
|
var internalSlots = internalSlotMap.get(x);
|
|
6
7
|
if (!internalSlots) {
|
|
7
|
-
internalSlots = Object.create(null)
|
|
8
|
+
internalSlots = Object.create(null, internalSlotsList.reduce(function (all, prop) {
|
|
9
|
+
all[prop] = {
|
|
10
|
+
enumerable: false,
|
|
11
|
+
writable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
};
|
|
14
|
+
return all;
|
|
15
|
+
}, {}));
|
|
8
16
|
internalSlotMap.set(x, internalSlots);
|
|
9
17
|
}
|
|
10
18
|
return internalSlots;
|
package/lib/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface IntlLocaleOptions {
|
|
|
8
8
|
caseFirst?: 'upper' | 'lower' | 'false';
|
|
9
9
|
numberingSystem?: string;
|
|
10
10
|
numeric?: boolean;
|
|
11
|
+
firstDayOfWeek?: string;
|
|
11
12
|
}
|
|
12
13
|
export interface IntlLocaleInternal extends IntlLocaleOptions {
|
|
13
14
|
locale: string;
|
|
@@ -27,7 +28,6 @@ export declare class Locale {
|
|
|
27
28
|
get baseName(): string;
|
|
28
29
|
get calendar(): string | undefined;
|
|
29
30
|
get collation(): string | undefined;
|
|
30
|
-
get hourCycle(): "h11" | "h12" | "h23" | "h24" | undefined;
|
|
31
31
|
get caseFirst(): "upper" | "lower" | "false" | undefined;
|
|
32
32
|
get numeric(): boolean | undefined;
|
|
33
33
|
get numberingSystem(): string | undefined;
|
|
@@ -43,70 +43,44 @@ export declare class Locale {
|
|
|
43
43
|
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.region
|
|
44
44
|
*/
|
|
45
45
|
get region(): string | undefined;
|
|
46
|
+
get firstDayOfWeek(): string | undefined;
|
|
47
|
+
get hourCycle(): "h11" | "h12" | "h23" | "h24" | undefined;
|
|
46
48
|
/**
|
|
47
49
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getCalendars
|
|
48
50
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getCalendars
|
|
49
51
|
*/
|
|
50
52
|
getCalendars(): string[];
|
|
51
|
-
/**
|
|
52
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.calendars
|
|
53
|
-
*/
|
|
54
|
-
get calendars(): string[];
|
|
55
53
|
/**
|
|
56
54
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getCollations
|
|
57
55
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getCollations
|
|
58
56
|
*/
|
|
59
57
|
getCollations(): string[];
|
|
60
|
-
/**
|
|
61
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.collations
|
|
62
|
-
*/
|
|
63
|
-
get collations(): string[];
|
|
64
58
|
/**
|
|
65
59
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getHourCycles
|
|
66
60
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getHourCycles
|
|
67
61
|
*/
|
|
68
62
|
getHourCycles(): string[];
|
|
69
|
-
/**
|
|
70
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.hourCycles
|
|
71
|
-
*/
|
|
72
|
-
get hourCycles(): string[];
|
|
73
63
|
/**
|
|
74
64
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getNumberingSystems
|
|
75
65
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getNumberingSystems
|
|
76
66
|
*/
|
|
77
67
|
getNumberingSystems(): string[];
|
|
78
|
-
/**
|
|
79
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.numberingSystems
|
|
80
|
-
*/
|
|
81
|
-
get numberingSystems(): string[];
|
|
82
68
|
/**
|
|
83
69
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTimeZones
|
|
84
70
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getTimeZones
|
|
85
71
|
*/
|
|
86
72
|
getTimeZones(): string[] | undefined;
|
|
87
|
-
/**
|
|
88
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.timeZones
|
|
89
|
-
*/
|
|
90
|
-
get timeZones(): string[] | undefined;
|
|
91
73
|
/**
|
|
92
74
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo
|
|
93
75
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getTextInfo
|
|
94
76
|
*/
|
|
95
77
|
getTextInfo(): any;
|
|
96
|
-
/**
|
|
97
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.textInfo
|
|
98
|
-
*/
|
|
99
|
-
get textInfo(): any;
|
|
100
78
|
/**
|
|
101
79
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo
|
|
102
80
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getWeekInfo
|
|
103
81
|
*/
|
|
104
82
|
getWeekInfo(): any;
|
|
105
|
-
|
|
106
|
-
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.weekInfo
|
|
107
|
-
*/
|
|
108
|
-
get weekInfo(): any;
|
|
109
|
-
static relevantExtensionKeys: readonly ["ca", "co", "hc", "kf", "kn", "nu"];
|
|
83
|
+
static relevantExtensionKeys: readonly ["ca", "co", "hc", "kf", "kn", "nu", "fw"];
|
|
110
84
|
static readonly polyfilled = true;
|
|
111
85
|
}
|
|
112
86
|
export default Locale;
|