@vtj/base 0.12.0 → 0.12.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/base",
3
3
  "private": false,
4
- "version": "0.12.0",
4
+ "version": "0.12.2",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "低代码引擎",
package/types/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export * from './data';
8
8
  export * from './lz-string';
9
9
  export * from './mitt';
10
10
  export * from './path-to-regexp';
11
+ export * from './queue';
package/types/lodash.d.ts CHANGED
@@ -1,2 +1,105 @@
1
+ /**
2
+ * 导出常用的lodash工具函数
3
+ *
4
+ * 每个函数的说明和示例:
5
+ *
6
+ * isString(value: any): boolean - 检查值是否为字符串
7
+ * 示例: isString('hello') // => true
8
+ *
9
+ * isFunction(value: any): boolean - 检查值是否为函数
10
+ * 示例: isFunction(() => {}) // => true
11
+ *
12
+ * isArray(value: any): boolean - 检查值是否为数组
13
+ * 示例: isArray([1, 2, 3]) // => true
14
+ *
15
+ * isObject(value: any): boolean - 检查值是否为对象(非null)
16
+ * 示例: isObject({}) // => true
17
+ *
18
+ * isBoolean(value: any): boolean - 检查值是否为布尔值
19
+ * 示例: isBoolean(true) // => true
20
+ *
21
+ * isBuffer(value: any): boolean - 检查值是否为Buffer
22
+ * 示例: isBuffer(Buffer.from('hello')) // => true
23
+ *
24
+ * isArrayBuffer(value: any): boolean - 检查值是否为ArrayBuffer
25
+ * 示例: isArrayBuffer(new ArrayBuffer(8)) // => true
26
+ *
27
+ * isDate(value: any): boolean - 检查值是否为Date对象
28
+ * 示例: isDate(new Date()) // => true
29
+ *
30
+ * isUndefined(value: any): boolean - 检查值是否为undefined
31
+ * 示例: isUndefined(undefined) // => true
32
+ *
33
+ * isNaN(value: any): boolean - 检查值是否为NaN
34
+ * 示例: isNaN(NaN) // => true
35
+ *
36
+ * isNull(value: any): boolean - 检查值是否为null
37
+ * 示例: isNull(null) // => true
38
+ *
39
+ * isNumber(value: any): boolean - 检查值是否为数字
40
+ * 示例: isNumber(42) // => true
41
+ *
42
+ * isSymbol(value: any): boolean - 检查值是否为Symbol
43
+ * 示例: isSymbol(Symbol('foo')) // => true
44
+ *
45
+ * isPlainObject(value: any): boolean - 检查值是否为纯对象
46
+ * 示例: isPlainObject({}) // => true
47
+ *
48
+ * isEqual(value: any, other: any): boolean - 深度比较两个值是否相等
49
+ * 示例: isEqual({a: 1}, {a: 1}) // => true
50
+ *
51
+ * noop(): void - 空操作函数
52
+ * 示例: noop() // => undefined
53
+ *
54
+ * upperFirst(string: string): string - 首字母大写
55
+ * 示例: upperFirst('hello') // => 'Hello'
56
+ *
57
+ * camelCase(string: string): string - 转换为驼峰命名
58
+ * 示例: camelCase('hello-world') // => 'helloWorld'
59
+ *
60
+ * get(object: Object, path: string, defaultValue: any): any - 获取对象属性值
61
+ * 示例: get({a: {b: 1}}, 'a.b') // => 1
62
+ *
63
+ * set(object: Object, path: string, value: any): Object - 设置对象属性值
64
+ * 示例: set({}, 'a.b', 1) // => {a: {b: 1}}
65
+ *
66
+ * cloneDeep(value: any): any - 深拷贝
67
+ * 示例: cloneDeep({a: 1}) // => {a: 1}
68
+ *
69
+ * merge(object: Object, ...sources: Object[]): Object - 深度合并对象
70
+ * 示例: merge({a: 1}, {b: 2}) // => {a: 1, b: 2}
71
+ *
72
+ * debounce(func: Function, wait: number, options: Object): Function - 防抖函数
73
+ * 示例: const debounced = debounce(() => console.log('hello'), 100)
74
+ *
75
+ * throttle(func: Function, wait: number, options: Object): Function - 节流函数
76
+ * 示例: const throttled = throttle(() => console.log('hello'), 100)
77
+ *
78
+ * template(string: string, options: Object): Function - 模板函数
79
+ * 示例: const compiled = template('hello <%= user %>!')
80
+ * compiled({user: 'world'}) // => 'hello world!'
81
+ *
82
+ * lowerFirst(string: string): string - 首字母小写
83
+ * 示例: lowerFirst('Hello') // => 'hello'
84
+ *
85
+ * kebabCase(string: string): string - 转换为短横线命名(kebab-case)
86
+ * 示例: kebabCase('helloWorld') // => 'hello-world'
87
+ *
88
+ * snakeCase(string: string): string - 转换为蛇形命名(snake_case)
89
+ * 示例: snakeCase('helloWorld') // => 'hello_world'
90
+ *
91
+ * groupBy(collection: Array|Object, iteratee: Function|string): Object - 根据条件分组
92
+ * 示例: groupBy([1.1, 1.2, 2.3], Math.floor) // => {1: [1.1, 1.2], 2: [2.3]}
93
+ */
1
94
  export { isString, isFunction, isArray, isObject, isBoolean, isBuffer, isArrayBuffer, isDate, isUndefined, isNaN, isNull, isNumber, isSymbol, isPlainObject, isEqual, noop, upperFirst, camelCase, get, set, cloneDeep, merge, debounce, throttle, template, lowerFirst, kebabCase, snakeCase, groupBy } from 'lodash-es';
