@partex/one-core 2.0.102 → 2.0.104
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/lib/components/hooks/index.d.ts +2 -0
- package/lib/components/hooks/memoryCache.d.ts +50 -0
- package/lib/components/hooks/useDebounceFn.d.ts +10 -0
- package/lib/components/hooks/useThrottleFn.d.ts +10 -0
- package/lib/components/hooks/utils.d.ts +15 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/one-core.cjs +15 -15
- package/lib/one-core.js +173 -157
- package/lib/one-core.umd.cjs +15 -15
- package/lib/style.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
interface Timer {
|
|
3
|
+
[key: string]: NodeJS.Timeout;
|
|
4
|
+
}
|
|
5
|
+
interface Options {
|
|
6
|
+
maxCache?: number;
|
|
7
|
+
}
|
|
8
|
+
declare class MemoryCache {
|
|
9
|
+
memoryCache: Map<string, any>;
|
|
10
|
+
timer: Timer;
|
|
11
|
+
maxCache: number;
|
|
12
|
+
constructor(options?: Options);
|
|
13
|
+
/**
|
|
14
|
+
* 增加缓存
|
|
15
|
+
* @param key
|
|
16
|
+
* @param value
|
|
17
|
+
* @param time
|
|
18
|
+
* @param timeoutCallback
|
|
19
|
+
*/
|
|
20
|
+
put(key: string, value: any, time?: number, timeoutCallback?: () => null): void;
|
|
21
|
+
/**
|
|
22
|
+
* 获取缓存
|
|
23
|
+
* @param key
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
get(key: string): any;
|
|
27
|
+
/**
|
|
28
|
+
* 判断是否有缓存
|
|
29
|
+
* @param key
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
has(key: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 删除缓存
|
|
35
|
+
* @param key
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
del(key: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* 清除缓存
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
clear(): void;
|
|
44
|
+
/**
|
|
45
|
+
* 获取缓存条数
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
size(): number;
|
|
49
|
+
}
|
|
50
|
+
export default MemoryCache;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type Fn = (...[]: any[]) => any;
|
|
2
|
+
/**
|
|
3
|
+
* 防抖
|
|
4
|
+
* @param fn
|
|
5
|
+
* @param delay
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const debounce: (fn: Fn, delay: number) => () => void;
|
|
9
|
+
/**
|
|
10
|
+
* 节流
|
|
11
|
+
* @param fn
|
|
12
|
+
* @param delay
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare const throttle: (fn: Fn, wait?: number) => Fn;
|