@partex/one-core 2.0.103 → 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.
@@ -0,0 +1,2 @@
1
+ export { useDebounceFn } from './useDebounceFn';
2
+ export { useThrottleFn } from './useThrottleFn';
@@ -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,10 @@
1
+ import type { Fn } from './utils';
2
+ /**
3
+ * 处理防抖函数
4
+ * @param fn
5
+ * @param delay
6
+ * @returns
7
+ */
8
+ export declare const useDebounceFn: (fn: Fn, delay?: number) => {
9
+ run: () => void;
10
+ };
@@ -0,0 +1,10 @@
1
+ import type { Fn } from './utils';
2
+ /**
3
+ * 处理节流函数
4
+ * @param fn
5
+ * @param delay
6
+ * @returns
7
+ */
8
+ export declare const useThrottleFn: (fn: Fn, delay?: number) => {
9
+ run: Fn;
10
+ };
@@ -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;
@@ -6,5 +6,6 @@ export * from './common';
6
6
  export * from './scale';
7
7
  export * from './fetch';
8
8
  export * from './role';
9
+ export * from './hooks';
9
10
  export { default, install } from './preset';
10
11
  export { default as create } from './create';