95
+ /**
96
+ * 将字符串转换为首字母大写的驼峰命名形式
97
+ * @param name - 需要转换的字符串
98
+ * @returns 转换后的字符串
99
+ *
100
+ * 示例:
101
+ * upperFirstCamelCase('hello-world') // => 'HelloWorld'
102
+ * upperFirstCamelCase('hello_world') // => 'HelloWorld'
103
+ * upperFirstCamelCase('hello world') // => 'HelloWorld'
104
+ */
2
105
  export declare function upperFirstCamelCase(name: string): Capitalize<string>;
@@ -0,0 +1,44 @@
1
+ export declare class Queue {
2
+ private queue;
3
+ private isProcessing;
4
+ private results;
5
+ private cache;
6
+ private pendingTasks;
7
+ /**
8
+ * 添加任务到队列
9
+ * @param key 任务唯一标识符(用于缓存)
10
+ * @param task 要执行的任务函数
11
+ * @returns 任务结果的Promise
12
+ */
13
+ add<T>(key: string | symbol, task: () => Promise<T>): Promise<T>;
14
+ /**
15
+ * 获取所有已完成任务的结果
16
+ * @returns 所有任务结果的副本
17
+ */
18
+ getAllResults(): {
19
+ key: string | symbol;
20
+ status: "fulfilled" | "rejected";
21
+ value?: any;
22
+ reason?: any;
23
+ }[];
24
+ /**
25
+ * 获取特定任务的结果
26
+ * @param key 任务键
27
+ * @returns 任务结果或undefined
28
+ */
29
+ getResult(key: string | symbol): {
30
+ status: "fulfilled" | "rejected";
31
+ value?: any;
32
+ reason?: any;
33
+ };
34
+ /**
35
+ * 清除特定任务的缓存
36
+ * @param key 要清除的任务键
37
+ */
38
+ clearCacheForKey(key: string | symbol): void;
39
+ /**
40
+ * 清除所有缓存
41
+ */
42
+ clearAllCache(): void;
43
+ private processQueue;
44
+ }