@steedos/i18n 2.5.2 → 2.5.3-beta.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.
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clearCacher = exports.getCacher = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* @Author: baozhoutao@steedos.com
|
|
6
|
+
* @Date: 2022-06-09 15:03:56
|
|
7
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
8
|
+
* @LastEditTime: 2022-06-09 15:47:58
|
|
9
|
+
* @Description:
|
|
10
|
+
*/
|
|
11
|
+
var CACHER_MAP = {};
|
|
12
|
+
var getCacher = function (name) {
|
|
13
|
+
if (!CACHER_MAP[name]) {
|
|
14
|
+
CACHER_MAP[name] = new Cacher();
|
|
15
|
+
}
|
|
16
|
+
return CACHER_MAP[name];
|
|
17
|
+
};
|
|
18
|
+
exports.getCacher = getCacher;
|
|
19
|
+
var clearCacher = function (name) {
|
|
20
|
+
if (CACHER_MAP[name]) {
|
|
21
|
+
CACHER_MAP[name].clear();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.clearCacher = clearCacher;
|
|
25
|
+
var Cacher = /** @class */ (function () {
|
|
26
|
+
function Cacher() {
|
|
27
|
+
this.cache = {};
|
|
28
|
+
this.hit = 0;
|
|
29
|
+
this.count = 0;
|
|
30
|
+
}
|
|
31
|
+
Cacher.prototype.getHitRate = function () {
|
|
32
|
+
return (this.hit / this.count * 100).toFixed(2) + "%";
|
|
33
|
+
};
|
|
34
|
+
Cacher.prototype.get = function (key) {
|
|
35
|
+
var data = this.cache[key];
|
|
36
|
+
this.count++;
|
|
37
|
+
if (data) {
|
|
38
|
+
this.hit++;
|
|
39
|
+
}
|
|
40
|
+
return data;
|
|
41
|
+
};
|
|
42
|
+
Cacher.prototype.set = function (key, value) {
|
|
43
|
+
this.cache[key] = value;
|
|
44
|
+
};
|
|
45
|
+
Cacher.prototype.clear = function () {
|
|
46
|
+
this.cache = {};
|
|
47
|
+
};
|
|
48
|
+
return Cacher;
|
|
49
|
+
}());
|
|
50
|
+
//# sourceMappingURL=cacher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cacher.js","sourceRoot":"","sources":["../../src/translations/cacher.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,IAAM,UAAU,GAAG,EAAE,CAAC;AAEf,IAAM,SAAS,GAAG,UAAU,IAAY;IAC3C,IAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAC;QACjB,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC;KACnC;IACD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC,CAAA;AALY,QAAA,SAAS,aAKrB;AAEM,IAAM,WAAW,GAAG,UAAU,IAAqB;IACtD,IAAG,UAAU,CAAC,IAAI,CAAC,EAAC;QAChB,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;KAC5B;AACL,CAAC,CAAA;AAJY,QAAA,WAAW,eAIvB;AAED;IAII;QACI,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,CAAC;IACD,2BAAU,GAAV;QACI,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;IAC1D,CAAC;IACD,oBAAG,GAAH,UAAI,GAAW;QACX,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,EAAG,CAAE;QACf,IAAG,IAAI,EAAC;YACJ,IAAI,CAAC,GAAG,EAAG,CAAC;SACf;QACD,OAAO,IAAI,CAAA;IACf,CAAC;IACD,oBAAG,GAAH,UAAI,GAAW,EAAE,KAAU;QACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC5B,CAAC;IACD,sBAAK,GAAL;QACI,IAAI,CAAC,KAAK,GAAG,EAAE,CAAA;IACnB,CAAC;IACL,aAAC;AAAD,CAAC,AA1BD,IA0BC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/i18n",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.3-beta.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"author": "",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@steedos/cachers": "2.5.
|
|
14
|
+
"@steedos/cachers": "2.5.3-beta.1",
|
|
15
15
|
"i18next": "^19.3.4",
|
|
16
16
|
"i18next-sprintf-postprocessor": "^0.2.2",
|
|
17
17
|
"underscore": "1.13.4"
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "a2e723ed4256279e8e6fa9f67d7f607c83f8638f"
|
|
26
26
|
}
|