@esmx/core 3.0.0-rc.60 → 3.0.0-rc.63

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.
@@ -1,21 +1,21 @@
1
1
  /**
2
- * 缓存处理函数的类型定义
2
+ * Type definition for cache handling function
3
3
  *
4
- * @template T - 缓存数据的类型
5
- * @param name - 缓存项的唯一标识符
6
- * @param fetch - 获取数据的异步函数
7
- * @returns 返回缓存的数据或新获取的数据
4
+ * @template T - Type of cached data
5
+ * @param name - Unique identifier for the cache item
6
+ * @param fetch - Asynchronous function to fetch data
7
+ * @returns Returns cached data or newly fetched data
8
8
  *
9
9
  * @example
10
10
  * ```ts
11
11
  * const cache = createCache(true);
12
12
  *
13
- * // 第一次调用会执行 fetch 函数
13
+ * // First call will execute the fetch function
14
14
  * const data1 = await cache('key', async () => {
15
15
  * return await fetchSomeData();
16
16
  * });
17
17
  *
18
- * // 第二次调用会直接返回缓存的结果
18
+ * // Second call will directly return the cached result
19
19
  * const data2 = await cache('key', async () => {
20
20
  * return await fetchSomeData();
21
21
  * });
@@ -27,24 +27,24 @@ export type CacheHandle = <T>(
27
27
  ) => Promise<T>;
28
28
 
29
29
  /**
30
- * 创建一个缓存处理函数
30
+ * Create a cache handling function
31
31
  *
32
- * @param enable - 是否启用缓存功能
33
- * @returns 返回一个缓存处理函数
32
+ * @param enable - Whether to enable caching functionality
33
+ * @returns Returns a cache handling function
34
34
  *
35
35
  * @description
36
- * enable true 时,会创建一个带有内存缓存的处理函数,相同的 name 只会执行一次 fetch
37
- * enable false 时,每次调用都会执行 fetch 函数,不会缓存结果。
36
+ * When enable is true, it creates a processing function with memory cache, the same name will only execute fetch once.
37
+ * When enable is false, each call will execute the fetch function and will not cache the result.
38
38
  *
39
39
  * @example
40
40
  * ```ts
41
- * // 创建一个启用缓存的处理函数
41
+ * // Create a cache-enabled processing function
42
42
  * const cacheEnabled = createCache(true);
43
43
  *
44
- * // 创建一个禁用缓存的处理函数
44
+ * // Create a cache-disabled processing function
45
45
  * const cacheDisabled = createCache(false);
46
46
  *
47
- * // 使用缓存处理函数
47
+ * // Use the cache processing function
48
48
  * const result = await cacheEnabled('userProfile', async () => {
49
49
  * return await fetchUserProfile(userId);
50
50
  * });