@naturalcycles/js-lib 15.64.0 → 15.66.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.
- package/dist/datetime/localTime.d.ts +0 -5
- package/dist/datetime/localTime.js +0 -7
- package/dist/intl/intl.d.ts +26 -0
- package/dist/intl/intl.js +66 -0
- package/package.json +2 -1
- package/src/datetime/localTime.ts +0 -8
- package/src/intl/intl.ts +71 -0
|
@@ -313,11 +313,6 @@ declare class LocalTimeFactory {
|
|
|
313
313
|
fromMillis(millis: UnixTimestampMillis): LocalTime;
|
|
314
314
|
fromDateTimeObject(o: DateTimeObjectInput): LocalTime;
|
|
315
315
|
private createDateFromDateTimeObject;
|
|
316
|
-
/**
|
|
317
|
-
* Returns the IANA timezone e.g `Europe/Stockholm`.
|
|
318
|
-
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
|
319
|
-
*/
|
|
320
|
-
getTimezone(): IANATimezone;
|
|
321
316
|
/**
|
|
322
317
|
* Returns true if passed IANA timezone is valid/supported.
|
|
323
318
|
* E.g `Europe/Stockholm` is valid, but `Europe/Stockholm2` is not.
|
|
@@ -852,13 +852,6 @@ class LocalTimeFactory {
|
|
|
852
852
|
// input,
|
|
853
853
|
// })
|
|
854
854
|
// }
|
|
855
|
-
/**
|
|
856
|
-
* Returns the IANA timezone e.g `Europe/Stockholm`.
|
|
857
|
-
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
|
858
|
-
*/
|
|
859
|
-
getTimezone() {
|
|
860
|
-
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
861
|
-
}
|
|
862
855
|
/**
|
|
863
856
|
* Returns true if passed IANA timezone is valid/supported.
|
|
864
857
|
* E.g `Europe/Stockholm` is valid, but `Europe/Stockholm2` is not.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IANATimezone } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns cached Intl.* formatters, because they are known to be
|
|
4
|
+
* very slow to create.
|
|
5
|
+
*
|
|
6
|
+
* See https://github.com/poppinss/intl-formatter
|
|
7
|
+
*
|
|
8
|
+
* Methods accept non-optional arguments consciously,
|
|
9
|
+
* to be able to cache them better. Just pass {} for options.
|
|
10
|
+
*/
|
|
11
|
+
declare class MemoizedIntl {
|
|
12
|
+
/**
|
|
13
|
+
* Returns the IANA timezone e.g `Europe/Stockholm`.
|
|
14
|
+
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
|
15
|
+
*/
|
|
16
|
+
getTimezone(): IANATimezone;
|
|
17
|
+
DateTimeFormat(locales: Intl.LocalesArgument, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
18
|
+
RelativeTimeFormat(locales: Intl.LocalesArgument, options: Intl.RelativeTimeFormatOptions): Intl.RelativeTimeFormat;
|
|
19
|
+
NumberFormat(locales: Intl.LocalesArgument, options: Intl.NumberFormatOptions): Intl.NumberFormat;
|
|
20
|
+
Collator(locales: Intl.LocalesArgument, options: Intl.CollatorOptions): Intl.Collator;
|
|
21
|
+
PluralRules(locales: Intl.LocalesArgument, options: Intl.PluralRulesOptions): Intl.PluralRules;
|
|
22
|
+
ListFormat(locales: Intl.LocalesArgument, options: Intl.ListFormatOptions): Intl.ListFormat;
|
|
23
|
+
DisplayNames(locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames;
|
|
24
|
+
}
|
|
25
|
+
export declare const Intl2: MemoizedIntl;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { _Memo } from '../decorators/memo.decorator.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns cached Intl.* formatters, because they are known to be
|
|
5
|
+
* very slow to create.
|
|
6
|
+
*
|
|
7
|
+
* See https://github.com/poppinss/intl-formatter
|
|
8
|
+
*
|
|
9
|
+
* Methods accept non-optional arguments consciously,
|
|
10
|
+
* to be able to cache them better. Just pass {} for options.
|
|
11
|
+
*/
|
|
12
|
+
class MemoizedIntl {
|
|
13
|
+
/**
|
|
14
|
+
* Returns the IANA timezone e.g `Europe/Stockholm`.
|
|
15
|
+
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
|
16
|
+
*/
|
|
17
|
+
getTimezone() {
|
|
18
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
19
|
+
}
|
|
20
|
+
DateTimeFormat(locales, options) {
|
|
21
|
+
return new Intl.DateTimeFormat(locales, options);
|
|
22
|
+
}
|
|
23
|
+
RelativeTimeFormat(locales, options) {
|
|
24
|
+
return new Intl.RelativeTimeFormat(locales, options);
|
|
25
|
+
}
|
|
26
|
+
NumberFormat(locales, options) {
|
|
27
|
+
return new Intl.NumberFormat(locales, options);
|
|
28
|
+
}
|
|
29
|
+
Collator(locales, options) {
|
|
30
|
+
return new Intl.Collator(locales, options);
|
|
31
|
+
}
|
|
32
|
+
PluralRules(locales, options) {
|
|
33
|
+
return new Intl.PluralRules(locales, options);
|
|
34
|
+
}
|
|
35
|
+
ListFormat(locales, options) {
|
|
36
|
+
return new Intl.ListFormat(locales, options);
|
|
37
|
+
}
|
|
38
|
+
DisplayNames(locales, options) {
|
|
39
|
+
return new Intl.DisplayNames(locales, options);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
__decorate([
|
|
43
|
+
_Memo()
|
|
44
|
+
], MemoizedIntl.prototype, "getTimezone", null);
|
|
45
|
+
__decorate([
|
|
46
|
+
_Memo()
|
|
47
|
+
], MemoizedIntl.prototype, "DateTimeFormat", null);
|
|
48
|
+
__decorate([
|
|
49
|
+
_Memo()
|
|
50
|
+
], MemoizedIntl.prototype, "RelativeTimeFormat", null);
|
|
51
|
+
__decorate([
|
|
52
|
+
_Memo()
|
|
53
|
+
], MemoizedIntl.prototype, "NumberFormat", null);
|
|
54
|
+
__decorate([
|
|
55
|
+
_Memo()
|
|
56
|
+
], MemoizedIntl.prototype, "Collator", null);
|
|
57
|
+
__decorate([
|
|
58
|
+
_Memo()
|
|
59
|
+
], MemoizedIntl.prototype, "PluralRules", null);
|
|
60
|
+
__decorate([
|
|
61
|
+
_Memo()
|
|
62
|
+
], MemoizedIntl.prototype, "ListFormat", null);
|
|
63
|
+
__decorate([
|
|
64
|
+
_Memo()
|
|
65
|
+
], MemoizedIntl.prototype, "DisplayNames", null);
|
|
66
|
+
export const Intl2 = new MemoizedIntl();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/js-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.66.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"tslib": "^2"
|
|
7
7
|
},
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"./error": "./dist/error/index.js",
|
|
41
41
|
"./error/*.js": "./dist/error/*.js",
|
|
42
42
|
"./http": "./dist/http/index.js",
|
|
43
|
+
"./intl": "./dist/intl/intl.js",
|
|
43
44
|
"./log": "./dist/log/commonLogger.js",
|
|
44
45
|
"./math": "./dist/math/index.js",
|
|
45
46
|
"./math/*.js": "./dist/math/*.js",
|
|
@@ -1000,14 +1000,6 @@ class LocalTimeFactory {
|
|
|
1000
1000
|
// })
|
|
1001
1001
|
// }
|
|
1002
1002
|
|
|
1003
|
-
/**
|
|
1004
|
-
* Returns the IANA timezone e.g `Europe/Stockholm`.
|
|
1005
|
-
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
|
1006
|
-
*/
|
|
1007
|
-
getTimezone(): IANATimezone {
|
|
1008
|
-
return Intl.DateTimeFormat().resolvedOptions().timeZone as IANATimezone
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
1003
|
/**
|
|
1012
1004
|
* Returns true if passed IANA timezone is valid/supported.
|
|
1013
1005
|
* E.g `Europe/Stockholm` is valid, but `Europe/Stockholm2` is not.
|
package/src/intl/intl.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { _Memo } from '../decorators/memo.decorator.js'
|
|
2
|
+
import type { IANATimezone } from '../types.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns cached Intl.* formatters, because they are known to be
|
|
6
|
+
* very slow to create.
|
|
7
|
+
*
|
|
8
|
+
* See https://github.com/poppinss/intl-formatter
|
|
9
|
+
*
|
|
10
|
+
* Methods accept non-optional arguments consciously,
|
|
11
|
+
* to be able to cache them better. Just pass {} for options.
|
|
12
|
+
*/
|
|
13
|
+
class MemoizedIntl {
|
|
14
|
+
/**
|
|
15
|
+
* Returns the IANA timezone e.g `Europe/Stockholm`.
|
|
16
|
+
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
|
17
|
+
*/
|
|
18
|
+
@_Memo()
|
|
19
|
+
getTimezone(): IANATimezone {
|
|
20
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone as IANATimezone
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@_Memo()
|
|
24
|
+
DateTimeFormat(
|
|
25
|
+
locales: Intl.LocalesArgument,
|
|
26
|
+
options: Intl.DateTimeFormatOptions,
|
|
27
|
+
): Intl.DateTimeFormat {
|
|
28
|
+
return new Intl.DateTimeFormat(locales, options)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@_Memo()
|
|
32
|
+
RelativeTimeFormat(
|
|
33
|
+
locales: Intl.LocalesArgument,
|
|
34
|
+
options: Intl.RelativeTimeFormatOptions,
|
|
35
|
+
): Intl.RelativeTimeFormat {
|
|
36
|
+
return new Intl.RelativeTimeFormat(locales, options)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@_Memo()
|
|
40
|
+
NumberFormat(
|
|
41
|
+
locales: Intl.LocalesArgument,
|
|
42
|
+
options: Intl.NumberFormatOptions,
|
|
43
|
+
): Intl.NumberFormat {
|
|
44
|
+
return new Intl.NumberFormat(locales, options)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@_Memo()
|
|
48
|
+
Collator(locales: Intl.LocalesArgument, options: Intl.CollatorOptions): Intl.Collator {
|
|
49
|
+
return new Intl.Collator(locales, options)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@_Memo()
|
|
53
|
+
PluralRules(locales: Intl.LocalesArgument, options: Intl.PluralRulesOptions): Intl.PluralRules {
|
|
54
|
+
return new Intl.PluralRules(locales, options)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@_Memo()
|
|
58
|
+
ListFormat(locales: Intl.LocalesArgument, options: Intl.ListFormatOptions): Intl.ListFormat {
|
|
59
|
+
return new Intl.ListFormat(locales, options)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@_Memo()
|
|
63
|
+
DisplayNames(
|
|
64
|
+
locales: Intl.LocalesArgument,
|
|
65
|
+
options: Intl.DisplayNamesOptions,
|
|
66
|
+
): Intl.DisplayNames {
|
|
67
|
+
return new Intl.DisplayNames(locales, options)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const Intl2 = new MemoizedIntl()
|