mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
完善翻译,添加翻译缺失检查工具
This commit is contained in:
1 parent
82c193b5ee
commit
13e3e0ec98
19 files changed
+242
-90
No files matched your search
@@ -1,8 +1,10 @@
|
||||
import fs from 'fs';
|
||||
import { serialize } from 'v8';
|
||||
import cluster from 'cluster';
|
||||
import path from 'path';
|
||||
import * as superagent from 'superagent';
|
||||
import proxy from 'superagent-proxy';
|
||||
import Lru from 'lru-cache';
|
||||
|
||||
declare global {
|
||||
interface StringConstructor {
|
||||
@@ -24,6 +26,21 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
const lru = new Lru(1000);
|
||||
|
||||
export function lrucache(target: any, funcName: string, obj: any) {
|
||||
const originalMethod = obj.value;
|
||||
obj.value = function func(...args: any[]) {
|
||||
const key = serialize({ funcName, args });
|
||||
let val = lru.get(key);
|
||||
if (val) return val;
|
||||
val = originalMethod.call(this, ...args);
|
||||
lru.set(key, val);
|
||||
return val;
|
||||
};
|
||||
return obj;
|
||||
}
|
||||
|
||||
proxy(superagent);
|
||||
|
||||
if (!cluster.worker) {
|
||||
|
||||
Reference in new issue
Block a user