@naturalcycles/js-lib 15.64.0 → 15.65.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/intl/intl.d.ts +20 -0
- package/dist/intl/intl.js +56 -0
- package/package.json +2 -1
- package/src/intl/intl.ts +61 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns cached Intl.* formatters, because they are known to be
|
|
3
|
+
* very slow to create.
|
|
4
|
+
*
|
|
5
|
+
* See https://github.com/poppinss/intl-formatter
|
|
6
|
+
*
|
|
7
|
+
* Methods accept non-optional arguments consciously,
|
|
8
|
+
* to be able to cache them better. Just pass {} for options.
|
|
9
|
+
*/
|
|
10
|
+
declare class MemoizedIntl {
|
|
11
|
+
DateTimeFormat(locales: Intl.LocalesArgument, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
12
|
+
RelativeTimeFormat(locales: Intl.LocalesArgument, options: Intl.RelativeTimeFormatOptions): Intl.RelativeTimeFormat;
|
|
13
|
+
NumberFormat(locales: Intl.LocalesArgument, options: Intl.NumberFormatOptions): Intl.NumberFormat;
|
|
14
|
+
Collator(locales: Intl.LocalesArgument, options: Intl.CollatorOptions): Intl.Collator;
|
|
15
|
+
PluralRules(locales: Intl.LocalesArgument, options: Intl.PluralRulesOptions): Intl.PluralRules;
|
|
16
|
+
ListFormat(locales: Intl.LocalesArgument, options: Intl.ListFormatOptions): Intl.ListFormat;
|
|
17
|
+
DisplayNames(locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames;
|
|
18
|
+
}
|
|
19
|
+
export declare const Intl2: MemoizedIntl;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
DateTimeFormat(locales, options) {
|
|
14
|
+
return new Intl.DateTimeFormat(locales, options);
|
|
15
|
+
}
|
|
16
|
+
RelativeTimeFormat(locales, options) {
|
|
17
|
+
return new Intl.RelativeTimeFormat(locales, options);
|
|
18
|
+
}
|
|
19
|
+
NumberFormat(locales, options) {
|
|
20
|
+
return new Intl.NumberFormat(locales, options);
|
|
21
|
+
}
|
|
22
|
+
Collator(locales, options) {
|
|
23
|
+
return new Intl.Collator(locales, options);
|
|
24
|
+
}
|
|
25
|
+
PluralRules(locales, options) {
|
|
26
|
+
return new Intl.PluralRules(locales, options);
|
|
27
|
+
}
|
|
28
|
+
ListFormat(locales, options) {
|
|
29
|
+
return new Intl.ListFormat(locales, options);
|
|
30
|
+
}
|
|
31
|
+
DisplayNames(locales, options) {
|
|
32
|
+
return new Intl.DisplayNames(locales, options);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
__decorate([
|
|
36
|
+
_Memo()
|
|
37
|
+
], MemoizedIntl.prototype, "DateTimeFormat", null);
|
|
38
|
+
__decorate([
|
|
39
|
+
_Memo()
|
|
40
|
+
], MemoizedIntl.prototype, "RelativeTimeFormat", null);
|
|
41
|
+
__decorate([
|
|
42
|
+
_Memo()
|
|
43
|
+
], MemoizedIntl.prototype, "NumberFormat", null);
|
|
44
|
+
__decorate([
|
|
45
|
+
_Memo()
|
|
46
|
+
], MemoizedIntl.prototype, "Collator", null);
|
|
47
|
+
__decorate([
|
|
48
|
+
_Memo()
|
|
49
|
+
], MemoizedIntl.prototype, "PluralRules", null);
|
|
50
|
+
__decorate([
|
|
51
|
+
_Memo()
|
|
52
|
+
], MemoizedIntl.prototype, "ListFormat", null);
|
|
53
|
+
__decorate([
|
|
54
|
+
_Memo()
|
|
55
|
+
], MemoizedIntl.prototype, "DisplayNames", null);
|
|
56
|
+
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.65.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",
|
package/src/intl/intl.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { _Memo } from '../decorators/memo.decorator.js'
|
|
2
|
+
|
|
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
|
+
@_Memo()
|
|
14
|
+
DateTimeFormat(
|
|
15
|
+
locales: Intl.LocalesArgument,
|
|
16
|
+
options: Intl.DateTimeFormatOptions,
|
|
17
|
+
): Intl.DateTimeFormat {
|
|
18
|
+
return new Intl.DateTimeFormat(locales, options)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@_Memo()
|
|
22
|
+
RelativeTimeFormat(
|
|
23
|
+
locales: Intl.LocalesArgument,
|
|
24
|
+
options: Intl.RelativeTimeFormatOptions,
|
|
25
|
+
): Intl.RelativeTimeFormat {
|
|
26
|
+
return new Intl.RelativeTimeFormat(locales, options)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@_Memo()
|
|
30
|
+
NumberFormat(
|
|
31
|
+
locales: Intl.LocalesArgument,
|
|
32
|
+
options: Intl.NumberFormatOptions,
|
|
33
|
+
): Intl.NumberFormat {
|
|
34
|
+
return new Intl.NumberFormat(locales, options)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@_Memo()
|
|
38
|
+
Collator(locales: Intl.LocalesArgument, options: Intl.CollatorOptions): Intl.Collator {
|
|
39
|
+
return new Intl.Collator(locales, options)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@_Memo()
|
|
43
|
+
PluralRules(locales: Intl.LocalesArgument, options: Intl.PluralRulesOptions): Intl.PluralRules {
|
|
44
|
+
return new Intl.PluralRules(locales, options)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@_Memo()
|
|
48
|
+
ListFormat(locales: Intl.LocalesArgument, options: Intl.ListFormatOptions): Intl.ListFormat {
|
|
49
|
+
return new Intl.ListFormat(locales, options)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@_Memo()
|
|
53
|
+
DisplayNames(
|
|
54
|
+
locales: Intl.LocalesArgument,
|
|
55
|
+
options: Intl.DisplayNamesOptions,
|
|
56
|
+
): Intl.DisplayNames {
|
|
57
|
+
return new Intl.DisplayNames(locales, options)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const Intl2 = new MemoizedIntl()
|