@pawover/kit 0.0.0-alpha.15 → 0.0.0-alpha.16

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,7 +1,7 @@
1
1
  import { useEffect, useRef, useState } from "react";
2
2
 
3
- //#region src/utils/typeof.ts
4
- const prototypes = {
3
+ //#region src/utils/typeof/types.ts
4
+ const prototypeStrings = {
5
5
  string: "[object String]",
6
6
  number: "[object Number]",
7
7
  boolean: "[object Boolean]",
@@ -30,22 +30,9 @@ const prototypes = {
30
30
  function resolvePrototypeString(value) {
31
31
  return Object.prototype.toString.call(value);
32
32
  }
33
- function isObject(value) {
34
- return resolvePrototypeString(value) === prototypes.object;
35
- }
36
- function isFunction(value) {
37
- return [
38
- prototypes.function,
39
- prototypes.generatorFunction,
40
- prototypes.asyncFunction
41
- ].includes(resolvePrototypeString(value));
42
- }
43
- function isPromise(value) {
44
- return resolvePrototypeString(value) === prototypes.promise;
45
- }
46
- function isPromiseLike(value) {
47
- return isPromise(value) || isObject(value) && isFunction(value["then"]);
48
- }
33
+
34
+ //#endregion
35
+ //#region src/utils/typeof/isEqual.ts
49
36
  /**
50
37
  * 判断给定的值是否相等
51
38
  * @reference https://github.com/radashi-org/radashi/blob/main/src/typed/isEqual.ts
@@ -68,6 +55,34 @@ function isEqual(x, y) {
68
55
  return true;
69
56
  }
70
57
 
58
+ //#endregion
59
+ //#region src/utils/typeof/isFunction.ts
60
+ function isFunction(value) {
61
+ return [
62
+ prototypeStrings.function,
63
+ prototypeStrings.generatorFunction,
64
+ prototypeStrings.asyncFunction
65
+ ].includes(resolvePrototypeString(value));
66
+ }
67
+
68
+ //#endregion
69
+ //#region src/utils/typeof/isObject.ts
70
+ function isObject(value) {
71
+ return resolvePrototypeString(value) === prototypeStrings.object;
72
+ }
73
+
74
+ //#endregion
75
+ //#region src/utils/typeof/isPromise.ts
76
+ function isPromise(value) {
77
+ return resolvePrototypeString(value) === prototypeStrings.promise;
78
+ }
79
+
80
+ //#endregion
81
+ //#region src/utils/typeof/isPromiseLike.ts
82
+ function isPromiseLike(value) {
83
+ return isPromise(value) || isObject(value) && isFunction(value["then"]);
84
+ }
85
+
71
86
  //#endregion
72
87
  //#region src/utils/object/objectKeys.ts
73
88
  /**
package/dist/index.d.ts CHANGED
@@ -98,7 +98,14 @@ declare function arrayReplace<T>(initialList: readonly T[], newItem: T, match: (
98
98
  */
99
99
  declare function arraySplit<T>(initialList: readonly T[], size?: number): T[][];
100
100
  //#endregion
101
- //#region src/utils/cloneDeep.d.ts
101
+ //#region src/utils/function/to.d.ts
102
+ /**
103
+ * @param promise
104
+ * @param errorExt - 可以传递给err对象的其他信息
105
+ */
106
+ declare function to<T, U = Error>(promise: Readonly<Promise<T>>, errorExt?: UnknownObject): Promise<[U, undefined] | [null, T]>;
107
+ //#endregion
108
+ //#region src/utils/object/cloneDeep.d.ts
102
109
  interface CloningStrategy {
103
110
  cloneMap: <K, V>(parent: Map<K, V>, track: (newParent: Map<K, V>) => Map<K, V>, clone: <T>(value: T) => T) => Map<K, V> | null;
104
111
  cloneSet: <T>(parent: Set<T>, track: (newParent: Set<T>) => Set<T>, clone: <T>(value: T) => T) => Set<T> | null;
@@ -197,13 +204,6 @@ declare function stringToJson<R extends AnyObject = AnyObject, D extends R = R>(
197
204
  //#region src/utils/string/stringToValues.d.ts
198
205
  declare function stringToValues<T extends number | string = number>(data: string | null | undefined, valueType?: "number" | "string", splitSymbol?: string): T[];
199
206
  //#endregion
200
- //#region src/utils/to.d.ts
201
- /**
202
- * @param promise
203
- * @param errorExt - 可以传递给err对象的其他信息
204
- */
205
- declare function to<T, U = Error>(promise: Readonly<Promise<T>>, errorExt?: UnknownObject): Promise<[U, undefined] | [null, T]>;
206
- //#endregion
207
207
  //#region src/utils/tree/types.d.ts
208
208
  type RowKey = "id";
209
209
  type ParentIdKey = "parentId";
@@ -262,35 +262,25 @@ type TreeToRowsOptions<T extends AnyObject, CK extends string = ChildrenKey> = T
262
262
  */
263
263
  declare function treeToRows<T extends AnyObject, CK extends string = ChildrenKey, R extends AnyObject = SetOptional<T, CK>>(tree: T | T[], options?: TreeToRowsOptions<T, CK>): R[];
264
264
  //#endregion
265
- //#region src/utils/typeof.d.ts
266
- declare function isString<T extends string>(value: unknown): value is T;
267
- declare function isNumber<T extends number>(value: unknown): value is T;
268
- declare function isBoolean<T extends boolean>(value: unknown): value is T;
269
- declare function isObject<T extends Record<PropertyKey, unknown>>(value: unknown): value is T;
265
+ //#region src/utils/typeof/isArray.d.ts
270
266
  declare function isArray<T extends unknown[]>(value: unknown): value is T;
271
- declare function isBigInt<T extends bigint>(value: unknown): value is T;
272
- declare function isSymbol<T extends symbol>(value: unknown): value is T;
273
- declare function isFunction<T extends Func>(value: unknown): value is T;
274
- declare function isGeneratorFunction<T extends Func>(value: unknown): value is T;
267
+ //#endregion
268
+ //#region src/utils/typeof/isAsyncFunction.d.ts
275
269
  declare function isAsyncFunction<T extends AsyncFunc>(value: unknown): value is T;
276
- declare function isPromise<T extends Promise<unknown>>(value: unknown): value is T;
277
- declare function isPromiseLike<T extends PromiseLike<unknown>>(value: unknown): value is T;
278
- declare function isNull<T extends null>(value: unknown): value is T;
279
- declare function isUndefined<T extends undefined>(value: unknown): value is T;
280
- declare function isDate<T extends Date>(value: unknown): value is T;
281
- declare function isRegExp<T extends RegExp>(value: unknown): value is T;
282
- declare function isError<T extends Error>(value: unknown): value is T;
283
- declare function isFile<T extends File>(value: unknown): value is T;
284
- declare function isMap<T extends Map<unknown, unknown>>(value: unknown): value is T;
285
- declare function isWeakMap<T extends WeakMap<AnyObject, unknown>>(value: unknown): value is T;
286
- declare function isSet<T extends Set<unknown>>(value: unknown): value is T;
287
- declare function isWeakSet<T extends WeakSet<AnyObject>>(value: unknown): value is T;
288
- declare function isWindow<T extends Window>(value: unknown): value is T;
289
- declare function isWebSocket<T extends WebSocket>(value: unknown): value is T;
290
- declare function isURLSearchParams<T extends Window>(value: unknown): value is T;
270
+ //#endregion
271
+ //#region src/utils/typeof/isBigInt.d.ts
272
+ declare function isBigInt<T extends bigint>(value: unknown): value is T;
273
+ //#endregion
274
+ //#region src/utils/typeof/isBoolean.d.ts
275
+ declare function isBoolean<T extends boolean>(value: unknown): value is T;
276
+ //#endregion
277
+ //#region src/utils/typeof/isClass.d.ts
291
278
  declare function isClass<T extends Class<AnyObject>>(value: unknown): value is T;
292
- declare function isInteger<T extends number>(value: unknown): value is T;
293
- declare function isIterable<T extends Iterable<unknown>>(value: unknown): value is T;
279
+ //#endregion
280
+ //#region src/utils/typeof/isDate.d.ts
281
+ declare function isDate<T extends Date>(value: unknown): value is T;
282
+ //#endregion
283
+ //#region src/utils/typeof/isEqual.d.ts
294
284
  /**
295
285
  * 判断给定的值是否相等
296
286
  * @reference https://github.com/radashi-org/radashi/blob/main/src/typed/isEqual.ts
@@ -300,4 +290,99 @@ declare function isIterable<T extends Iterable<unknown>>(value: unknown): value
300
290
  */
301
291
  declare function isEqual<T>(x: T, y: T): boolean;
302
292
  //#endregion
303
- export { arrayCast, arrayCompete, arrayCounting, arrayDiff, arrayFirst, arrayFork, arrayLast, arrayMerge, arrayPick, arrayReplace, arraySplit, cloneDeep, enumEntries, enumKeys, enumTypeCheck, enumValues, isArray, isAsyncFunction, isBigInt, isBoolean, isClass, isDate, isEqual, isError, isFile, isFunction, isGeneratorFunction, isInteger, isIterable, isMap, isNull, isNumber, isObject, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isURLSearchParams, isUndefined, isWeakMap, isWeakSet, isWebSocket, isWindow, mapEntries, objectAssign, objectEntries, objectKeys, objectPick, objectSwitch, objectValues, rowsToTree, stringInitialCase, stringReplace, stringToJson, stringToValues, to, treeFilter, treeFind, treeForEach, treeMap, treeToRows };
293
+ //#region src/utils/typeof/isError.d.ts
294
+ declare function isError<T extends Error>(value: unknown): value is T;
295
+ //#endregion
296
+ //#region src/utils/typeof/isFile.d.ts
297
+ declare function isFile<T extends File>(value: unknown): value is T;
298
+ //#endregion
299
+ //#region src/utils/typeof/isFunction.d.ts
300
+ declare function isFunction<T extends Func>(value: unknown): value is T;
301
+ //#endregion
302
+ //#region src/utils/typeof/isGeneratorFunction.d.ts
303
+ declare function isGeneratorFunction<T extends Func>(value: unknown): value is T;
304
+ //#endregion
305
+ //#region src/utils/typeof/isInteger.d.ts
306
+ declare function isInteger<T extends number>(value: unknown): value is T;
307
+ //#endregion
308
+ //#region src/utils/typeof/isIterable.d.ts
309
+ declare function isIterable<T extends Iterable<unknown>>(value: unknown): value is T;
310
+ //#endregion
311
+ //#region src/utils/typeof/isMap.d.ts
312
+ declare function isMap<T extends Map<unknown, unknown>>(value: unknown): value is T;
313
+ //#endregion
314
+ //#region src/utils/typeof/isNull.d.ts
315
+ declare function isNull<T extends null>(value: unknown): value is T;
316
+ //#endregion
317
+ //#region src/utils/typeof/isNumber.d.ts
318
+ declare function isNumber<T extends number>(value: unknown): value is T;
319
+ //#endregion
320
+ //#region src/utils/typeof/isObject.d.ts
321
+ declare function isObject<T extends Record<PropertyKey, unknown>>(value: unknown): value is T;
322
+ //#endregion
323
+ //#region src/utils/typeof/isPromise.d.ts
324
+ declare function isPromise<T extends Promise<unknown>>(value: unknown): value is T;
325
+ //#endregion
326
+ //#region src/utils/typeof/isPromiseLike.d.ts
327
+ declare function isPromiseLike<T extends PromiseLike<unknown>>(value: unknown): value is T;
328
+ //#endregion
329
+ //#region src/utils/typeof/isRegExp.d.ts
330
+ declare function isRegExp<T extends RegExp>(value: unknown): value is T;
331
+ //#endregion
332
+ //#region src/utils/typeof/isSet.d.ts
333
+ declare function isSet<T extends Set<unknown>>(value: unknown): value is T;
334
+ //#endregion
335
+ //#region src/utils/typeof/isString.d.ts
336
+ declare function isString<T extends string>(value: unknown): value is T;
337
+ //#endregion
338
+ //#region src/utils/typeof/isSymbol.d.ts
339
+ declare function isSymbol<T extends symbol>(value: unknown): value is T;
340
+ //#endregion
341
+ //#region src/utils/typeof/isUndefined.d.ts
342
+ declare function isUndefined<T extends undefined>(value: unknown): value is T;
343
+ //#endregion
344
+ //#region src/utils/typeof/isURLSearchParams.d.ts
345
+ declare function isURLSearchParams<T extends Window>(value: unknown): value is T;
346
+ //#endregion
347
+ //#region src/utils/typeof/isWeakMap.d.ts
348
+ declare function isWeakMap<T extends WeakMap<AnyObject, unknown>>(value: unknown): value is T;
349
+ //#endregion
350
+ //#region src/utils/typeof/isWeakSet.d.ts
351
+ declare function isWeakSet<T extends WeakSet<AnyObject>>(value: unknown): value is T;
352
+ //#endregion
353
+ //#region src/utils/typeof/isWebSocket.d.ts
354
+ declare function isWebSocket<T extends WebSocket>(value: unknown): value is T;
355
+ //#endregion
356
+ //#region src/utils/typeof/isWindow.d.ts
357
+ declare function isWindow<T extends Window>(value: unknown): value is T;
358
+ //#endregion
359
+ //#region src/utils/typeof/types.d.ts
360
+ declare const prototypeStrings: {
361
+ readonly string: "[object String]";
362
+ readonly number: "[object Number]";
363
+ readonly boolean: "[object Boolean]";
364
+ readonly object: "[object Object]";
365
+ readonly array: "[object Array]";
366
+ readonly bigInt: "[object BigInt]";
367
+ readonly symbol: "[object Symbol]";
368
+ readonly function: "[object Function]";
369
+ readonly generatorFunction: "[object GeneratorFunction]";
370
+ readonly asyncFunction: "[object AsyncFunction]";
371
+ readonly promise: "[object Promise]";
372
+ readonly null: "[object Null]";
373
+ readonly undefined: "[object Undefined]";
374
+ readonly date: "[object Date]";
375
+ readonly regExp: "[object RegExp]";
376
+ readonly error: "[object Error]";
377
+ readonly file: "[object File]";
378
+ readonly map: "[object Map]";
379
+ readonly weakMap: "[object WeakMap]";
380
+ readonly set: "[object Set]";
381
+ readonly weakSet: "[object WeakSet]";
382
+ readonly window: "[object Window]";
383
+ readonly webSocket: "[object WebSocket]";
384
+ readonly URLSearchParams: "[object URLSearchParams]";
385
+ };
386
+ declare function resolvePrototypeString(value: unknown): string;
387
+ //#endregion
388
+ export { arrayCast, arrayCompete, arrayCounting, arrayDiff, arrayFirst, arrayFork, arrayLast, arrayMerge, arrayPick, arrayReplace, arraySplit, cloneDeep, enumEntries, enumKeys, enumTypeCheck, enumValues, isArray, isAsyncFunction, isBigInt, isBoolean, isClass, isDate, isEqual, isError, isFile, isFunction, isGeneratorFunction, isInteger, isIterable, isMap, isNull, isNumber, isObject, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isURLSearchParams, isUndefined, isWeakMap, isWeakSet, isWebSocket, isWindow, mapEntries, objectAssign, objectEntries, objectKeys, objectPick, objectSwitch, objectValues, prototypeStrings, resolvePrototypeString, rowsToTree, stringInitialCase, stringReplace, stringToJson, stringToValues, to, treeFilter, treeFind, treeForEach, treeMap, treeToRows };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- //#region src/utils/typeof.ts
2
- const prototypes = {
1
+ //#region src/utils/typeof/types.ts
2
+ const prototypeStrings = {
3
3
  string: "[object String]",
4
4
  number: "[object Number]",
5
5
  boolean: "[object Boolean]",
@@ -28,114 +28,201 @@ const prototypes = {
28
28
  function resolvePrototypeString(value) {
29
29
  return Object.prototype.toString.call(value);
30
30
  }
31
- function isString(value) {
32
- return resolvePrototypeString(value) === prototypes.string;
31
+
32
+ //#endregion
33
+ //#region src/utils/typeof/isArray.ts
34
+ function isArray(value) {
35
+ return resolvePrototypeString(value) === prototypeStrings.array;
33
36
  }
34
- function isNumber(value) {
35
- return resolvePrototypeString(value) === prototypes.number;
37
+
38
+ //#endregion
39
+ //#region src/utils/typeof/isAsyncFunction.ts
40
+ function isAsyncFunction(value) {
41
+ return resolvePrototypeString(value) === prototypeStrings.asyncFunction;
42
+ }
43
+
44
+ //#endregion
45
+ //#region src/utils/typeof/isBigInt.ts
46
+ function isBigInt(value) {
47
+ return resolvePrototypeString(value) === prototypeStrings.bigInt;
36
48
  }
49
+
50
+ //#endregion
51
+ //#region src/utils/typeof/isBoolean.ts
37
52
  function isBoolean(value) {
38
- return resolvePrototypeString(value) === prototypes.boolean;
53
+ return resolvePrototypeString(value) === prototypeStrings.boolean;
39
54
  }
40
- function isObject(value) {
41
- return resolvePrototypeString(value) === prototypes.object;
55
+
56
+ //#endregion
57
+ //#region src/utils/typeof/isClass.ts
58
+ function isClass(value) {
59
+ return resolvePrototypeString(value).startsWith("class ");
42
60
  }
43
- function isArray(value) {
44
- return resolvePrototypeString(value) === prototypes.array;
61
+
62
+ //#endregion
63
+ //#region src/utils/typeof/isDate.ts
64
+ function isDate(value) {
65
+ return resolvePrototypeString(value) === prototypeStrings.date;
45
66
  }
46
- function isBigInt(value) {
47
- return resolvePrototypeString(value) === prototypes.bigInt;
67
+
68
+ //#endregion
69
+ //#region src/utils/typeof/isEqual.ts
70
+ /**
71
+ * 判断给定的值是否相等
72
+ * @reference https://github.com/radashi-org/radashi/blob/main/src/typed/isEqual.ts
73
+ *
74
+ * @param {T} x
75
+ * @param {T} y
76
+ */
77
+ function isEqual(x, y) {
78
+ if (Object.is(x, y)) return true;
79
+ if (x instanceof Date && y instanceof Date) return x.getTime() === y.getTime();
80
+ if (x instanceof RegExp && y instanceof RegExp) return x.toString() === y.toString();
81
+ if (typeof x !== "object" || x === null || typeof y !== "object" || y === null) return false;
82
+ const keysX = Reflect.ownKeys(x);
83
+ const keysY = Reflect.ownKeys(y);
84
+ if (keysX.length !== keysY.length) return false;
85
+ for (const key of keysX) {
86
+ if (!Reflect.has(y, key)) return false;
87
+ if (!isEqual(x[key], y[key])) return false;
88
+ }
89
+ return true;
48
90
  }
49
- function isSymbol(value) {
50
- return resolvePrototypeString(value) === prototypes.symbol;
91
+
92
+ //#endregion
93
+ //#region src/utils/typeof/isError.ts
94
+ function isError(value) {
95
+ return resolvePrototypeString(value) === prototypeStrings.error;
96
+ }
97
+
98
+ //#endregion
99
+ //#region src/utils/typeof/isFile.ts
100
+ function isFile(value) {
101
+ return resolvePrototypeString(value) === prototypeStrings.file;
51
102
  }
103
+
104
+ //#endregion
105
+ //#region src/utils/typeof/isFunction.ts
52
106
  function isFunction(value) {
53
107
  return [
54
- prototypes.function,
55
- prototypes.generatorFunction,
56
- prototypes.asyncFunction
108
+ prototypeStrings.function,
109
+ prototypeStrings.generatorFunction,
110
+ prototypeStrings.asyncFunction
57
111
  ].includes(resolvePrototypeString(value));
58
112
  }
113
+
114
+ //#endregion
115
+ //#region src/utils/typeof/isGeneratorFunction.ts
59
116
  function isGeneratorFunction(value) {
60
- return resolvePrototypeString(value) === prototypes.generatorFunction;
117
+ return resolvePrototypeString(value) === prototypeStrings.generatorFunction;
61
118
  }
62
- function isAsyncFunction(value) {
63
- return resolvePrototypeString(value) === prototypes.asyncFunction;
64
- }
65
- function isPromise(value) {
66
- return resolvePrototypeString(value) === prototypes.promise;
67
- }
68
- function isPromiseLike(value) {
69
- return isPromise(value) || isObject(value) && isFunction(value["then"]);
119
+
120
+ //#endregion
121
+ //#region src/utils/typeof/isInteger.ts
122
+ function isInteger(value) {
123
+ return Number.isInteger(value);
70
124
  }
71
- function isNull(value) {
72
- return resolvePrototypeString(value) === prototypes.null;
125
+
126
+ //#endregion
127
+ //#region src/utils/typeof/isObject.ts
128
+ function isObject(value) {
129
+ return resolvePrototypeString(value) === prototypeStrings.object;
73
130
  }
74
- function isUndefined(value) {
75
- return resolvePrototypeString(value) === prototypes.undefined;
131
+
132
+ //#endregion
133
+ //#region src/utils/typeof/isIterable.ts
134
+ function isIterable(value) {
135
+ return isObject(value) && Symbol.iterator in value;
76
136
  }
77
- function isDate(value) {
78
- return resolvePrototypeString(value) === prototypes.date;
137
+
138
+ //#endregion
139
+ //#region src/utils/typeof/isMap.ts
140
+ function isMap(value) {
141
+ return resolvePrototypeString(value) === prototypeStrings.map;
79
142
  }
80
- function isRegExp(value) {
81
- return resolvePrototypeString(value) === prototypes.regExp;
143
+
144
+ //#endregion
145
+ //#region src/utils/typeof/isNull.ts
146
+ function isNull(value) {
147
+ return resolvePrototypeString(value) === prototypeStrings.null;
82
148
  }
83
- function isError(value) {
84
- return resolvePrototypeString(value) === prototypes.error;
149
+
150
+ //#endregion
151
+ //#region src/utils/typeof/isNumber.ts
152
+ function isNumber(value) {
153
+ return resolvePrototypeString(value) === prototypeStrings.number;
85
154
  }
86
- function isFile(value) {
87
- return resolvePrototypeString(value) === prototypes.file;
155
+
156
+ //#endregion
157
+ //#region src/utils/typeof/isPromise.ts
158
+ function isPromise(value) {
159
+ return resolvePrototypeString(value) === prototypeStrings.promise;
88
160
  }
89
- function isMap(value) {
90
- return resolvePrototypeString(value) === prototypes.map;
161
+
162
+ //#endregion
163
+ //#region src/utils/typeof/isPromiseLike.ts
164
+ function isPromiseLike(value) {
165
+ return isPromise(value) || isObject(value) && isFunction(value["then"]);
91
166
  }
92
- function isWeakMap(value) {
93
- return resolvePrototypeString(value) === prototypes.weakMap;
167
+
168
+ //#endregion
169
+ //#region src/utils/typeof/isRegExp.ts
170
+ function isRegExp(value) {
171
+ return resolvePrototypeString(value) === prototypeStrings.regExp;
94
172
  }
173
+
174
+ //#endregion
175
+ //#region src/utils/typeof/isSet.ts
95
176
  function isSet(value) {
96
- return resolvePrototypeString(value) === prototypes.set;
177
+ return resolvePrototypeString(value) === prototypeStrings.set;
97
178
  }
98
- function isWeakSet(value) {
99
- return resolvePrototypeString(value) === prototypes.weakSet;
179
+
180
+ //#endregion
181
+ //#region src/utils/typeof/isString.ts
182
+ function isString(value) {
183
+ return resolvePrototypeString(value) === prototypeStrings.string;
100
184
  }
101
- function isWindow(value) {
102
- return resolvePrototypeString(value) === prototypes.window;
185
+
186
+ //#endregion
187
+ //#region src/utils/typeof/isSymbol.ts
188
+ function isSymbol(value) {
189
+ return resolvePrototypeString(value) === prototypeStrings.symbol;
103
190
  }
104
- function isWebSocket(value) {
105
- return resolvePrototypeString(value) === prototypes.webSocket;
191
+
192
+ //#endregion
193
+ //#region src/utils/typeof/isUndefined.ts
194
+ function isUndefined(value) {
195
+ return resolvePrototypeString(value) === prototypeStrings.undefined;
106
196
  }
197
+
198
+ //#endregion
199
+ //#region src/utils/typeof/isURLSearchParams.ts
107
200
  function isURLSearchParams(value) {
108
- return resolvePrototypeString(value) === prototypes.URLSearchParams;
201
+ return resolvePrototypeString(value) === prototypeStrings.URLSearchParams;
109
202
  }
110
- function isClass(value) {
111
- return resolvePrototypeString(value).startsWith("class ");
203
+
204
+ //#endregion
205
+ //#region src/utils/typeof/isWeakMap.ts
206
+ function isWeakMap(value) {
207
+ return resolvePrototypeString(value) === prototypeStrings.weakMap;
112
208
  }
113
- function isInteger(value) {
114
- return Number.isInteger(value);
209
+
210
+ //#endregion
211
+ //#region src/utils/typeof/isWeakSet.ts
212
+ function isWeakSet(value) {
213
+ return resolvePrototypeString(value) === prototypeStrings.weakSet;
115
214
  }
116
- function isIterable(value) {
117
- return isObject(value) && Symbol.iterator in value;
215
+
216
+ //#endregion
217
+ //#region src/utils/typeof/isWebSocket.ts
218
+ function isWebSocket(value) {
219
+ return resolvePrototypeString(value) === prototypeStrings.webSocket;
118
220
  }
119
- /**
120
- * 判断给定的值是否相等
121
- * @reference https://github.com/radashi-org/radashi/blob/main/src/typed/isEqual.ts
122
- *
123
- * @param {T} x
124
- * @param {T} y
125
- */
126
- function isEqual(x, y) {
127
- if (Object.is(x, y)) return true;
128
- if (x instanceof Date && y instanceof Date) return x.getTime() === y.getTime();
129
- if (x instanceof RegExp && y instanceof RegExp) return x.toString() === y.toString();
130
- if (typeof x !== "object" || x === null || typeof y !== "object" || y === null) return false;
131
- const keysX = Reflect.ownKeys(x);
132
- const keysY = Reflect.ownKeys(y);
133
- if (keysX.length !== keysY.length) return false;
134
- for (const key of keysX) {
135
- if (!Reflect.has(y, key)) return false;
136
- if (!isEqual(x[key], y[key])) return false;
137
- }
138
- return true;
221
+
222
+ //#endregion
223
+ //#region src/utils/typeof/isWindow.ts
224
+ function isWindow(value) {
225
+ return resolvePrototypeString(value) === prototypeStrings.window;
139
226
  }
140
227
 
141
228
  //#endregion
@@ -318,7 +405,23 @@ function arraySplit(initialList, size = 10) {
318
405
  }
319
406
 
320
407
  //#endregion
321
- //#region src/utils/cloneDeep.ts
408
+ //#region src/utils/function/to.ts
409
+ /**
410
+ * @param promise
411
+ * @param errorExt - 可以传递给err对象的其他信息
412
+ */
413
+ function to(promise, errorExt) {
414
+ return promise.then((data) => [null, data]).catch((err) => {
415
+ if (errorExt) return [{
416
+ ...err,
417
+ ...errorExt
418
+ }, void 0];
419
+ return [err ? err : /* @__PURE__ */ new Error("defaultError"), void 0];
420
+ });
421
+ }
422
+
423
+ //#endregion
424
+ //#region src/utils/object/cloneDeep.ts
322
425
  const DefaultCloningStrategy = {
323
426
  cloneMap(input, track, clone) {
324
427
  const output = track(/* @__PURE__ */ new Map());
@@ -622,22 +725,6 @@ function stringToValues(data, valueType = "number", splitSymbol = ",") {
622
725
  else return [];
623
726
  }
624
727
 
625
- //#endregion
626
- //#region src/utils/to.ts
627
- /**
628
- * @param promise
629
- * @param errorExt - 可以传递给err对象的其他信息
630
- */
631
- function to(promise, errorExt) {
632
- return promise.then((data) => [null, data]).catch((err) => {
633
- if (errorExt) return [{
634
- ...err,
635
- ...errorExt
636
- }, void 0];
637
- return [err ? err : /* @__PURE__ */ new Error("defaultError"), void 0];
638
- });
639
- }
640
-
641
728
  //#endregion
642
729
  //#region src/utils/tree/types.ts
643
730
  function getFinalChildrenKey(tree, meta, options) {
@@ -1046,4 +1133,4 @@ function treeToRows(tree, options = {}) {
1046
1133
  }
1047
1134
 
1048
1135
  //#endregion
1049
- export { arrayCast, arrayCompete, arrayCounting, arrayDiff, arrayFirst, arrayFork, arrayLast, arrayMerge, arrayPick, arrayReplace, arraySplit, cloneDeep, enumEntries, enumKeys, enumTypeCheck, enumValues, isArray, isAsyncFunction, isBigInt, isBoolean, isClass, isDate, isEqual, isError, isFile, isFunction, isGeneratorFunction, isInteger, isIterable, isMap, isNull, isNumber, isObject, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isURLSearchParams, isUndefined, isWeakMap, isWeakSet, isWebSocket, isWindow, mapEntries, objectAssign, objectEntries, objectKeys, objectPick, objectSwitch, objectValues, rowsToTree, stringInitialCase, stringReplace, stringToJson, stringToValues, to, treeFilter, treeFind, treeForEach, treeMap, treeToRows };
1136
+ export { arrayCast, arrayCompete, arrayCounting, arrayDiff, arrayFirst, arrayFork, arrayLast, arrayMerge, arrayPick, arrayReplace, arraySplit, cloneDeep, enumEntries, enumKeys, enumTypeCheck, enumValues, isArray, isAsyncFunction, isBigInt, isBoolean, isClass, isDate, isEqual, isError, isFile, isFunction, isGeneratorFunction, isInteger, isIterable, isMap, isNull, isNumber, isObject, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isURLSearchParams, isUndefined, isWeakMap, isWeakSet, isWebSocket, isWindow, mapEntries, objectAssign, objectEntries, objectKeys, objectPick, objectSwitch, objectValues, prototypeStrings, resolvePrototypeString, rowsToTree, stringInitialCase, stringReplace, stringToJson, stringToValues, to, treeFilter, treeFind, treeForEach, treeMap, treeToRows };
package/metadata.json ADDED
@@ -0,0 +1,133 @@
1
+ {
2
+ "index": [
3
+ "arrayCast",
4
+ "arrayCompete",
5
+ "arrayCounting",
6
+ "arrayDiff",
7
+ "arrayFirst",
8
+ "arrayFork",
9
+ "arrayLast",
10
+ "arrayMerge",
11
+ "arrayPick",
12
+ "arrayReplace",
13
+ "arraySplit",
14
+ "cloneDeep",
15
+ "enumEntries",
16
+ "enumKeys",
17
+ "enumTypeCheck",
18
+ "enumValues",
19
+ "isArray",
20
+ "isAsyncFunction",
21
+ "isBigInt",
22
+ "isBoolean",
23
+ "isClass",
24
+ "isDate",
25
+ "isEqual",
26
+ "isError",
27
+ "isFile",
28
+ "isFunction",
29
+ "isGeneratorFunction",
30
+ "isInteger",
31
+ "isIterable",
32
+ "isMap",
33
+ "isNull",
34
+ "isNumber",
35
+ "isObject",
36
+ "isPromise",
37
+ "isPromiseLike",
38
+ "isRegExp",
39
+ "isSet",
40
+ "isString",
41
+ "isSymbol",
42
+ "isURLSearchParams",
43
+ "isUndefined",
44
+ "isWeakMap",
45
+ "isWeakSet",
46
+ "isWebSocket",
47
+ "isWindow",
48
+ "mapEntries",
49
+ "objectAssign",
50
+ "objectEntries",
51
+ "objectKeys",
52
+ "objectPick",
53
+ "objectSwitch",
54
+ "objectValues",
55
+ "prototypeStrings",
56
+ "resolvePrototypeString",
57
+ "rowsToTree",
58
+ "stringInitialCase",
59
+ "stringReplace",
60
+ "stringToJson",
61
+ "stringToValues",
62
+ "to",
63
+ "treeFilter",
64
+ "treeFind",
65
+ "treeForEach",
66
+ "treeMap",
67
+ "treeToRows"
68
+ ],
69
+ "zod": [
70
+ "ID",
71
+ "IMEI",
72
+ "USCC",
73
+ "USCC_S",
74
+ "alphabet",
75
+ "alphabetLowercase",
76
+ "alphabetOmit",
77
+ "alphabetUppercase",
78
+ "any",
79
+ "bigint",
80
+ "boolean",
81
+ "booleanAllowEmpty",
82
+ "carCodeGreen",
83
+ "carCodeNotGreen",
84
+ "chinaProvince",
85
+ "chineseName",
86
+ "dirPathLinux",
87
+ "dirPathWindows",
88
+ "email",
89
+ "empty",
90
+ "filePathLinux",
91
+ "filePathWindows",
92
+ "int",
93
+ "intAllowEmpty",
94
+ "link",
95
+ "linkPort",
96
+ "nation",
97
+ "natural",
98
+ "naturalAllowEmpty",
99
+ "never",
100
+ "number",
101
+ "numberAllowEmpty",
102
+ "numberAlphabet",
103
+ "phone",
104
+ "spaceEnd",
105
+ "spaceInclude",
106
+ "spaceStart",
107
+ "spaceStartEnd",
108
+ "string",
109
+ "stringAllowEmpty",
110
+ "stringEmpty",
111
+ "stringNoEmpty",
112
+ "stringSignedDecimalismFloat",
113
+ "stringSignedDecimalismInt",
114
+ "stringUnsignedDecimalismFloat",
115
+ "stringUnsignedDecimalismInt",
116
+ "symbol",
117
+ "telephone",
118
+ "thunder",
119
+ "unknown"
120
+ ],
121
+ "enums": [
122
+ "BREAK_POINT_TOKENS"
123
+ ],
124
+ "hooks": {
125
+ "react": [
126
+ "useCreation",
127
+ "useLatest",
128
+ "useMount",
129
+ "useResponsive",
130
+ "useUnmount"
131
+ ]
132
+ }
133
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "description": "pawover's kit",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "version": "0.0.0-alpha.15",
7
+ "version": "0.0.0-alpha.16",
8
8
  "packageManager": "pnpm@10.20.0",
9
9
  "engines": {
10
10
  "node": ">=22.20.0"
@@ -22,18 +22,20 @@
22
22
  "module": "./dist/index.js",
23
23
  "types": "./dist/index.d.ts",
24
24
  "files": [
25
- "dist"
25
+ "dist",
26
+ "metadata.json"
26
27
  ],
27
28
  "exports": {
28
29
  ".": "./dist/index.js",
29
30
  "./enums": "./dist/enums.js",
30
- "./metadata": "./dist/metadata.js",
31
31
  "./zod": "./dist/zod.js",
32
32
  "./hooks-react": "./dist/hooks-react.js",
33
+ "./metadata.json": "./metadata.json",
33
34
  "./package.json": "./package.json"
34
35
  },
35
36
  "scripts": {
36
- "build": "tsdown",
37
+ "build": "tsdown && pnpm build:metadata",
38
+ "build:metadata": "node scripts/metadata.ts",
37
39
  "public": "pnpm build && npm publish --access public",
38
40
  "check": "pnpm check:types & pnpm check:eslint & pnpm check:format",
39
41
  "check:types": "tsc --noEmit",
@@ -50,10 +52,12 @@
50
52
  "@pawover/eslint-rules": "0.0.0-alpha.8",
51
53
  "@pawover/types": "0.0.0-alpha.6",
52
54
  "@stylistic/eslint-plugin": "^5.5.0",
55
+ "@types/fs-extra": "^11.0.4",
53
56
  "@types/node": "^24.10.1",
54
57
  "@types/react": "^19.2.5",
55
58
  "eslint": "^9.39.1",
56
59
  "eslint-plugin-antfu": "^3.1.1",
60
+ "fs-extra": "^11.3.2",
57
61
  "globals": "^16.5.0",
58
62
  "prettier": "^3.6.2",
59
63
  "radashi": "^12.7.0",
@@ -1,10 +0,0 @@
1
- //#region src/metadata.d.ts
2
- declare const metadata: {
3
- readonly index: readonly ["arrayCast", "arrayCompete", "arrayCounting", "arrayDiff", "arrayFirst", "arrayFork", "arrayLast", "arrayMerge", "arrayPick", "arrayReplace", "arraySplit", "cloneDeep", "enumEntries", "enumKeys", "enumTypeCheck", "enumValues", "isArray", "isAsyncFunction", "isBigInt", "isBoolean", "isClass", "isDate", "isEqual", "isError", "isFile", "isFunction", "isGeneratorFunction", "isInteger", "isIterable", "isMap", "isNull", "isNumber", "isObject", "isPromise", "isPromiseLike", "isRegExp", "isSet", "isString", "isSymbol", "isURLSearchParams", "isUndefined", "isWeakMap", "isWeakSet", "isWebSocket", "isWindow", "mapEntries", "objectAssign", "objectEntries", "objectKeys", "objectPick", "objectSwitch", "objectValues", "rowsToTree", "stringInitialCase", "stringReplace", "stringToJson", "stringToValues", "to", "treeFilter", "treeFind", "treeForEach", "treeMap", "treeToRows"];
4
- readonly enums: readonly ["BREAK_POINT_TOKENS"];
5
- readonly hooks: {
6
- readonly react: readonly ["useCreation", "useLatest", "useMount", "useResponsive", "useUnmount"];
7
- };
8
- };
9
- //#endregion
10
- export { metadata };
package/dist/metadata.js DELETED
@@ -1,79 +0,0 @@
1
- //#region src/metadata.ts
2
- const metadata = {
3
- index: [
4
- "arrayCast",
5
- "arrayCompete",
6
- "arrayCounting",
7
- "arrayDiff",
8
- "arrayFirst",
9
- "arrayFork",
10
- "arrayLast",
11
- "arrayMerge",
12
- "arrayPick",
13
- "arrayReplace",
14
- "arraySplit",
15
- "cloneDeep",
16
- "enumEntries",
17
- "enumKeys",
18
- "enumTypeCheck",
19
- "enumValues",
20
- "isArray",
21
- "isAsyncFunction",
22
- "isBigInt",
23
- "isBoolean",
24
- "isClass",
25
- "isDate",
26
- "isEqual",
27
- "isError",
28
- "isFile",
29
- "isFunction",
30
- "isGeneratorFunction",
31
- "isInteger",
32
- "isIterable",
33
- "isMap",
34
- "isNull",
35
- "isNumber",
36
- "isObject",
37
- "isPromise",
38
- "isPromiseLike",
39
- "isRegExp",
40
- "isSet",
41
- "isString",
42
- "isSymbol",
43
- "isURLSearchParams",
44
- "isUndefined",
45
- "isWeakMap",
46
- "isWeakSet",
47
- "isWebSocket",
48
- "isWindow",
49
- "mapEntries",
50
- "objectAssign",
51
- "objectEntries",
52
- "objectKeys",
53
- "objectPick",
54
- "objectSwitch",
55
- "objectValues",
56
- "rowsToTree",
57
- "stringInitialCase",
58
- "stringReplace",
59
- "stringToJson",
60
- "stringToValues",
61
- "to",
62
- "treeFilter",
63
- "treeFind",
64
- "treeForEach",
65
- "treeMap",
66
- "treeToRows"
67
- ],
68
- enums: ["BREAK_POINT_TOKENS"],
69
- hooks: { react: [
70
- "useCreation",
71
- "useLatest",
72
- "useMount",
73
- "useResponsive",
74
- "useUnmount"
75
- ] }
76
- };
77
-
78
- //#endregion
79
- export { metadata };