@pawover/kit 0.0.0-beta.4 → 0.0.0-beta.40

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.
Files changed (40) hide show
  1. package/dist/enums-BL6w5-mS.js +148 -0
  2. package/dist/enums-BL6w5-mS.js.map +1 -0
  3. package/dist/enums.d.ts +2 -25
  4. package/dist/enums.js +2 -24
  5. package/dist/except-MacUK44u.d.ts +971 -0
  6. package/dist/except-MacUK44u.d.ts.map +1 -0
  7. package/dist/hooks-alova.d.ts +23 -14
  8. package/dist/hooks-alova.d.ts.map +1 -1
  9. package/dist/hooks-alova.js +54 -24
  10. package/dist/hooks-alova.js.map +1 -1
  11. package/dist/hooks-react.d.ts +82 -42
  12. package/dist/hooks-react.d.ts.map +1 -1
  13. package/dist/hooks-react.js +83 -260
  14. package/dist/hooks-react.js.map +1 -1
  15. package/dist/index-Bn_PNnsM.d.ts +212 -0
  16. package/dist/index-Bn_PNnsM.d.ts.map +1 -0
  17. package/dist/index-DBPmnr4a.d.ts +21 -0
  18. package/dist/index-DBPmnr4a.d.ts.map +1 -0
  19. package/dist/index.d.ts +1936 -1029
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +2 -1430
  22. package/dist/patches-fetchEventSource.d.ts +2 -721
  23. package/dist/patches-fetchEventSource.d.ts.map +1 -1
  24. package/dist/patches-fetchEventSource.js +1 -114
  25. package/dist/patches-fetchEventSource.js.map +1 -1
  26. package/dist/utils-DbMbll5L.js +2004 -0
  27. package/dist/utils-DbMbll5L.js.map +1 -0
  28. package/dist/value-of-DUmTbnuw.d.ts +26 -0
  29. package/dist/value-of-DUmTbnuw.d.ts.map +1 -0
  30. package/dist/vite.d.ts.map +1 -1
  31. package/dist/vite.js.map +1 -1
  32. package/dist/zod.d.ts +8 -1
  33. package/dist/zod.d.ts.map +1 -1
  34. package/dist/zod.js +13 -1
  35. package/dist/zod.js.map +1 -1
  36. package/metadata.json +34 -7
  37. package/package.json +31 -23
  38. package/dist/enums.d.ts.map +0 -1
  39. package/dist/enums.js.map +0 -1
  40. package/dist/index.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,181 +1,10 @@
1
+ import { a as Simplify, c as Not, d as IsNever, f as OptionalKeysOf, i as HomomorphicPick, l as UnknownArray, m as UnionToIntersection, n as ApplyDefaultOptions, o as IfNotAnyOrNever, p as IsAny, r as CollapseLiterals, s as IsExactOptionalPropertyTypesEnabled, t as Except, u as If } from "./except-MacUK44u.js";
2
+ import { t as ValueOf } from "./value-of-DUmTbnuw.js";
3
+ import { a as AnyObject, i as AnyGeneratorFunction, n as AnyAsyncGeneratorFunction, o as PlainObject, r as AnyFunction, s as TreeLike, t as AnyAsyncFunction } from "./index-DBPmnr4a.js";
4
+ import { clone, cloneDeep, cloneDeepWith } from "lodash-es";
1
5
  import { BigNumber, MathExpression, MathJsInstance, Matrix } from "mathjs";
2
6
 
3
- //#region src/utils/array/arrayCast.d.ts
4
-
5
- /**
6
- * 构造数组
7
- * @param candidate 待构造项
8
- * @param checkEmpty 是否检查 `undefined` 和 `null`
9
- */
10
- declare function arrayCast<T>(candidate: T | T[], checkEmpty?: boolean): T[];
11
- //#endregion
12
- //#region src/utils/array/arrayCompete.d.ts
13
- /**
14
- * 数组竞争
15
- * - 返回在匹配函数的比较条件中获胜的最终项目,适用于更复杂的最小值/最大值计算
16
- *
17
- * @param initialList 数组
18
- * @param match 匹配函数
19
- */
20
- declare function arrayCompete<T>(initialList: readonly T[], match: (a: T, b: T) => T): T | null;
21
- //#endregion
22
- //#region src/utils/array/arrayCounting.d.ts
23
- /**
24
- * 统计数组的项目出现次数
25
- * - 通过给定的标识符匹配函数,返回一个对象,其中键是回调函数返回的 key 值,每个值是一个整数,表示该 key 出现的次数
26
- *
27
- * @param initialList 初始数组
28
- * @param match 匹配函数
29
- */
30
- declare function arrayCounting<T, K$1 extends PropertyKey>(initialList: readonly T[], match: (row: T) => K$1): Record<string, number>;
31
- //#endregion
32
- //#region src/utils/array/arrayDifference.d.ts
33
- /**
34
- * 求数组差集
35
- *
36
- * @param initialList 初始数组
37
- * @param diffList 对比数组
38
- * @param match 匹配函数
39
- */
40
- declare function arrayDifference<T>(initialList: readonly T[], diffList: readonly T[], match?: (row: T) => unknown): T[];
41
- //#endregion
42
- //#region src/utils/array/arrayFirst.d.ts
43
- /**
44
- * 获取数组第一项
45
- *
46
- * @param initialList 初始数组
47
- * @param saveValue 安全值
48
- */
49
- declare function arrayFirst<T>(initialList: readonly T[]): T | undefined;
50
- declare function arrayFirst<T>(initialList: readonly T[], saveValue: T): T;
51
- //#endregion
52
- //#region src/utils/array/arrayFork.d.ts
53
- /**
54
- * 数组分组过滤
55
- * - 给定一个数组和一个条件,返回一个由两个数组组成的元组,其中第一个数组包含所有满足条件的项,第二个数组包含所有不满足条件的项
56
- *
57
- * @param initialList 初始数组
58
- * @param match 条件匹配函数
59
- */
60
- declare function arrayFork<T>(initialList: readonly T[], match: (item: T) => boolean): [T[], T[]];
61
- //#endregion
62
- //#region src/utils/array/arrayIntersection.d.ts
63
- /**
64
- * 求数组交集
65
- *
66
- * @param initialList 初始数组
67
- * @param diffList 对比数组
68
- * @param match 匹配函数
69
- */
70
- declare function arrayIntersection<T>(initialList: readonly T[], diffList: readonly T[], match?: (row: T) => unknown): T[];
71
- //#endregion
72
- //#region src/utils/array/arrayLast.d.ts
73
- /**
74
- * 获取数组最后一项
75
- *
76
- * @param initialList 初始数组
77
- * @param saveValue 安全值
78
- */
79
- declare function arrayLast<T>(initialList: readonly T[]): T | undefined;
80
- declare function arrayLast<T>(initialList: readonly T[], saveValue: T): T;
81
- //#endregion
82
- //#region src/utils/array/arrayMerge.d.ts
83
- /**
84
- * 数组合并
85
- * - 通过给定的标识符匹配函数,用第二个数组中的匹配项替换第一个数组中匹配项的所有内容
86
- *
87
- * @param initialList 初始数组
88
- * @param mergeList 待合并数组
89
- * @param match 匹配函数
90
- */
91
- declare function arrayMerge<T>(initialList: readonly T[], mergeList: readonly T[], match?: (item: T) => unknown): T[];
92
- //#endregion
93
- //#region src/utils/array/arrayPick.d.ts
94
- /**
95
- * 数组选择
96
- * - 一次性应用 `filter` 和 `map` 操作
97
- *
98
- * @param initialList 初始数组
99
- * @param filter filter 函数
100
- * @param mapper map 函数
101
- */
102
- declare function arrayPick<T, K$1 = T>(initialList: readonly T[], filter: (row: T, index: number) => boolean, mapper?: ((row: T, index: number) => K$1) | undefined): T[] | K$1[];
103
- //#endregion
104
- //#region src/utils/array/arrayReplace.d.ts
105
- /**
106
- * 数组项替换
107
- * - 在给定的数组中,替换符合匹配函数结果的项目。只替换第一个匹配项。始终返回原始数组的副本。
108
- *
109
- * @param initialList 初始数组
110
- * @param newItem 替换项
111
- * @param match 匹配函数
112
- */
113
- declare function arrayReplace<T>(initialList: readonly T[], newItem: T, match: (row: T, index: number) => boolean): T[];
114
- //#endregion
115
- //#region src/utils/array/arraySplit.d.ts
116
- /**
117
- * 数组切分
118
- * - 将数组以指定的长度切分后,组合在高维数组中
119
- *
120
- * @param initialList 初始数组
121
- * @param size 分割尺寸,默认 `10`
122
- */
123
- declare function arraySplit<T>(initialList: readonly T[], size?: number): T[][];
124
- //#endregion
125
- //#region src/utils/function/to.d.ts
126
- /**
127
- * @param promise
128
- * @param errorExt 可以传递给err对象的其他信息
129
- */
130
- declare function to<T, U$1 = Error>(promise: Readonly<Promise<T>>, errorExt?: PlainObject): Promise<[U$1, undefined] | [null, T]>;
131
- //#endregion
132
- //#region src/utils/math/toMathBignumber.d.ts
133
- /**
134
- * 将任意类型的值转换为 `math.bignumber`
135
- *
136
- * @param mathJsInstance mathJs 实例
137
- * @param value 任意类型的值
138
- * @param saveValue 安全值
139
- */
140
- declare function toMathBignumber(mathJsInstance: MathJsInstance, value: unknown, saveValue?: BigNumber | undefined): BigNumber;
141
- //#endregion
142
- //#region src/utils/math/toMathDecimal.d.ts
143
- /**
144
- * 将任意类型的值转换为十进制数字字符串
145
- *
146
- * @param mathJsInstance mathJs 实例
147
- * @param value 任意类型的值
148
- * @param precision 精度
149
- * @param isFormat 是否格式化为字符串
150
- */
151
- declare function toMathDecimal(mathJsInstance: MathJsInstance, value: unknown, precision?: number | undefined, isFormat?: true): string;
152
- declare function toMathDecimal(mathJsInstance: MathJsInstance, value: unknown, precision?: number | undefined, isFormat?: false): BigNumber;
153
- //#endregion
154
- //#region src/utils/math/toMathEvaluate.d.ts
155
- /**
156
- * 数学表达式求值
157
- *
158
- * @param mathJsInstance mathJs 实例
159
- * @param expr 表达式
160
- * @param scope 键值映射
161
- */
162
- declare function toMathEvaluate(mathJsInstance: MathJsInstance, expr: MathExpression | Matrix, scope?: Record<string, BigNumber>): string;
163
- //#endregion
164
- //#region src/utils/object/cloneDeep.d.ts
165
- interface CloningStrategy {
166
- cloneMap: <K$1, V>(parent: Map<K$1, V>, track: (newParent: Map<K$1, V>) => Map<K$1, V>, clone: <T>(value: T) => T) => Map<K$1, V> | null;
167
- cloneSet: <T>(parent: Set<T>, track: (newParent: Set<T>) => Set<T>, clone: <T>(value: T) => T) => Set<T> | null;
168
- cloneArray: <T>(parent: readonly T[], track: (newParent: T[]) => T[], clone: <T>(value: T) => T) => T[] | null;
169
- cloneObject: <T extends AnyObject>(parent: T, track: (newParent: T) => T, clone: <T>(value: T) => T) => T | null;
170
- cloneOther: <T>(parent: T, track: (newParent: T) => T, clone: <T>(value: T) => T) => T | null;
171
- }
172
- /**
173
- * cloneDeep
174
- * @reference https://github.com/radashi-org/radashi/blob/main/src/object/cloneDeep.ts
175
- */
176
- declare function cloneDeep<T extends AnyObject>(root: T, customStrategy?: Partial<CloningStrategy>): T;
177
- //#endregion
178
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/basic.d.ts
7
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/basic.d.ts
179
8
  /**
180
9
  Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
181
10
 
@@ -186,1015 +15,654 @@ type Class<T, Arguments extends unknown[] = any[]> = {
186
15
  new (...arguments_: Arguments): T;
187
16
  };
188
17
  //#endregion
189
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/union-to-intersection.d.ts
190
- /**
191
- Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
18
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/internal/array.d.ts
192
19
 
193
- Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
20
+ /**
21
+ Transforms a tuple type by replacing it's rest element with a single element that has the same type as the rest element, while keeping all the non-rest elements intact.
194
22
 
195
23
  @example
196
24
  ```
197
- import type {UnionToIntersection} from 'type-fest';
25
+ type A = CollapseRestElement<[string, string, ...number[]]>;
26
+ //=> [string, string, number]
198
27
 
199
- type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
28
+ type B = CollapseRestElement<[...string[], number, number]>;
29
+ //=> [string, number, number]
200
30
 
201
- type Intersection = UnionToIntersection<Union>;
202
- //=> {the(): void; great(arg: string): void; escape: boolean};
31
+ type C = CollapseRestElement<[string, string, ...Array<number | bigint>]>;
32
+ //=> [string, string, number | bigint]
33
+
34
+ type D = CollapseRestElement<[string, number]>;
35
+ //=> [string, number]
203
36
  ```
204
37
 
205
- @category Type
206
- */
207
- type UnionToIntersection<Union> = (
208
- // `extends unknown` is always going to be the case and is used to convert the
209
- // `Union` into a [distributive conditional
210
- // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
211
- Union extends unknown
212
- // The union type is used as the only argument to a function since the union
213
- // of function arguments is an intersection.
214
- ? (distributedUnion: Union) => void
215
- // This won't happen.
216
- : never
217
- // Infer the `Intersection` type since TypeScript represents the positional
218
- // arguments of unions of functions as an intersection of the union.
219
- ) extends ((mergedIntersection: infer Intersection) => void)
220
- // The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
221
- ? Intersection & Union : never;
222
- //#endregion
223
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/keys-of-union.d.ts
224
- /**
225
- Create a union of all keys from a given type, even those exclusive to specific union members.
226
-
227
- Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
228
-
229
- @link https://stackoverflow.com/a/49402091
38
+ Note: Optional modifiers (`?`) are removed from elements unless the `exactOptionalPropertyTypes` compiler option is disabled. When disabled, there's an additional `| undefined` for optional elements.
230
39
 
231
40
  @example
232
41
  ```
233
- import type {KeysOfUnion} from 'type-fest';
234
-
235
- type A = {
236
- common: string;
237
- a: number;
238
- };
42
+ // `exactOptionalPropertyTypes` enabled
43
+ type A = CollapseRestElement<[string?, string?, ...number[]]>;
44
+ //=> [string, string, number]
239
45
 
240
- type B = {
241
- common: string;
242
- b: string;
243
- };
244
-
245
- type C = {
246
- common: string;
247
- c: boolean;
248
- };
249
-
250
- type Union = A | B | C;
251
-
252
- type CommonKeys = keyof Union;
253
- //=> 'common'
254
-
255
- type AllKeys = KeysOfUnion<Union>;
256
- //=> 'common' | 'a' | 'b' | 'c'
46
+ // `exactOptionalPropertyTypes` disabled
47
+ type B = CollapseRestElement<[string?, string?, ...number[]]>;
48
+ //=> [string | undefined, string | undefined, number]
257
49
  ```
258
-
259
- @category Object
260
50
  */
261
- type KeysOfUnion<ObjectType> =
262
- // Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
263
- keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
51
+ type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, _CollapseRestElement<TArray>>;
52
+ type _CollapseRestElement<TArray extends UnknownArray, ForwardAccumulator extends UnknownArray = [], BackwardAccumulator extends UnknownArray = []> = TArray extends UnknownArray // For distributing `TArray`
53
+ ? keyof TArray & `${number}` extends never
54
+ // Enters this branch, if `TArray` is empty (e.g., []),
55
+ // or `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
56
+ ? TArray extends readonly [...infer Rest, infer Last] ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
57
+ : TArray extends readonly [] ? [...ForwardAccumulator, ...BackwardAccumulator] : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
58
+ : TArray extends readonly [(infer First)?, ...infer Rest] ? _CollapseRestElement<Rest, [...ForwardAccumulator, '0' extends OptionalKeysOf<TArray> ? If<IsExactOptionalPropertyTypesEnabled, First, First | undefined> // Add `| undefined` for optional elements, if `exactOptionalPropertyTypes` is disabled.
59
+ : First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
60
+ : never; // Should never happen
264
61
  //#endregion
265
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-any.d.ts
266
- /**
267
- Returns a boolean for whether the given type is `any`.
62
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/numeric.d.ts
63
+ type _Numeric = number | bigint;
64
+ type Zero = 0 | 0n;
268
65
 
269
- @link https://stackoverflow.com/a/49928360/1490091
66
+ /**
67
+ Matches the hidden `Infinity` type.
270
68
 
271
- Useful in type utilities, such as disallowing `any`s to be passed to a function.
69
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
272
70
 
273
- @example
274
- ```
275
- import type {IsAny} from 'type-fest';
71
+ @see {@link NegativeInfinity}
276
72
 
277
- const typedObject = {a: 1, b: 2} as const;
278
- const anyObject: any = {a: 1, b: 2};
73
+ @category Numeric
74
+ */
75
+ // See https://github.com/microsoft/TypeScript/issues/31752
76
+ // eslint-disable-next-line no-loss-of-precision
279
77
 
280
- function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
281
- return object[key];
282
- }
78
+ /**
79
+ A negative `number`/`bigint` (`-∞ < x < 0`)
283
80
 
284
- const typedA = get(typedObject, 'a');
285
- //=> 1
81
+ Use-case: Validating and documenting parameters.
286
82
 
287
- const anyA = get(anyObject, 'a');
288
- //=> any
289
- ```
83
+ @see {@link NegativeInteger}
84
+ @see {@link NonNegative}
290
85
 
291
- @category Type Guard
292
- @category Utilities
86
+ @category Numeric
293
87
  */
294
- type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
295
- //#endregion
296
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-optional-key-of.d.ts
88
+ type Negative<T extends _Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never;
297
89
  /**
298
- Returns a boolean for whether the given key is an optional key of type.
90
+ Returns a boolean for whether the given number is a negative number.
299
91
 
300
- This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
92
+ @see {@link Negative}
301
93
 
302
94
  @example
303
95
  ```
304
- import type {IsOptionalKeyOf} from 'type-fest';
96
+ import type {IsNegative} from 'type-fest';
305
97
 
306
- type User = {
307
- name: string;
308
- surname: string;
98
+ type ShouldBeFalse = IsNegative<1>;
99
+ type ShouldBeTrue = IsNegative<-1>;
100
+ ```
309
101
 
310
- luckyNumber?: number;
102
+ @category Numeric
103
+ */
104
+ type IsNegative<T extends _Numeric> = T extends Negative<T> ? true : false;
105
+ //#endregion
106
+ //#region node_modules/.pnpm/tagged-tag@1.0.0/node_modules/tagged-tag/index.d.ts
107
+ declare const tag: unique symbol;
108
+ //#endregion
109
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/tagged.d.ts
110
+ // eslint-disable-next-line type-fest/require-exported-types
111
+ type TagContainer<Token> = {
112
+ readonly [tag]: Token;
311
113
  };
114
+ type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{ [K in Token]: TagMetadata }>;
312
115
 
313
- type Admin = {
314
- name: string;
315
- surname?: string;
316
- };
116
+ /**
117
+ Attach a "tag" to an arbitrary type. This allows you to create distinct types, that aren't assignable to one another, for distinct concepts in your program that should not be interchangeable, even if their runtime values have the same type. (See examples.)
317
118
 
318
- type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
319
- //=> true
119
+ A type returned by `Tagged` can be passed to `Tagged` again, to create a type with multiple tags.
320
120
 
321
- type T2 = IsOptionalKeyOf<User, 'name'>;
322
- //=> false
121
+ [Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
323
122
 
324
- type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
325
- //=> boolean
123
+ A tag's name is usually a string (and must be a string, number, or symbol), but each application of a tag can also contain an arbitrary type as its "metadata". See {@link GetTagMetadata} for examples and explanation.
326
124
 
327
- type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
328
- //=> false
125
+ A type `A` returned by `Tagged` is assignable to another type `B` returned by `Tagged` if and only if:
126
+ - the underlying (untagged) type of `A` is assignable to the underlying type of `B`;
127
+ - `A` contains at least all the tags `B` has;
128
+ - and the metadata type for each of `A`'s tags is assignable to the metadata type of `B`'s corresponding tag.
329
129
 
330
- type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
331
- //=> boolean
130
+ There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
131
+ - [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
132
+ - [Microsoft/TypeScript#4895](https://github.com/microsoft/TypeScript/issues/4895)
133
+ - [Microsoft/TypeScript#33290](https://github.com/microsoft/TypeScript/pull/33290)
134
+
135
+ @example
332
136
  ```
137
+ import type {Tagged} from 'type-fest';
333
138
 
334
- @category Type Guard
335
- @category Utilities
336
- */
337
- type IsOptionalKeyOf<Type extends object, Key$1 extends keyof Type> = IsAny<Type | Key$1> extends true ? never : Key$1 extends keyof Type ? Type extends Record<Key$1, Type[Key$1]> ? false : true : false;
338
- //#endregion
339
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/optional-keys-of.d.ts
340
- /**
341
- Extract all optional keys from the given type.
139
+ type AccountNumber = Tagged<number, 'AccountNumber'>;
140
+ type AccountBalance = Tagged<number, 'AccountBalance'>;
342
141
 
343
- This is useful when you want to create a new type that contains different type values for the optional keys only.
142
+ function createAccountNumber(): AccountNumber {
143
+ // As you can see, casting from a `number` (the underlying type being tagged) is allowed.
144
+ return 2 as AccountNumber;
145
+ }
344
146
 
345
- @example
346
- ```
347
- import type {OptionalKeysOf, Except} from 'type-fest';
147
+ declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
348
148
 
349
- type User = {
350
- name: string;
351
- surname: string;
149
+ // This will compile successfully.
150
+ getMoneyForAccount(createAccountNumber());
352
151
 
353
- luckyNumber?: number;
354
- };
152
+ // But this won't, because it has to be explicitly passed as an `AccountNumber` type!
153
+ // Critically, you could not accidentally use an `AccountBalance` as an `AccountNumber`.
154
+ // @ts-expect-error
155
+ getMoneyForAccount(2);
355
156
 
356
- const REMOVE_FIELD = Symbol('remove field symbol');
357
- type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
358
- [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
359
- };
157
+ // You can also use tagged values like their underlying, untagged type.
158
+ // I.e., this will compile successfully because an `AccountNumber` can be used as a regular `number`.
159
+ // In this sense, the underlying base type is not hidden, which differentiates tagged types from opaque types in other languages.
160
+ const accountNumber = createAccountNumber() + 2;
161
+ ```
360
162
 
361
- const update1: UpdateOperation<User> = {
362
- name: 'Alice',
363
- };
163
+ @example
164
+ ```
165
+ import type {Tagged} from 'type-fest';
364
166
 
365
- const update2: UpdateOperation<User> = {
366
- name: 'Bob',
367
- luckyNumber: REMOVE_FIELD,
368
- };
167
+ // You can apply multiple tags to a type by using `Tagged` repeatedly.
168
+ type Url = Tagged<string, 'URL'>;
169
+ type SpecialCacheKey = Tagged<Url, 'SpecialCacheKey'>;
170
+
171
+ // You can also pass a union of tag names, so this is equivalent to the above, although it doesn't give you the ability to assign distinct metadata to each tag.
172
+ type SpecialCacheKey2 = Tagged<string, 'URL' | 'SpecialCacheKey'>;
369
173
  ```
370
174
 
371
- @category Utilities
175
+ @category Type
372
176
  */
373
- type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
374
- ? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
375
- : never;
376
- //#endregion
377
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/required-keys-of.d.ts
177
+ type Tagged<Type$1, TagName extends PropertyKey, TagMetadata = never> = Type$1 & Tag<TagName, TagMetadata>;
378
178
  /**
379
- Extract all required keys from the given type.
179
+ Revert a tagged type back to its original type by removing all tags.
380
180
 
381
- This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
181
+ Why is this necessary?
182
+
183
+ 1. Use a `Tagged` type as object keys
184
+ 2. Prevent TS4058 error: "Return type of exported function has or is using name X from external module Y but cannot be named"
382
185
 
383
186
  @example
384
187
  ```
385
- import type {RequiredKeysOf} from 'type-fest';
188
+ import type {Tagged, UnwrapTagged} from 'type-fest';
386
189
 
387
- declare function createValidation<
388
- Entity extends object,
389
- Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
390
- >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
190
+ type AccountType = Tagged<'SAVINGS' | 'CHECKING', 'AccountType'>;
391
191
 
392
- type User = {
393
- name: string;
394
- surname: string;
395
- luckyNumber?: number;
192
+ const moneyByAccountType: Record<UnwrapTagged<AccountType>, number> = {
193
+ SAVINGS: 99,
194
+ CHECKING: 0.1,
396
195
  };
397
196
 
398
- const validator1 = createValidation<User>('name', value => value.length < 25);
399
- const validator2 = createValidation<User>('surname', value => value.length < 25);
197
+ // Without UnwrapTagged, the following expression would throw a type error.
198
+ const money = moneyByAccountType.SAVINGS; // TS error: Property 'SAVINGS' does not exist
400
199
 
200
+ // Attempting to pass an non-Tagged type to UnwrapTagged will raise a type error.
401
201
  // @ts-expect-error
402
- const validator3 = createValidation<User>('luckyNumber', value => value > 0);
403
- // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
202
+ type WontWork = UnwrapTagged<string>;
404
203
  ```
405
204
 
406
- @category Utilities
205
+ @category Type
407
206
  */
408
- type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
409
- ? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
410
- //#endregion
411
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/has-required-keys.d.ts
207
+ type UnwrapTagged<TaggedType extends Tag<PropertyKey, any>> = RemoveAllTags<TaggedType>;
208
+ type RemoveAllTags<T> = T extends Tag<PropertyKey, any> ? { [ThisTag in keyof T[typeof tag]]: T extends Tagged<infer Type, ThisTag, T[typeof tag][ThisTag]> ? RemoveAllTags<Type> : never }[keyof T[typeof tag]] : T;
209
+
412
210
  /**
413
- Creates a type that represents `true` or `false` depending on whether the given type has any required fields.
211
+ Note: The `Opaque` type is deprecated in favor of `Tagged`.
212
+
213
+ Attach a "tag" to an arbitrary type. This allows you to create distinct types, that aren't assignable to one another, for runtime values that would otherwise have the same type. (See examples.)
214
+
215
+ The generic type parameters can be anything.
414
216
 
415
- This is useful when you want to create an API whose behavior depends on the presence or absence of required fields.
217
+ Note that `Opaque` is somewhat of a misnomer here, in that, unlike [some alternative implementations](https://github.com/microsoft/TypeScript/issues/4895#issuecomment-425132582), the original, untagged type is not actually hidden. (E.g., functions that accept the untagged type can still be called with the "opaque" version -- but not vice-versa.)
218
+
219
+ Also note that this implementation is limited to a single tag. If you want to allow multiple tags, use `Tagged` instead.
220
+
221
+ [Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
222
+
223
+ There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
224
+ - [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
225
+ - [Microsoft/TypeScript#15408](https://github.com/Microsoft/TypeScript/issues/15408)
226
+ - [Microsoft/TypeScript#15807](https://github.com/Microsoft/TypeScript/issues/15807)
416
227
 
417
228
  @example
418
229
  ```
419
- import type {HasRequiredKeys} from 'type-fest';
230
+ import type {Opaque} from 'type-fest';
420
231
 
421
- type GeneratorOptions<Template extends object> = {
422
- prop1: number;
423
- prop2: string;
424
- } & (HasRequiredKeys<Template> extends true
425
- ? {template: Template}
426
- : {template?: Template});
232
+ type AccountNumber = Opaque<number, 'AccountNumber'>;
233
+ type AccountBalance = Opaque<number, 'AccountBalance'>;
427
234
 
428
- type Template1 = {
429
- optionalSubParam?: string;
430
- };
235
+ // The `Token` parameter allows the compiler to differentiate between types, whereas "unknown" will not. For example, consider the following structures:
236
+ type ThingOne = Opaque<string>;
237
+ type ThingTwo = Opaque<string>;
431
238
 
432
- type Template2 = {
433
- requiredSubParam: string;
434
- };
239
+ // To the compiler, these types are allowed to be cast to each other as they have the same underlying type. They are both `string & { __opaque__: unknown }`.
240
+ // To avoid this behaviour, you would instead pass the "Token" parameter, like so.
241
+ type NewThingOne = Opaque<string, 'ThingOne'>;
242
+ type NewThingTwo = Opaque<string, 'ThingTwo'>;
435
243
 
436
- type Options1 = GeneratorOptions<Template1>;
437
- type Options2 = GeneratorOptions<Template2>;
244
+ // Now they're completely separate types, so the following will fail to compile.
245
+ function createNewThingOne(): NewThingOne {
246
+ // As you can see, casting from a string is still allowed. However, you may not cast NewThingOne to NewThingTwo, and vice versa.
247
+ return 'new thing one' as NewThingOne;
248
+ }
438
249
 
439
- const optA: Options1 = {
440
- prop1: 0,
441
- prop2: 'hi',
442
- };
443
- const optB: Options1 = {
444
- prop1: 0,
445
- prop2: 'hi',
446
- template: {},
447
- };
448
- const optC: Options1 = {
449
- prop1: 0,
450
- prop2: 'hi',
451
- template: {
452
- optionalSubParam: 'optional value',
453
- },
454
- };
250
+ // This will fail to compile, as they are fundamentally different types.
251
+ // @ts-expect-error
252
+ const thingTwo = createNewThingOne() as NewThingTwo;
455
253
 
456
- const optD: Options2 = {
457
- prop1: 0,
458
- prop2: 'hi',
459
- template: {
460
- requiredSubParam: 'required value',
461
- },
462
- };
254
+ // Here's another example of opaque typing.
255
+ function createAccountNumber(): AccountNumber {
256
+ return 2 as AccountNumber;
257
+ }
258
+
259
+ declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
260
+
261
+ // This will compile successfully.
262
+ getMoneyForAccount(createAccountNumber());
263
+
264
+ // But this won't, because it has to be explicitly passed as an `AccountNumber` type.
265
+ // @ts-expect-error
266
+ getMoneyForAccount(2);
463
267
 
268
+ // You can use opaque values like they aren't opaque too.
269
+ const accountNumber = createAccountNumber();
270
+
271
+ // This will compile successfully.
272
+ const newAccountNumber = accountNumber + 2;
273
+
274
+ // As a side note, you can (and should) use recursive types for your opaque types to make them stronger and hopefully easier to type.
275
+ type Person = {
276
+ id: Opaque<number, Person>;
277
+ name: string;
278
+ };
464
279
  ```
465
280
 
466
- @category Utilities
281
+ @category Type
282
+ @deprecated Use {@link Tagged} instead
467
283
  */
468
- type HasRequiredKeys<BaseType extends object> = RequiredKeysOf<BaseType> extends never ? false : true;
469
284
  //#endregion
470
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-never.d.ts
285
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/is-literal.d.ts
471
286
  /**
472
- Returns a boolean for whether the given type is `never`.
287
+ Returns a boolean for whether the given type is a `string` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
473
288
 
474
- @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
475
- @link https://stackoverflow.com/a/53984913/10292952
476
- @link https://www.zhenghao.io/posts/ts-never
289
+ Useful for:
290
+ - providing strongly-typed string manipulation functions
291
+ - constraining strings to be a string literal
292
+ - type utilities, such as when constructing parsers and ASTs
477
293
 
478
- Useful in type utilities, such as checking if something does not occur.
294
+ The implementation of this type is inspired by the trick mentioned in this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
479
295
 
480
296
  @example
481
297
  ```
482
- import type {IsNever, And} from 'type-fest';
298
+ import type {IsStringLiteral} from 'type-fest';
483
299
 
484
- type A = IsNever<never>;
485
- //=> true
300
+ type CapitalizedString<T extends string> = IsStringLiteral<T> extends true ? Capitalize<T> : string;
486
301
 
487
- type B = IsNever<any>;
488
- //=> false
302
+ // https://github.com/yankeeinlondon/native-dash/blob/master/src/capitalize.ts
303
+ function capitalize<T extends Readonly<string>>(input: T): CapitalizedString<T> {
304
+ return (input.slice(0, 1).toUpperCase() + input.slice(1)) as CapitalizedString<T>;
305
+ }
489
306
 
490
- type C = IsNever<unknown>;
491
- //=> false
307
+ const output = capitalize('hello, world!');
308
+ //=> 'Hello, world!'
309
+ ```
492
310
 
493
- type D = IsNever<never[]>;
494
- //=> false
311
+ @example
312
+ ```
313
+ // String types with infinite set of possible values return `false`.
495
314
 
496
- type E = IsNever<object>;
497
- //=> false
315
+ import type {IsStringLiteral} from 'type-fest';
498
316
 
499
- type F = IsNever<string>;
317
+ type AllUppercaseStrings = IsStringLiteral<Uppercase<string>>;
500
318
  //=> false
501
- ```
502
319
 
503
- @example
504
- ```
505
- import type {IsNever} from 'type-fest';
320
+ type StringsStartingWithOn = IsStringLiteral<`on${string}`>;
321
+ //=> false
506
322
 
507
- type IsTrue<T> = T extends true ? true : false;
323
+ // This behaviour is particularly useful in string manipulation utilities, as infinite string types often require separate handling.
508
324
 
509
- // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
510
- type A = IsTrue<never>;
511
- // ^? type A = never
325
+ type Length<S extends string, Counter extends never[] = []> =
326
+ IsStringLiteral<S> extends false
327
+ ? number // return `number` for infinite string types
328
+ : S extends `${string}${infer Tail}`
329
+ ? Length<Tail, [...Counter, never]>
330
+ : Counter['length'];
512
331
 
513
- // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
514
- type IsTrueFixed<T> =
515
- IsNever<T> extends true ? false : T extends true ? true : false;
332
+ type L1 = Length<Lowercase<string>>;
333
+ //=> number
516
334
 
517
- type B = IsTrueFixed<never>;
518
- // ^? type B = false
335
+ type L2 = Length<`${number}`>;
336
+ //=> number
519
337
  ```
520
338
 
521
339
  @category Type Guard
522
340
  @category Utilities
523
341
  */
524
- type IsNever<T> = [T] extends [never] ? true : false;
342
+ type IsStringLiteral<S> = IfNotAnyOrNever<S, _IsStringLiteral<CollapseLiterals<S extends TagContainer<any> ? UnwrapTagged<S> : S>>, false, false>;
343
+ type _IsStringLiteral<S> =
344
+ // If `T` is an infinite string type (e.g., `on${string}`), `Record<T, never>` produces an index signature,
345
+ // and since `{}` extends index signatures, the result becomes `false`.
346
+ S extends string ? {} extends Record<S, never> ? false : true : false;
525
347
  //#endregion
526
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/if.d.ts
348
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/tuple-of.d.ts
527
349
  /**
528
- An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
529
-
530
- Use-cases:
531
- - You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
532
-
533
- Note:
534
- - Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
535
- - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
350
+ Create a tuple type of the specified length with elements of the specified type.
536
351
 
537
352
  @example
538
353
  ```
539
- import type {If} from 'type-fest';
540
-
541
- type A = If<true, 'yes', 'no'>;
542
- //=> 'yes'
354
+ import type {TupleOf} from 'type-fest';
543
355
 
544
- type B = If<false, 'yes', 'no'>;
545
- //=> 'no'
356
+ type RGB = TupleOf<3, number>;
357
+ //=> [number, number, number]
546
358
 
547
- type C = If<boolean, 'yes', 'no'>;
548
- //=> 'yes' | 'no'
359
+ type Line = TupleOf<2, {x: number; y: number}>;
360
+ //=> [{x: number; y: number}, {x: number; y: number}]
549
361
 
550
- type D = If<any, 'yes', 'no'>;
551
- //=> 'yes' | 'no'
552
-
553
- type E = If<never, 'yes', 'no'>;
554
- //=> 'no'
362
+ type TicTacToeBoard = TupleOf<3, TupleOf<3, 'X' | 'O' | null>>;
363
+ //=> [['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null], ['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null], ['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null]]
555
364
  ```
556
365
 
557
366
  @example
558
367
  ```
559
- import type {If, IsAny, IsNever} from 'type-fest';
368
+ import type {TupleOf} from 'type-fest';
369
+
370
+ type Range<Start extends number, End extends number> = Exclude<keyof TupleOf<End>, keyof TupleOf<Start>>;
560
371
 
561
- type A = If<IsAny<unknown>, 'is any', 'not any'>;
562
- //=> 'not any'
372
+ type ZeroToFour = Range<0, 5>;
373
+ //=> '0' | '1' | '2' | '3' | '4'
563
374
 
564
- type B = If<IsNever<never>, 'is never', 'not never'>;
565
- //=> 'is never'
375
+ type ThreeToEight = Range<3, 9>;
376
+ //=> '5' | '3' | '4' | '6' | '7' | '8'
566
377
  ```
567
378
 
379
+ Note: If the specified length is the non-literal `number` type, the result will not be a tuple but a regular array.
380
+
568
381
  @example
569
382
  ```
570
- import type {If, IsEqual} from 'type-fest';
571
-
572
- type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
383
+ import type {TupleOf} from 'type-fest';
573
384
 
574
- type A = IfEqual<string, string, 'equal', 'not equal'>;
575
- //=> 'equal'
576
-
577
- type B = IfEqual<string, number, 'equal', 'not equal'>;
578
- //=> 'not equal'
385
+ type StringArray = TupleOf<number, string>;
386
+ //=> string[]
579
387
  ```
580
388
 
581
- Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
389
+ Note: If the type for elements is not specified, it will default to `unknown`.
582
390
 
583
391
  @example
584
392
  ```
585
- import type {If, IsEqual, StringRepeat} from 'type-fest';
586
-
587
- type HundredZeroes = StringRepeat<'0', 100>;
393
+ import type {TupleOf} from 'type-fest';
588
394
 
589
- // The following implementation is not tail recursive
590
- type Includes<S extends string, Char extends string> =
591
- S extends `${infer First}${infer Rest}`
592
- ? If<IsEqual<First, Char>,
593
- 'found',
594
- Includes<Rest, Char>>
595
- : 'not found';
596
-
597
- // Hence, instantiations with long strings will fail
598
- // @ts-expect-error
599
- type Fails = Includes<HundredZeroes, '1'>;
600
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
601
- // Error: Type instantiation is excessively deep and possibly infinite.
602
-
603
- // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
604
- type IncludesWithoutIf<S extends string, Char extends string> =
605
- S extends `${infer First}${infer Rest}`
606
- ? IsEqual<First, Char> extends true
607
- ? 'found'
608
- : IncludesWithoutIf<Rest, Char>
609
- : 'not found';
610
-
611
- // Now, instantiations with long strings will work
612
- type Works = IncludesWithoutIf<HundredZeroes, '1'>;
613
- //=> 'not found'
395
+ type UnknownTriplet = TupleOf<3>;
396
+ //=> [unknown, unknown, unknown]
614
397
  ```
615
398
 
616
- @category Type Guard
617
- @category Utilities
618
- */
619
- type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
620
- //#endregion
621
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/internal/type.d.ts
622
- /**
623
- An if-else-like type that resolves depending on whether the given type is `any` or `never`.
399
+ Note: If the specified length is negative, the result will be an empty tuple.
624
400
 
625
401
  @example
626
402
  ```
627
- // When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
628
- type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
629
- //=> 'VALID'
630
-
631
- // When `T` is `any` => Returns `IfAny` branch
632
- type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
633
- //=> 'IS_ANY'
403
+ import type {TupleOf} from 'type-fest';
634
404
 
635
- // When `T` is `never` => Returns `IfNever` branch
636
- type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
637
- //=> 'IS_NEVER'
405
+ type EmptyTuple = TupleOf<-3, string>;
406
+ //=> []
638
407
  ```
639
408
 
640
- Note: Wrapping a tail-recursive type with `IfNotAnyOrNever` makes the implementation non-tail-recursive. To fix this, move the recursion into a helper type. Refer to the following example:
641
-
642
- @example
643
- ```ts
644
- import type {StringRepeat} from 'type-fest';
645
-
646
- type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
647
-
648
- // The following implementation is not tail recursive
649
- type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>;
409
+ Note: If you need a readonly tuple, simply wrap this type with `Readonly`, for example, to create `readonly [number, number, number]` use `Readonly<TupleOf<3, number>>`.
650
410
 
651
- // Hence, instantiations with long strings will fail
652
- // @ts-expect-error
653
- type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
654
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
655
- // Error: Type instantiation is excessively deep and possibly infinite.
656
-
657
- // To fix this, move the recursion into a helper type
658
- type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S>>;
659
-
660
- type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
661
-
662
- type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
663
- //=> ''
664
- ```
411
+ @category Array
665
412
  */
666
- type IfNotAnyOrNever<T, IfNotAnyOrNever$1, IfAny = any, IfNever = never> = If<IsAny<T>, IfAny, If<IsNever<T>, IfNever, IfNotAnyOrNever$1>>;
413
+ type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length, _TupleOf<If<IsNegative<Length>, 0, Length>, Fill, []>, Fill[], []>;
414
+ type _TupleOf<L extends number, Fill, Accumulator extends UnknownArray> = number extends L ? Fill[] : L extends Accumulator['length'] ? Accumulator : _TupleOf<L, Fill, [...Accumulator, Fill]>;
667
415
  //#endregion
668
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/simplify.d.ts
416
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/or.d.ts
669
417
  /**
670
- Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
671
-
672
- @example
673
- ```
674
- import type {Simplify} from 'type-fest';
675
-
676
- type PositionProps = {
677
- top: number;
678
- left: number;
679
- };
680
-
681
- type SizeProps = {
682
- width: number;
683
- height: number;
684
- };
685
-
686
- // In your editor, hovering over `Props` will show a flattened object with all the properties.
687
- type Props = Simplify<PositionProps & SizeProps>;
688
- ```
689
-
690
- Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
418
+ Returns a boolean for whether either of two given types is true.
691
419
 
692
- If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
420
+ Use-case: Constructing complex conditional types where at least one condition must be satisfied.
693
421
 
694
422
  @example
695
423
  ```
696
- import type {Simplify} from 'type-fest';
424
+ import type {Or} from 'type-fest';
697
425
 
698
- interface SomeInterface {
699
- foo: number;
700
- bar?: string;
701
- baz: number | undefined;
702
- }
703
-
704
- type SomeType = {
705
- foo: number;
706
- bar?: string;
707
- baz: number | undefined;
708
- };
426
+ type TT = Or<true, true>;
427
+ //=> true
709
428
 
710
- const literal = {foo: 123, bar: 'hello', baz: 456};
711
- const someType: SomeType = literal;
712
- const someInterface: SomeInterface = literal;
429
+ type TF = Or<true, false>;
430
+ //=> true
713
431
 
714
- declare function fn(object: Record<string, unknown>): void;
432
+ type FT = Or<false, true>;
433
+ //=> true
715
434
 
716
- fn(literal); // Good: literal object type is sealed
717
- fn(someType); // Good: type is sealed
718
- // @ts-expect-error
719
- fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
720
- fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
435
+ type FF = Or<false, false>;
436
+ //=> false
721
437
  ```
722
438
 
723
- @link https://github.com/microsoft/TypeScript/issues/15300
724
- @see {@link SimplifyDeep}
725
- @category Object
726
- */
727
- type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
728
- //#endregion
729
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-equal.d.ts
730
- /**
731
- Returns a boolean for whether the two given types are equal.
732
-
733
- @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
734
- @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
735
-
736
- Use-cases:
737
- - If you want to make a conditional branch based on the result of a comparison of two types.
439
+ Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
440
+ For example, `Or<false, boolean>` expands to `Or<false, true> | Or<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
738
441
 
739
442
  @example
740
443
  ```
741
- import type {IsEqual} from 'type-fest';
742
-
743
- // This type returns a boolean for whether the given array includes the given item.
744
- // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
745
- type Includes<Value extends readonly any[], Item> =
746
- Value extends readonly [Value[0], ...infer rest]
747
- ? IsEqual<Value[0], Item> extends true
748
- ? true
749
- : Includes<rest, Item>
750
- : false;
751
- ```
752
-
753
- @category Type Guard
754
- @category Utilities
755
- */
756
- type IsEqual<A$1, B$1> = [A$1] extends [B$1] ? [B$1] extends [A$1] ? _IsEqual<A$1, B$1> : false : false;
757
- // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
758
- type _IsEqual<A$1, B$1> = (<G>() => G extends A$1 & G | G ? 1 : 2) extends (<G>() => G extends B$1 & G | G ? 1 : 2) ? true : false;
759
- //#endregion
760
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/omit-index-signature.d.ts
761
- /**
762
- Omit any index signatures from the given object type, leaving only explicitly defined properties.
763
-
764
- This is the counterpart of `PickIndexSignature`.
444
+ import type {Or} from 'type-fest';
765
445
 
766
- Use-cases:
767
- - Remove overly permissive signatures from third-party types.
768
-
769
- This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
446
+ type A = Or<false, boolean>;
447
+ //=> boolean
770
448
 
771
- It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
449
+ type B = Or<boolean, false>;
450
+ //=> boolean
772
451
 
773
- (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
452
+ type C = Or<true, boolean>;
453
+ //=> true
774
454
 
775
- ```
776
- const indexed: Record<string, unknown> = {}; // Allowed
455
+ type D = Or<boolean, true>;
456
+ //=> true
777
457
 
778
- // @ts-expect-error
779
- const keyed: Record<'foo', unknown> = {}; // Error
780
- // => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
458
+ type E = Or<boolean, boolean>;
459
+ //=> boolean
781
460
  ```
782
461
 
783
- Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
462
+ Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
784
463
 
464
+ @example
785
465
  ```
786
- type Indexed = {} extends Record<string, unknown>
787
- ? '✅ `{}` is assignable to `Record<string, unknown>`'
788
- : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
789
- // => '✅ `{}` is assignable to `Record<string, unknown>`'
790
-
791
- type Keyed = {} extends Record<'foo' | 'bar', unknown>
792
- ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
793
- : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
794
- // => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
795
- ```
466
+ import type {Or} from 'type-fest';
796
467
 
797
- Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
468
+ type A = Or<true, never>;
469
+ //=> true
798
470
 
799
- ```
800
- type OmitIndexSignature<ObjectType> = {
801
- [KeyType in keyof ObjectType // Map each key of `ObjectType`...
802
- ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
803
- };
804
- ```
471
+ type B = Or<never, true>;
472
+ //=> true
805
473
 
806
- ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
474
+ type C = Or<false, never>;
475
+ //=> false
807
476
 
808
- ```
809
- type OmitIndexSignature<ObjectType> = {
810
- [KeyType in keyof ObjectType
811
- // Is `{}` assignable to `Record<KeyType, unknown>`?
812
- as {} extends Record<KeyType, unknown>
813
- ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
814
- : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
815
- ]: ObjectType[KeyType];
816
- };
817
- ```
477
+ type D = Or<never, false>;
478
+ //=> false
818
479
 
819
- If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
480
+ type E = Or<boolean, never>;
481
+ //=> boolean
820
482
 
821
- @example
822
- ```
823
- import type {OmitIndexSignature} from 'type-fest';
824
-
825
- type Example = {
826
- // These index signatures will be removed.
827
- [x: string]: any;
828
- [x: number]: any;
829
- [x: symbol]: any;
830
- [x: `head-${string}`]: string;
831
- [x: `${string}-tail`]: string;
832
- [x: `head-${string}-tail`]: string;
833
- [x: `${bigint}`]: string;
834
- [x: `embedded-${number}`]: string;
835
-
836
- // These explicitly defined keys will remain.
837
- foo: 'bar';
838
- qux?: 'baz';
839
- };
483
+ type F = Or<never, boolean>;
484
+ //=> boolean
840
485
 
841
- type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
842
- // => { foo: 'bar'; qux?: 'baz' | undefined; }
486
+ type G = Or<never, never>;
487
+ //=> false
843
488
  ```
844
489
 
845
- @see {@link PickIndexSignature}
846
- @category Object
490
+ @see {@link And}
491
+ @see {@link Xor}
847
492
  */
848
- type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
849
- //#endregion
850
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/pick-index-signature.d.ts
851
- /**
852
- Pick only index signatures from the given object type, leaving out all explicitly defined properties.
853
-
854
- This is the counterpart of `OmitIndexSignature`.
855
-
856
- @example
857
- ```
858
- import type {PickIndexSignature} from 'type-fest';
859
-
860
- declare const symbolKey: unique symbol;
861
-
862
- type Example = {
863
- // These index signatures will remain.
864
- [x: string]: unknown;
865
- [x: number]: unknown;
866
- [x: symbol]: unknown;
867
- [x: `head-${string}`]: string;
868
- [x: `${string}-tail`]: string;
869
- [x: `head-${string}-tail`]: string;
870
- [x: `${bigint}`]: string;
871
- [x: `embedded-${number}`]: string;
872
-
873
- // These explicitly defined keys will be removed.
874
- ['kebab-case-key']: string;
875
- [symbolKey]: string;
876
- foo: 'bar';
877
- qux?: 'baz';
878
- };
493
+ type Or<A$1 extends boolean, B$1 extends boolean> = _Or<If<IsNever<A$1>, false, A$1>, If<IsNever<B$1>, false, B$1>>;
494
+ // `never` is treated as `false`
879
495
 
880
- type ExampleIndexSignature = PickIndexSignature<Example>;
881
- // {
882
- // [x: string]: unknown;
883
- // [x: number]: unknown;
884
- // [x: symbol]: unknown;
885
- // [x: `head-${string}`]: string;
886
- // [x: `${string}-tail`]: string;
887
- // [x: `head-${string}-tail`]: string;
888
- // [x: `${bigint}`]: string;
889
- // [x: `embedded-${number}`]: string;
890
- // }
891
- ```
892
-
893
- @see {@link OmitIndexSignature}
894
- @category Object
895
- */
896
- type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
496
+ type _Or<A$1 extends boolean, B$1 extends boolean> = A$1 extends true ? true : B$1 extends true ? true : false;
897
497
  //#endregion
898
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/merge.d.ts
899
- // Merges two objects without worrying about index signatures.
900
- type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
901
-
498
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/all-extend.d.ts
902
499
  /**
903
- Merge two types into a new type. Keys of the second type overrides keys of the first type.
904
-
905
- @example
906
- ```
907
- import type {Merge} from 'type-fest';
908
-
909
- type Foo = {
910
- [x: string]: unknown;
911
- [x: number]: unknown;
912
- foo: string;
913
- bar: symbol;
500
+ @see {@link AllExtend}
501
+ */
502
+ type AllExtendOptions = {
503
+ /**
504
+ Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
505
+ - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
506
+ - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
507
+ @default true
508
+ @example
509
+ ```
510
+ import type {AllExtend} from 'type-fest';
511
+ type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
512
+ //=> false
513
+ type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
514
+ //=> true
515
+ type C = AllExtend<[never, never], never, {strictNever: true}>;
516
+ //=> true
517
+ type D = AllExtend<[never, never], never, {strictNever: false}>;
518
+ //=> true
519
+ type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
520
+ //=> true
521
+ type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
522
+ //=> true
523
+ type G = AllExtend<[never, 1], never, {strictNever: true}>;
524
+ //=> false
525
+ type H = AllExtend<[never, 1], never, {strictNever: false}>;
526
+ //=> false
527
+ ```
528
+ */
529
+ strictNever?: boolean;
914
530
  };
915
-
916
- type Bar = {
917
- [x: number]: number;
918
- [x: symbol]: unknown;
919
- bar: Date;
920
- baz: boolean;
531
+ type DefaultAllExtendOptions = {
532
+ strictNever: true;
921
533
  };
922
534
 
923
- export type FooBar = Merge<Foo, Bar>;
924
- // => {
925
- // [x: string]: unknown;
926
- // [x: number]: number;
927
- // [x: symbol]: unknown;
928
- // foo: string;
929
- // bar: Date;
930
- // baz: boolean;
931
- // }
932
- ```
933
-
934
- @category Object
935
- */
936
- type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
937
- //#endregion
938
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/internal/object.d.ts
939
535
  /**
940
- Works similar to the built-in `Pick` utility type, except for the following differences:
941
- - Distributes over union types and allows picking keys from any member of the union type.
942
- - Primitives types are returned as-is.
943
- - Picks all keys if `Keys` is `any`.
944
- - Doesn't pick `number` from a `string` index signature.
536
+ Returns a boolean for whether every element in an array type extends another type.
945
537
 
946
538
  @example
947
539
  ```
948
- type ImageUpload = {
949
- url: string;
950
- size: number;
951
- thumbnailUrl: string;
952
- };
953
-
954
- type VideoUpload = {
955
- url: string;
956
- duration: number;
957
- encodingFormat: string;
958
- };
540
+ import type {AllExtend} from 'type-fest';
959
541
 
960
- // Distributes over union types and allows picking keys from any member of the union type
961
- type MediaDisplay = HomomorphicPick<ImageUpload | VideoUpload, "url" | "size" | "duration">;
962
- //=> {url: string; size: number} | {url: string; duration: number}
963
-
964
- // Primitive types are returned as-is
965
- type Primitive = HomomorphicPick<string | number, 'toUpperCase' | 'toString'>;
966
- //=> string | number
542
+ type A = AllExtend<[1, 2, 3], number>;
543
+ //=> true
967
544
 
968
- // Picks all keys if `Keys` is `any`
969
- type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
970
- //=> {a: 1; b: 2} | {c: 3}
545
+ type B = AllExtend<[1, 2, '3'], number>;
546
+ //=> false
971
547
 
972
- // Doesn't pick `number` from a `string` index signature
973
- type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
974
- //=> {}
975
- */
976
- type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P] };
977
- /**
978
- Merges user specified options with default options.
548
+ type C = AllExtend<[number, number | string], number>;
549
+ //=> boolean
979
550
 
980
- @example
551
+ type D = AllExtend<[true, boolean, true], true>;
552
+ //=> boolean
981
553
  ```
982
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
983
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
984
- type SpecifiedOptions = {leavesOnly: true};
985
554
 
986
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
987
- //=> {maxRecursionDepth: 10; leavesOnly: true}
988
- ```
555
+ Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
989
556
 
990
- @example
991
557
  ```
992
- // Complains if default values are not provided for optional options
558
+ // @exactOptionalPropertyTypes: true
559
+ import type {AllExtend} from 'type-fest';
993
560
 
994
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
995
- type DefaultPathsOptions = {maxRecursionDepth: 10};
996
- type SpecifiedOptions = {};
997
-
998
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
999
- // ~~~~~~~~~~~~~~~~~~~
1000
- // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
561
+ type A = AllExtend<[1?, 2?, 3?], number>;
562
+ //=> true
1001
563
  ```
1002
564
 
1003
- @example
1004
565
  ```
1005
- // Complains if an option's default type does not conform to the expected type
1006
-
1007
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1008
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
1009
- type SpecifiedOptions = {};
566
+ // @exactOptionalPropertyTypes: false
567
+ import type {AllExtend} from 'type-fest';
1010
568
 
1011
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1012
- // ~~~~~~~~~~~~~~~~~~~
1013
- // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
1014
- ```
569
+ type A = AllExtend<[1?, 2?, 3?], number>;
570
+ //=> boolean
1015
571
 
1016
- @example
572
+ type B = AllExtend<[1?, 2?, 3?], number | undefined>;
573
+ //=> true
1017
574
  ```
1018
- // Complains if an option's specified type does not conform to the expected type
1019
575
 
1020
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1021
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
1022
- type SpecifiedOptions = {leavesOnly: 'yes'};
576
+ @see {@link AllExtendOptions}
1023
577
 
1024
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1025
- // ~~~~~~~~~~~~~~~~
1026
- // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
1027
- ```
578
+ @category Utilities
579
+ @category Array
1028
580
  */
1029
- type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
581
+ type AllExtend<TArray extends UnknownArray, Type$1, Options extends AllExtendOptions = {}> = _AllExtend<CollapseRestElement<TArray>, Type$1, ApplyDefaultOptions<AllExtendOptions, DefaultAllExtendOptions, Options>>;
582
+ type _AllExtend<TArray extends UnknownArray, Type$1, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, If<IsAny<Type$1>, true, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<IsNever<Type$1>, Not<Options['strictNever']>> extends true
583
+ // If target `Type` is also `never` OR `strictNever` is disabled, recurse further.
584
+ ? _AllExtend<Rest, Type$1, Options> : false : First extends Type$1 ? _AllExtend<Rest, Type$1, Options> : false : true>, false, false>;
1030
585
  //#endregion
1031
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/except.d.ts
586
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/and.d.ts
1032
587
  /**
1033
- Filter out keys from an object.
1034
-
1035
- Returns `never` if `Exclude` is strictly equal to `Key`.
1036
- Returns `never` if `Key` extends `Exclude`.
1037
- Returns `Key` otherwise.
1038
-
1039
- @example
1040
- ```
1041
- type Filtered = Filter<'foo', 'foo'>;
1042
- //=> never
1043
- ```
588
+ Returns a boolean for whether two given types are both true.
1044
589
 
1045
- @example
1046
- ```
1047
- type Filtered = Filter<'bar', string>;
1048
- //=> never
1049
- ```
590
+ Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
1050
591
 
1051
592
  @example
1052
593
  ```
1053
- type Filtered = Filter<'bar', 'foo'>;
1054
- //=> 'bar'
1055
- ```
594
+ import type {And} from 'type-fest';
1056
595
 
1057
- @see {Except}
1058
- */
1059
- type Filter<KeyType$1, ExcludeType> = IsEqual<KeyType$1, ExcludeType> extends true ? never : (KeyType$1 extends ExcludeType ? never : KeyType$1);
1060
- type ExceptOptions = {
1061
- /**
1062
- Disallow assigning non-specified properties.
1063
- Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
1064
- @default false
1065
- */
1066
- requireExactProps?: boolean;
1067
- };
1068
- type DefaultExceptOptions = {
1069
- requireExactProps: false;
1070
- };
596
+ type TT = And<true, true>;
597
+ //=> true
1071
598
 
1072
- /**
1073
- Create a type from an object type without certain keys.
599
+ type TF = And<true, false>;
600
+ //=> false
1074
601
 
1075
- We recommend setting the `requireExactProps` option to `true`.
602
+ type FT = And<false, true>;
603
+ //=> false
1076
604
 
1077
- This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
605
+ type FF = And<false, false>;
606
+ //=> false
607
+ ```
1078
608
 
1079
- This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
609
+ Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
610
+ For example, `And<true, boolean>` expands to `And<true, true> | And<true, false>`, which simplifies to `true | false` (i.e., `boolean`).
1080
611
 
1081
612
  @example
1082
613
  ```
1083
- import type {Except} from 'type-fest';
1084
-
1085
- type Foo = {
1086
- a: number;
1087
- b: string;
1088
- };
1089
-
1090
- type FooWithoutA = Except<Foo, 'a'>;
1091
- //=> {b: string}
1092
-
1093
- // @ts-expect-error
1094
- const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
1095
- //=> errors: 'a' does not exist in type '{ b: string; }'
614
+ import type {And} from 'type-fest';
1096
615
 
1097
- type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
1098
- //=> {a: number} & Partial<Record<"b", never>>
1099
-
1100
- // @ts-expect-error
1101
- const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
1102
- //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
1103
-
1104
- // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
616
+ type A = And<true, boolean>;
617
+ //=> boolean
1105
618
 
1106
- // Consider the following example:
619
+ type B = And<boolean, true>;
620
+ //=> boolean
1107
621
 
1108
- type UserData = {
1109
- [metadata: string]: string;
1110
- email: string;
1111
- name: string;
1112
- role: 'admin' | 'user';
1113
- };
622
+ type C = And<false, boolean>;
623
+ //=> false
1114
624
 
1115
- // `Omit` clearly doesn't behave as expected in this case:
1116
- type PostPayload = Omit<UserData, 'email'>;
1117
- //=> { [x: string]: string; [x: number]: string; }
625
+ type D = And<boolean, false>;
626
+ //=> false
1118
627
 
1119
- // In situations like this, `Except` works better.
1120
- // It simply removes the `email` key while preserving all the other keys.
1121
- type PostPayloadFixed = Except<UserData, 'email'>;
1122
- //=> { [x: string]: string; name: string; role: 'admin' | 'user'; }
628
+ type E = And<boolean, boolean>;
629
+ //=> boolean
1123
630
  ```
1124
631
 
1125
- @category Object
1126
- */
1127
- type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
1128
- type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
1129
- //#endregion
1130
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/require-at-least-one.d.ts
1131
- /**
1132
- Create a type that requires at least one of the given keys. The remaining keys are kept as is.
632
+ Note: If either of the types is `never`, the result becomes `false`.
1133
633
 
1134
634
  @example
1135
635
  ```
1136
- import type {RequireAtLeastOne} from 'type-fest';
1137
-
1138
- type Responder = {
1139
- text?: () => string;
1140
- json?: () => string;
1141
- secure?: boolean;
1142
- };
1143
-
1144
- const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
1145
- json: () => '{"message": "ok"}',
1146
- secure: true,
1147
- };
1148
- ```
636
+ import type {And} from 'type-fest';
1149
637
 
1150
- @category Object
1151
- */
1152
- type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If<IsNever<KeysType>, never, _RequireAtLeastOne<ObjectType, If<IsAny<KeysType>, keyof ObjectType, KeysType>>>>;
1153
- type _RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = {
1154
- // For each `Key` in `KeysType` make a mapped type:
1155
- [Key in KeysType]-?: Required<Pick<ObjectType, Key>> &
1156
- // 1. Make `Key`'s type required
1157
- // 2. Make all other keys in `KeysType` optional
1158
- Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] &
1159
- // 3. Add the remaining keys not in `KeysType`
1160
- Except<ObjectType, KeysType>;
1161
- //#endregion
1162
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/non-empty-object.d.ts
1163
- /**
1164
- Represents an object with at least 1 non-optional key.
638
+ type A = And<true, never>;
639
+ //=> false
1165
640
 
1166
- This is useful when you need an object where all keys are optional, but there must be at least 1 key.
641
+ type B = And<never, true>;
642
+ //=> false
1167
643
 
1168
- @example
1169
- ```
1170
- import type {NonEmptyObject} from 'type-fest';
644
+ type C = And<false, never>;
645
+ //=> false
1171
646
 
1172
- type User = {
1173
- name: string;
1174
- surname: string;
1175
- id: number;
1176
- };
647
+ type D = And<never, false>;
648
+ //=> false
1177
649
 
1178
- type UpdateRequest<Entity extends object> = NonEmptyObject<Partial<Entity>>;
650
+ type E = And<boolean, never>;
651
+ //=> false
1179
652
 
1180
- const update1: UpdateRequest<User> = {
1181
- name: 'Alice',
1182
- surname: 'Acme',
1183
- };
653
+ type F = And<never, boolean>;
654
+ //=> false
1184
655
 
1185
- // At least 1 key is required, therefore this will report a 2322 error:
1186
- // Type '{}' is not assignable to type 'UpdateRequest<User>'
1187
- // @ts-expect-error
1188
- const update2: UpdateRequest<User> = {};
656
+ type G = And<never, never>;
657
+ //=> false
1189
658
  ```
1190
659
 
1191
- @see Use `IsEmptyObject` to check whether an object is empty.
1192
-
1193
- @category Object
660
+ @see {@link Or}
661
+ @see {@link Xor}
1194
662
  */
1195
- type NonEmptyObject<T extends object> = HasRequiredKeys<T> extends true ? T : RequireAtLeastOne<T, keyof T>;
663
+ type And<A$1 extends boolean, B$1 extends boolean> = AllExtend<[A$1, B$1], true>;
1196
664
  //#endregion
1197
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/union-to-tuple.d.ts
665
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/union-to-tuple.d.ts
1198
666
  /**
1199
667
  Returns the last element of a union type.
1200
668
 
@@ -1243,7 +711,7 @@ const petList = Object.keys(pets) as UnionToTuple<Pet>;
1243
711
  */
1244
712
  type UnionToTuple<T, L = LastOfUnion<T>> = IsNever<T> extends false ? [...UnionToTuple<Exclude<T, L>>, L] : [];
1245
713
  //#endregion
1246
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/set-optional.d.ts
714
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/set-optional.d.ts
1247
715
  /**
1248
716
  Create a type that makes the given keys optional. The remaining keys are kept as is. The sister of the `SetRequired` type.
1249
717
 
@@ -1277,31 +745,66 @@ Except<BaseType, Keys> &
1277
745
  // Pick the keys that should be mutable from the base type and make them mutable.
1278
746
  Partial<HomomorphicPick<BaseType, Keys>>> : never;
1279
747
  //#endregion
1280
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/value-of.d.ts
748
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/split.d.ts
749
+ /**
750
+ Split options.
751
+
752
+ @see {@link Split}
753
+ */
754
+ type SplitOptions = {
755
+ /**
756
+ When enabled, instantiations with non-literal string types (e.g., `string`, `Uppercase<string>`, `on${string}`) simply return back `string[]` without performing any splitting, as the exact structure cannot be statically determined.
757
+ @default true
758
+ @example
759
+ ```ts
760
+ import type {Split} from 'type-fest';
761
+ type Example1 = Split<`foo.${string}.bar`, '.', {strictLiteralChecks: false}>;
762
+ //=> ['foo', string, 'bar']
763
+ type Example2 = Split<`foo.${string}`, '.', {strictLiteralChecks: true}>;
764
+ //=> string[]
765
+ type Example3 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: false}>;
766
+ //=> ['foo', 'r', 'z']
767
+ type Example4 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: true}>;
768
+ //=> string[]
769
+ ```
770
+ */
771
+ strictLiteralChecks?: boolean;
772
+ };
773
+ type DefaultSplitOptions = {
774
+ strictLiteralChecks: true;
775
+ };
776
+
1281
777
  /**
1282
- Create a union of the given object's values, and optionally specify which keys to get the values from.
778
+ Represents an array of strings split using a given character or character set.
1283
779
 
1284
- Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31438) if you want to have this type as a built-in in TypeScript.
780
+ Use-case: Defining the return type of a method like `String.prototype.split`.
1285
781
 
1286
782
  @example
1287
783
  ```
1288
- import type {ValueOf} from 'type-fest';
784
+ import type {Split} from 'type-fest';
1289
785
 
1290
- type A = ValueOf<{id: number; name: string; active: boolean}>;
1291
- //=> number | string | boolean
786
+ declare function split<S extends string, D extends string>(string: S, separator: D): Split<S, D>;
1292
787
 
1293
- type B = ValueOf<{id: number; name: string; active: boolean}, 'name'>;
1294
- //=> string
1295
-
1296
- type C = ValueOf<{id: number; name: string; active: boolean}, 'id' | 'name'>;
1297
- //=> number | string
788
+ type Item = 'foo' | 'bar' | 'baz' | 'waldo';
789
+ const items = 'foo,bar,baz,waldo';
790
+ const array: Item[] = split(items, ',');
1298
791
  ```
1299
792
 
1300
- @category Object
793
+ @see {@link SplitOptions}
794
+
795
+ @category String
796
+ @category Template literal
1301
797
  */
1302
- type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
1303
- //#endregion
1304
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/replace.d.ts
798
+ type Split<S extends string, Delimiter extends string, Options extends SplitOptions = {}> = SplitHelper<S, Delimiter, ApplyDefaultOptions<SplitOptions, DefaultSplitOptions, Options>>;
799
+ type SplitHelper<S extends string, Delimiter extends string, Options extends Required<SplitOptions>, Accumulator extends string[] = []> = S extends string // For distributing `S`
800
+ ? Delimiter extends string // For distributing `Delimiter`
801
+ // If `strictLiteralChecks` is `false` OR `S` and `Delimiter` both are string literals, then perform the split
802
+ ? Or<Not<Options['strictLiteralChecks']>, And<IsStringLiteral<S>, IsStringLiteral<Delimiter>>> extends true ? S extends `${infer Head}${Delimiter}${infer Tail}` ? SplitHelper<Tail, Delimiter, Options, [...Accumulator, Head]> : Delimiter extends '' ? S extends '' ? Accumulator : [...Accumulator, S] : [...Accumulator, S]
803
+ // Otherwise, return `string[]`
804
+ : string[] : never // Should never happen
805
+ : never; // Should never happen
806
+ //#endregion
807
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/replace.d.ts
1305
808
  type ReplaceOptions = {
1306
809
  all?: boolean;
1307
810
  };
@@ -1367,38 +870,959 @@ type _Replace<Input extends string, Search extends string, Replacement extends s
1367
870
  ? Replacement extends string // For distributing `Replacement`
1368
871
  ? Input extends `${infer Head}${Search}${infer Tail}` ? Options['all'] extends true ? _Replace<Tail, Search, Replacement, Options, `${Accumulator}${Head}${Replacement}`> : `${Head}${Replacement}${Tail}` : `${Accumulator}${Input}` : never : never;
1369
872
  //#endregion
1370
- //#region src/utils/object/enumEntries.d.ts
873
+ //#region src/utils/array/arrayCast.d.ts
874
+ /**
875
+ * 构造数组
876
+ * @param candidate 待构造项
877
+ * @param checkEmpty 是否检查 `undefined` 和 `null`,默认为 `true`
878
+ * @returns 构造后的数组
879
+ * @example
880
+ * ```ts
881
+ * arrayCast(1); // [1]
882
+ * arrayCast([1, 2]); // [1, 2]
883
+ * arrayCast(null); // []
884
+ * arrayCast(undefined); // []
885
+ * arrayCast(null, false); // [null]
886
+ * ```
887
+ */
888
+ declare function arrayCast<T>(candidate: T | T[] | null | undefined, checkEmpty?: true): NonNullable<T>[];
889
+ declare function arrayCast<T>(candidate: T | T[] | null | undefined, checkEmpty?: false): T[];
890
+ //#endregion
891
+ //#region src/utils/array/arrayCompete.d.ts
892
+ /**
893
+ * 数组竞争
894
+ * - 返回在匹配函数的比较条件中获胜的最终项目,适用于更复杂的最小值/最大值计算
895
+ *
896
+ * @param initialList 数组
897
+ * @param match 匹配函数
898
+ * @returns 获胜的元素,如果数组为空或参数无效则返回 `null`
899
+ * @example
900
+ * ```ts
901
+ * const list = [1, 10, 5];
902
+ * arrayCompete(list, (a, b) => (a > b ? a : b)); // 10
903
+ * arrayCompete(list, (a, b) => (a < b ? a : b)); // 1
904
+ * ```
905
+ */
906
+ declare function arrayCompete<T>(initialList: readonly T[], match: (a: T, b: T, index: number) => T): T | null;
907
+ //#endregion
908
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/List.d.ts
909
+ /**
910
+ * A [[List]]
911
+ * @param A its type
912
+ * @returns [[List]]
913
+ * @example
914
+ * ```ts
915
+ * type list0 = [1, 2, 3]
916
+ * type list1 = number[]
917
+ * ```
918
+ */
919
+ declare type List<A$1 = any> = ReadonlyArray<A$1>;
920
+ //#endregion
921
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Any/Cast.d.ts
1371
922
  /**
1372
- * 返回枚举的属性的键/值数组
923
+ * Ask TS to re-check that `A1` extends `A2`.
924
+ * And if it fails, `A2` will be enforced anyway.
925
+ * Can also be used to add constraints on parameters.
926
+ * @param A1 to check against
927
+ * @param A2 to cast to
928
+ * @returns `A1 | A2`
929
+ * @example
930
+ * ```ts
931
+ * import {A} from 'ts-toolbelt'
1373
932
  *
1374
- * @param enumeration 枚举
933
+ * type test0 = A.Cast<'42', string> // '42'
934
+ * type test1 = A.Cast<'42', number> // number
935
+ * ```
1375
936
  */
1376
- declare function enumEntries<E extends AnyObject>(enumeration: NonEmptyObject<E>): [keyof E, E[keyof E]][];
937
+ declare type Cast<A1 extends any, A2 extends any> = A1 extends A2 ? A1 : A2;
1377
938
  //#endregion
1378
- //#region src/utils/object/enumKeys.d.ts
939
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Any/Extends.d.ts
940
+ /**
941
+ * Check whether `A1` is part of `A2` or not. The difference with
942
+ * `extends` is that it forces a [[Boolean]] return.
943
+ * @param A1
944
+ * @param A2
945
+ * @returns [[Boolean]]
946
+ * @example
947
+ * ```ts
948
+ * import {A} from 'ts-toolbelt'
949
+ *
950
+ * type test0 = A.Extends<'a' | 'b', 'b'> // Boolean
951
+ * type test1 = A.Extends<'a', 'a' | 'b'> // True
952
+ *
953
+ * type test2 = A.Extends<{a: string}, {a: any}> // True
954
+ * type test3 = A.Extends<{a: any}, {a: any, b: any}> // False
955
+ *
956
+ * type test4 = A.Extends<never, never> // False
957
+ * /// Nothing cannot extend nothing, use `A.Equals`
958
+ * ```
959
+ */
960
+ declare type Extends<A1 extends any, A2 extends any> = [A1] extends [never] ? 0 : A1 extends A2 ? 1 : 0;
961
+ //#endregion
962
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/Iteration.d.ts
963
+ /**
964
+ * An entry of `IterationMap`
965
+ */
966
+ declare type Iteration = [value: number, sign: '-' | '0' | '+', prev: keyof IterationMap, next: keyof IterationMap, oppo: keyof IterationMap];
967
+ declare type IterationMap = {
968
+ '__': [number, '-' | '0' | '+', '__', '__', '__'];
969
+ '-100': [-100, '-', '__', '-99', '100'];
970
+ '-99': [-99, '-', '-100', '-98', '99'];
971
+ '-98': [-98, '-', '-99', '-97', '98'];
972
+ '-97': [-97, '-', '-98', '-96', '97'];
973
+ '-96': [-96, '-', '-97', '-95', '96'];
974
+ '-95': [-95, '-', '-96', '-94', '95'];
975
+ '-94': [-94, '-', '-95', '-93', '94'];
976
+ '-93': [-93, '-', '-94', '-92', '93'];
977
+ '-92': [-92, '-', '-93', '-91', '92'];
978
+ '-91': [-91, '-', '-92', '-90', '91'];
979
+ '-90': [-90, '-', '-91', '-89', '90'];
980
+ '-89': [-89, '-', '-90', '-88', '89'];
981
+ '-88': [-88, '-', '-89', '-87', '88'];
982
+ '-87': [-87, '-', '-88', '-86', '87'];
983
+ '-86': [-86, '-', '-87', '-85', '86'];
984
+ '-85': [-85, '-', '-86', '-84', '85'];
985
+ '-84': [-84, '-', '-85', '-83', '84'];
986
+ '-83': [-83, '-', '-84', '-82', '83'];
987
+ '-82': [-82, '-', '-83', '-81', '82'];
988
+ '-81': [-81, '-', '-82', '-80', '81'];
989
+ '-80': [-80, '-', '-81', '-79', '80'];
990
+ '-79': [-79, '-', '-80', '-78', '79'];
991
+ '-78': [-78, '-', '-79', '-77', '78'];
992
+ '-77': [-77, '-', '-78', '-76', '77'];
993
+ '-76': [-76, '-', '-77', '-75', '76'];
994
+ '-75': [-75, '-', '-76', '-74', '75'];
995
+ '-74': [-74, '-', '-75', '-73', '74'];
996
+ '-73': [-73, '-', '-74', '-72', '73'];
997
+ '-72': [-72, '-', '-73', '-71', '72'];
998
+ '-71': [-71, '-', '-72', '-70', '71'];
999
+ '-70': [-70, '-', '-71', '-69', '70'];
1000
+ '-69': [-69, '-', '-70', '-68', '69'];
1001
+ '-68': [-68, '-', '-69', '-67', '68'];
1002
+ '-67': [-67, '-', '-68', '-66', '67'];
1003
+ '-66': [-66, '-', '-67', '-65', '66'];
1004
+ '-65': [-65, '-', '-66', '-64', '65'];
1005
+ '-64': [-64, '-', '-65', '-63', '64'];
1006
+ '-63': [-63, '-', '-64', '-62', '63'];
1007
+ '-62': [-62, '-', '-63', '-61', '62'];
1008
+ '-61': [-61, '-', '-62', '-60', '61'];
1009
+ '-60': [-60, '-', '-61', '-59', '60'];
1010
+ '-59': [-59, '-', '-60', '-58', '59'];
1011
+ '-58': [-58, '-', '-59', '-57', '58'];
1012
+ '-57': [-57, '-', '-58', '-56', '57'];
1013
+ '-56': [-56, '-', '-57', '-55', '56'];
1014
+ '-55': [-55, '-', '-56', '-54', '55'];
1015
+ '-54': [-54, '-', '-55', '-53', '54'];
1016
+ '-53': [-53, '-', '-54', '-52', '53'];
1017
+ '-52': [-52, '-', '-53', '-51', '52'];
1018
+ '-51': [-51, '-', '-52', '-50', '51'];
1019
+ '-50': [-50, '-', '-51', '-49', '50'];
1020
+ '-49': [-49, '-', '-50', '-48', '49'];
1021
+ '-48': [-48, '-', '-49', '-47', '48'];
1022
+ '-47': [-47, '-', '-48', '-46', '47'];
1023
+ '-46': [-46, '-', '-47', '-45', '46'];
1024
+ '-45': [-45, '-', '-46', '-44', '45'];
1025
+ '-44': [-44, '-', '-45', '-43', '44'];
1026
+ '-43': [-43, '-', '-44', '-42', '43'];
1027
+ '-42': [-42, '-', '-43', '-41', '42'];
1028
+ '-41': [-41, '-', '-42', '-40', '41'];
1029
+ '-40': [-40, '-', '-41', '-39', '40'];
1030
+ '-39': [-39, '-', '-40', '-38', '39'];
1031
+ '-38': [-38, '-', '-39', '-37', '38'];
1032
+ '-37': [-37, '-', '-38', '-36', '37'];
1033
+ '-36': [-36, '-', '-37', '-35', '36'];
1034
+ '-35': [-35, '-', '-36', '-34', '35'];
1035
+ '-34': [-34, '-', '-35', '-33', '34'];
1036
+ '-33': [-33, '-', '-34', '-32', '33'];
1037
+ '-32': [-32, '-', '-33', '-31', '32'];
1038
+ '-31': [-31, '-', '-32', '-30', '31'];
1039
+ '-30': [-30, '-', '-31', '-29', '30'];
1040
+ '-29': [-29, '-', '-30', '-28', '29'];
1041
+ '-28': [-28, '-', '-29', '-27', '28'];
1042
+ '-27': [-27, '-', '-28', '-26', '27'];
1043
+ '-26': [-26, '-', '-27', '-25', '26'];
1044
+ '-25': [-25, '-', '-26', '-24', '25'];
1045
+ '-24': [-24, '-', '-25', '-23', '24'];
1046
+ '-23': [-23, '-', '-24', '-22', '23'];
1047
+ '-22': [-22, '-', '-23', '-21', '22'];
1048
+ '-21': [-21, '-', '-22', '-20', '21'];
1049
+ '-20': [-20, '-', '-21', '-19', '20'];
1050
+ '-19': [-19, '-', '-20', '-18', '19'];
1051
+ '-18': [-18, '-', '-19', '-17', '18'];
1052
+ '-17': [-17, '-', '-18', '-16', '17'];
1053
+ '-16': [-16, '-', '-17', '-15', '16'];
1054
+ '-15': [-15, '-', '-16', '-14', '15'];
1055
+ '-14': [-14, '-', '-15', '-13', '14'];
1056
+ '-13': [-13, '-', '-14', '-12', '13'];
1057
+ '-12': [-12, '-', '-13', '-11', '12'];
1058
+ '-11': [-11, '-', '-12', '-10', '11'];
1059
+ '-10': [-10, '-', '-11', '-9', '10'];
1060
+ '-9': [-9, '-', '-10', '-8', '9'];
1061
+ '-8': [-8, '-', '-9', '-7', '8'];
1062
+ '-7': [-7, '-', '-8', '-6', '7'];
1063
+ '-6': [-6, '-', '-7', '-5', '6'];
1064
+ '-5': [-5, '-', '-6', '-4', '5'];
1065
+ '-4': [-4, '-', '-5', '-3', '4'];
1066
+ '-3': [-3, '-', '-4', '-2', '3'];
1067
+ '-2': [-2, '-', '-3', '-1', '2'];
1068
+ '-1': [-1, '-', '-2', '0', '1'];
1069
+ '0': [0, '0', '-1', '1', '0'];
1070
+ '1': [1, '+', '0', '2', '-1'];
1071
+ '2': [2, '+', '1', '3', '-2'];
1072
+ '3': [3, '+', '2', '4', '-3'];
1073
+ '4': [4, '+', '3', '5', '-4'];
1074
+ '5': [5, '+', '4', '6', '-5'];
1075
+ '6': [6, '+', '5', '7', '-6'];
1076
+ '7': [7, '+', '6', '8', '-7'];
1077
+ '8': [8, '+', '7', '9', '-8'];
1078
+ '9': [9, '+', '8', '10', '-9'];
1079
+ '10': [10, '+', '9', '11', '-10'];
1080
+ '11': [11, '+', '10', '12', '-11'];
1081
+ '12': [12, '+', '11', '13', '-12'];
1082
+ '13': [13, '+', '12', '14', '-13'];
1083
+ '14': [14, '+', '13', '15', '-14'];
1084
+ '15': [15, '+', '14', '16', '-15'];
1085
+ '16': [16, '+', '15', '17', '-16'];
1086
+ '17': [17, '+', '16', '18', '-17'];
1087
+ '18': [18, '+', '17', '19', '-18'];
1088
+ '19': [19, '+', '18', '20', '-19'];
1089
+ '20': [20, '+', '19', '21', '-20'];
1090
+ '21': [21, '+', '20', '22', '-21'];
1091
+ '22': [22, '+', '21', '23', '-22'];
1092
+ '23': [23, '+', '22', '24', '-23'];
1093
+ '24': [24, '+', '23', '25', '-24'];
1094
+ '25': [25, '+', '24', '26', '-25'];
1095
+ '26': [26, '+', '25', '27', '-26'];
1096
+ '27': [27, '+', '26', '28', '-27'];
1097
+ '28': [28, '+', '27', '29', '-28'];
1098
+ '29': [29, '+', '28', '30', '-29'];
1099
+ '30': [30, '+', '29', '31', '-30'];
1100
+ '31': [31, '+', '30', '32', '-31'];
1101
+ '32': [32, '+', '31', '33', '-32'];
1102
+ '33': [33, '+', '32', '34', '-33'];
1103
+ '34': [34, '+', '33', '35', '-34'];
1104
+ '35': [35, '+', '34', '36', '-35'];
1105
+ '36': [36, '+', '35', '37', '-36'];
1106
+ '37': [37, '+', '36', '38', '-37'];
1107
+ '38': [38, '+', '37', '39', '-38'];
1108
+ '39': [39, '+', '38', '40', '-39'];
1109
+ '40': [40, '+', '39', '41', '-40'];
1110
+ '41': [41, '+', '40', '42', '-41'];
1111
+ '42': [42, '+', '41', '43', '-42'];
1112
+ '43': [43, '+', '42', '44', '-43'];
1113
+ '44': [44, '+', '43', '45', '-44'];
1114
+ '45': [45, '+', '44', '46', '-45'];
1115
+ '46': [46, '+', '45', '47', '-46'];
1116
+ '47': [47, '+', '46', '48', '-47'];
1117
+ '48': [48, '+', '47', '49', '-48'];
1118
+ '49': [49, '+', '48', '50', '-49'];
1119
+ '50': [50, '+', '49', '51', '-50'];
1120
+ '51': [51, '+', '50', '52', '-51'];
1121
+ '52': [52, '+', '51', '53', '-52'];
1122
+ '53': [53, '+', '52', '54', '-53'];
1123
+ '54': [54, '+', '53', '55', '-54'];
1124
+ '55': [55, '+', '54', '56', '-55'];
1125
+ '56': [56, '+', '55', '57', '-56'];
1126
+ '57': [57, '+', '56', '58', '-57'];
1127
+ '58': [58, '+', '57', '59', '-58'];
1128
+ '59': [59, '+', '58', '60', '-59'];
1129
+ '60': [60, '+', '59', '61', '-60'];
1130
+ '61': [61, '+', '60', '62', '-61'];
1131
+ '62': [62, '+', '61', '63', '-62'];
1132
+ '63': [63, '+', '62', '64', '-63'];
1133
+ '64': [64, '+', '63', '65', '-64'];
1134
+ '65': [65, '+', '64', '66', '-65'];
1135
+ '66': [66, '+', '65', '67', '-66'];
1136
+ '67': [67, '+', '66', '68', '-67'];
1137
+ '68': [68, '+', '67', '69', '-68'];
1138
+ '69': [69, '+', '68', '70', '-69'];
1139
+ '70': [70, '+', '69', '71', '-70'];
1140
+ '71': [71, '+', '70', '72', '-71'];
1141
+ '72': [72, '+', '71', '73', '-72'];
1142
+ '73': [73, '+', '72', '74', '-73'];
1143
+ '74': [74, '+', '73', '75', '-74'];
1144
+ '75': [75, '+', '74', '76', '-75'];
1145
+ '76': [76, '+', '75', '77', '-76'];
1146
+ '77': [77, '+', '76', '78', '-77'];
1147
+ '78': [78, '+', '77', '79', '-78'];
1148
+ '79': [79, '+', '78', '80', '-79'];
1149
+ '80': [80, '+', '79', '81', '-80'];
1150
+ '81': [81, '+', '80', '82', '-81'];
1151
+ '82': [82, '+', '81', '83', '-82'];
1152
+ '83': [83, '+', '82', '84', '-83'];
1153
+ '84': [84, '+', '83', '85', '-84'];
1154
+ '85': [85, '+', '84', '86', '-85'];
1155
+ '86': [86, '+', '85', '87', '-86'];
1156
+ '87': [87, '+', '86', '88', '-87'];
1157
+ '88': [88, '+', '87', '89', '-88'];
1158
+ '89': [89, '+', '88', '90', '-89'];
1159
+ '90': [90, '+', '89', '91', '-90'];
1160
+ '91': [91, '+', '90', '92', '-91'];
1161
+ '92': [92, '+', '91', '93', '-92'];
1162
+ '93': [93, '+', '92', '94', '-93'];
1163
+ '94': [94, '+', '93', '95', '-94'];
1164
+ '95': [95, '+', '94', '96', '-95'];
1165
+ '96': [96, '+', '95', '97', '-96'];
1166
+ '97': [97, '+', '96', '98', '-97'];
1167
+ '98': [98, '+', '97', '99', '-98'];
1168
+ '99': [99, '+', '98', '100', '-99'];
1169
+ '100': [100, '+', '99', '__', '-100'];
1170
+ };
1171
+ //#endregion
1172
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/Prev.d.ts
1379
1173
  /**
1380
- * 获取枚举所有属性的键
1174
+ * Move `I`'s position backwards
1175
+ * @param I to move
1176
+ * @returns [[Iteration]]
1177
+ * @example
1178
+ * ```ts
1179
+ * import {I} from 'ts-toolbelt'
1381
1180
  *
1382
- * @param enumeration 枚举
1181
+ * type i = I.IterationOf<'20'>
1182
+ *
1183
+ * type test0 = I.Pos<i> // 20
1184
+ * type test1 = I.Pos<I.Prev<i>> // 19
1185
+ * ```
1186
+ */
1187
+ declare type Prev<I$1 extends Iteration> = IterationMap[I$1[2]];
1188
+ //#endregion
1189
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/IterationOf.d.ts
1190
+ /**
1191
+ * Transform a number into an [[Iteration]]
1192
+ * (to use [[Prev]], [[Next]], & [[Pos]])
1193
+ * @param N to transform
1194
+ * @returns [[Iteration]]
1195
+ * @example
1196
+ * ```ts
1197
+ * import {I} from 'ts-toolbelt'
1198
+ *
1199
+ * type i = I.IterationOf<0> // ["-1", "1", "0", 0, "0"]
1200
+ *
1201
+ * type next = I.Next<i> // ["0", "2", "1", 1, "+"]
1202
+ * type prev = I.Prev<i> // ["-2", "0", "-1", -1, "-"]
1203
+ *
1204
+ * type nnext = I.Pos<next> // +1
1205
+ * type nprev = I.Pos<prev> // -1
1206
+ * ```
1207
+ */
1208
+ declare type IterationOf<N extends number> = `${N}` extends keyof IterationMap ? IterationMap[`${N}`] : IterationMap['__'];
1209
+ //#endregion
1210
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/Pos.d.ts
1211
+ /**
1212
+ * Get the position of `I` (**number**)
1213
+ * @param I to query
1214
+ * @returns `number`
1215
+ * @example
1216
+ * ```ts
1217
+ * import {I} from 'ts-toolbelt'
1218
+ *
1219
+ * type i = I.IterationOf<'20'>
1220
+ *
1221
+ * type test0 = I.Pos<i> // 20
1222
+ * type test1 = I.Pos<I.Next<i>> // 21
1223
+ * ```
1224
+ */
1225
+ declare type Pos<I$1 extends Iteration> = I$1[0];
1226
+ //#endregion
1227
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Tail.d.ts
1228
+ /**
1229
+ * Remove the first item out of a [[List]]
1230
+ * @param L
1231
+ * @returns [[List]]
1232
+ * @example
1233
+ * ```ts
1234
+ * ```
1235
+ */
1236
+ declare type Tail$1<L extends List> = L extends readonly [] ? L : L extends readonly [any?, ...infer LTail] ? LTail : L;
1237
+ //#endregion
1238
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Object/Overwrite.d.ts
1239
+ /**
1240
+ * Update the fields of `O` with the ones of `O1`
1241
+ * (only the existing fields will be updated)
1242
+ * @param O to update
1243
+ * @param O1 to update with
1244
+ * @returns [[Object]]
1245
+ * @example
1246
+ * ```ts
1247
+ * ```
1248
+ */
1249
+ declare type Overwrite<O extends object, O1 extends object> = { [K in keyof O]: K extends keyof O1 ? O1[K] : O[K] } & {};
1250
+ //#endregion
1251
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/_Internal.d.ts
1252
+ /**
1253
+ * Remove `?` & `readonly` from a [[List]]
1254
+ */
1255
+ declare type Naked<L extends List> = Overwrite<Required<L>, L>;
1256
+ //#endregion
1257
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Prepend.d.ts
1258
+ /**
1259
+ * Add an element `A` at the beginning of `L`
1260
+ * @param L to append to
1261
+ * @param A to be added to
1262
+ * @returns [[List]]
1263
+ * @example
1264
+ * ```ts
1265
+ * ```
1266
+ */
1267
+ declare type Prepend<L extends List, A$1 extends any> = [A$1, ...L];
1268
+ //#endregion
1269
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/_Internal.d.ts
1270
+ /**
1271
+ * Describes how to perform iterations
1272
+ */
1273
+ declare type Way = '->' | '<-';
1274
+ //#endregion
1275
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Append.d.ts
1276
+ /**
1277
+ * Add an element `A` at the end of `L`.
1278
+ * @param L to append to
1279
+ * @param A to be added to
1280
+ * @returns [[List]]
1281
+ * @example
1282
+ * ```ts
1283
+ * import {L} from 'ts-toolbelt'
1284
+ *
1285
+ * type test0 = L.Append<[1, 2, 3], 4> // [1, 2, 3, 4]
1286
+ * type test1 = L.Append<[], 'a'> // ['a']
1287
+ * type test2 = L.Append<readonly ['a', 'b'], 'c'> // ['a', 'b', 'c']
1288
+ * type test3 = L.Append<[1, 2], [3, 4]> // [1, 2, [3, 4]]
1289
+ * ```
1290
+ */
1291
+ declare type Append<L extends List, A$1 extends any> = [...L, A$1];
1292
+ //#endregion
1293
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Drop.d.ts
1294
+ /**
1295
+ * @hidden
1296
+ */
1297
+ declare type DropForth<L extends List, N extends Iteration> = {
1298
+ 0: DropForth<Tail$1<L>, Prev<N>>;
1299
+ 1: L;
1300
+ }[Extends<0, Pos<N>>];
1301
+ /**
1302
+ * @hidden
1303
+ */
1304
+ declare type DropBack<L extends List, N extends Iteration, I$1 extends Iteration = Prev<N>, LN extends List = []> = {
1305
+ 0: DropBack<L, N, Prev<I$1>, Prepend<LN, L[Pos<I$1>]>>;
1306
+ 1: LN;
1307
+ }[Extends<-1, Pos<I$1>>];
1308
+ /**
1309
+ * @hidden
1310
+ */
1311
+ declare type __Drop<L extends List, N extends Iteration, way extends Way> = {
1312
+ '->': DropForth<L, N>;
1313
+ '<-': DropBack<L, N>;
1314
+ }[way];
1315
+ /**
1316
+ * @hidden
1317
+ */
1318
+ declare type _Drop<L extends List, N extends number, way extends Way = '->'> = __Drop<Naked<L>, IterationOf<N>, way> extends infer X ? Cast<X, List> : never;
1319
+ /**
1320
+ * Remove `N` entries out of `L`
1321
+ * @param L to remove from
1322
+ * @param N to remove out
1323
+ * @param way (?=`'->'`) from front: '->', from end: '<-'
1324
+ * @returns [[List]]
1325
+ * @example
1326
+ * ```ts
1327
+ * ```
1328
+ */
1329
+ declare type Drop<L extends List, N extends number, way extends Way = '->'> = L extends unknown ? N extends unknown ? _Drop<L, N, way> : never : never;
1330
+ //#endregion
1331
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Take.d.ts
1332
+ /**
1333
+ * starts in reverse from `N` till `N` = 0
1334
+ * @hidden
1335
+ */
1336
+ declare type TakeForth<L extends List, N extends Iteration, I$1 extends Iteration = Prev<N>, LN extends List = []> = {
1337
+ 0: TakeForth<L, N, Prev<I$1>, Prepend<LN, L[Pos<I$1>]>>;
1338
+ 1: LN;
1339
+ }[Extends<-1, Pos<I$1>>];
1340
+ /**
1341
+ * starts in reverse from the end till `N` = 0
1342
+ * @hidden
1343
+ */
1344
+ declare type TakeBack<L extends List, N extends Iteration> = {
1345
+ 0: TakeBack<Tail$1<L>, Prev<N>>;
1346
+ 1: L;
1347
+ }[Extends<0, Pos<N>>];
1348
+ /**
1349
+ * @hidden
1350
+ */
1351
+ declare type __Take<L extends List, N extends Iteration, way extends Way> = {
1352
+ '->': TakeForth<L, N>;
1353
+ '<-': TakeBack<L, N>;
1354
+ }[way];
1355
+ /**
1356
+ * @hidden
1357
+ */
1358
+ declare type _Take<L extends List, N extends number, way extends Way = '->'> = __Take<L, IterationOf<N>, way> extends infer X ? Cast<X, List> : never;
1359
+ /**
1360
+ * Extract `N` entries out of `L`
1361
+ * @param L to extract from
1362
+ * @param N to extract out
1363
+ * @param way (?=`'->'`) to extract from end
1364
+ * @returns [[List]]
1365
+ * @example
1366
+ * ```ts
1367
+ * ```
1368
+ */
1369
+ declare type Take<L extends List, N extends number, way extends Way = '->'> = L extends unknown ? N extends unknown ? _Take<L, N, way> : never : never;
1370
+ //#endregion
1371
+ //#region src/types/index.type.d.ts
1372
+ type AnyArray<A$1 = any> = readonly A$1[];
1373
+ type Range<Start extends number, End extends number> = Exclude<keyof TupleOf<End>, keyof TupleOf<Start>>;
1374
+ type TupleToEntries<A$1 extends readonly unknown[]> = If<IsAny<A$1>, unknown, { [Key in keyof A$1]: [Key, A$1[Key]] }>;
1375
+ type Groups<L extends AnyArray, LN extends AnyArray = [], D extends number[] = []> = D["length"] extends 40 ? LN : {
1376
+ 0: Groups<Drop<L, 1>, Append<LN, [`${LN["length"]}`, Take<L, 1>]>, [...D, 0]>;
1377
+ 1: LN;
1378
+ }[Extends<L, AnyArray<never>>];
1379
+ type TupleToGroups<L extends AnyArray> = Groups<L> extends infer X ? Cast<X, AnyArray> : never;
1380
+ type MatchFunction<T, R$1 = unknown> = (row: T, index: number) => R$1;
1381
+ //#endregion
1382
+ //#region src/utils/array/arrayCounting.d.ts
1383
+ /**
1384
+ * 统计数组的项目出现次数
1385
+ * - 通过给定的标识符匹配函数,返回一个对象,其中键是回调函数返回的 key 值,每个值是一个整数,表示该 key 出现的次数
1386
+ *
1387
+ * @param initialList 初始数组
1388
+ * @param match 匹配函数
1389
+ * @returns 统计对象
1390
+ * @example
1391
+ * ```ts
1392
+ * const list = ["a", "b", "a", "c"];
1393
+ * arrayCounting(list, (x) => x); // { a: 2, b: 1, c: 1 }
1394
+ *
1395
+ * const users = [{ id: 1, group: "A" }, { id: 2, group: "B" }, { id: 3, group: "A" }];
1396
+ * arrayCounting(users, (u) => u.group); // { A: 2, B: 1 }
1397
+ * ```
1398
+ */
1399
+ declare function arrayCounting<T, K$1 extends PropertyKey>(initialList: readonly T[], match: MatchFunction<T, K$1>): Record<string, number>;
1400
+ //#endregion
1401
+ //#region src/utils/array/arrayDifference.d.ts
1402
+ /**
1403
+ * 求数组差集
1404
+ * - 返回在 `initialList` 中存在,但在 `diffList` 中不存在的元素
1405
+ *
1406
+ * @param initialList 初始数组
1407
+ * @param diffList 对比数组
1408
+ * @param match 匹配函数
1409
+ * @returns 差集数组
1410
+ * @example
1411
+ * ```ts
1412
+ * arrayDifference([1, 2, 3], [2, 3, 4]); // [1]
1413
+ * arrayDifference([{ id: 1 }, { id: 2 }], [{ id: 2 }], (x) => x.id); // [{ id: 1 }]
1414
+ * ```
1415
+ */
1416
+ declare function arrayDifference<T>(initialList: readonly T[], diffList: readonly T[], match?: (row: T, index: number) => unknown): T[];
1417
+ //#endregion
1418
+ //#region src/utils/array/arrayFirst.d.ts
1419
+ /**
1420
+ * 获取数组第一项
1421
+ *
1422
+ * @param initialList 初始数组
1423
+ * @param saveValue 安全值
1424
+ * @returns 数组第一项,如果为空则返回安全值
1425
+ * @example
1426
+ * ```ts
1427
+ * arrayFirst([1, 2]); // 1
1428
+ * arrayFirst([], 0); // 0
1429
+ * ```
1430
+ */
1431
+ declare function arrayFirst<T>(initialList: readonly T[]): T | undefined;
1432
+ declare function arrayFirst<T>(initialList: readonly T[], saveValue: T): T;
1433
+ //#endregion
1434
+ //#region src/utils/array/arrayFork.d.ts
1435
+ /**
1436
+ * 数组分组过滤
1437
+ * - 给定一个数组和一个条件,返回一个由两个数组组成的元组,其中第一个数组包含所有满足条件的项,第二个数组包含所有不满足条件的项
1438
+ *
1439
+ * @param initialList 初始数组
1440
+ * @param match 条件匹配函数
1441
+ * @returns [满足条件的项[], 不满足条件的项[]]
1442
+ * @example
1443
+ * ```ts
1444
+ * arrayFork([1, 2, 3, 4], (n) => n % 2 === 0); // [[2, 4], [1, 3]]
1445
+ * ```
1446
+ */
1447
+ declare function arrayFork<T>(initialList: readonly T[], match: MatchFunction<T, boolean>): [T[], T[]];
1448
+ //#endregion
1449
+ //#region src/utils/array/arrayIntersection.d.ts
1450
+ /**
1451
+ * 求数组交集
1452
+ * - 返回在 `initialList` 和 `diffList` 中都存在的元素
1453
+ *
1454
+ * @param initialList 初始数组
1455
+ * @param diffList 对比数组
1456
+ * @param match 匹配函数
1457
+ * @returns 交集数组
1458
+ * @example
1459
+ * ```ts
1460
+ * arrayIntersection([1, 2], [2, 3]); // [2]
1461
+ * arrayIntersection([{ id: 1 }, { id: 2 }], [{ id: 2 }], (x) => x.id); // [{ id: 2 }]
1462
+ * ```
1463
+ */
1464
+ declare function arrayIntersection<T>(initialList: readonly T[], diffList: readonly T[]): T[];
1465
+ declare function arrayIntersection<T, D = T>(initialList: readonly T[], diffList: readonly D[], match: MatchFunction<T>): T[];
1466
+ //#endregion
1467
+ //#region src/utils/array/arrayLast.d.ts
1468
+ /**
1469
+ * 获取数组最后一项
1470
+ *
1471
+ * @param initialList 初始数组
1472
+ * @param saveValue 安全值
1473
+ * @returns 数组最后一项,如果为空则返回安全值
1474
+ * @example
1475
+ * ```ts
1476
+ * arrayLast([1, 2, 3]); // 3
1477
+ * arrayLast([], 0); // 0
1478
+ * ```
1479
+ */
1480
+ declare function arrayLast<T>(initialList: readonly T[]): T | undefined;
1481
+ declare function arrayLast<T>(initialList: readonly T[], saveValue: T): T;
1482
+ //#endregion
1483
+ //#region src/utils/array/arrayMerge.d.ts
1484
+ /**
1485
+ * 数组合并
1486
+ * - 如果未提供 `match` 函数,则合并两个数组并去重(Union)
1487
+ * - 如果提供了 `match` 函数,则仅更新 `initialList` 中匹配到的项(Left Join Update),不会追加 `mergeList` 中新增的项
1488
+ *
1489
+ * @param initialList 初始数组
1490
+ * @param mergeList 待合并数组
1491
+ * @param match 匹配函数
1492
+ * @returns 合并后的数组
1493
+ * @example
1494
+ * ```ts
1495
+ * // 基础合并去重
1496
+ * arrayMerge([1, 2], [2, 3]); // [1, 2, 3]
1497
+ * arrayMerge([], [1, 2, 3]); // [1, 2, 3]
1498
+ *
1499
+ * // 按条件更新
1500
+ * const source = [{ id: 1, val: "a" }, { id: 2, val: "b" }];
1501
+ * const update = [{ id: 2, val: "new" }, { id: 3, val: "c" }];
1502
+ * arrayMerge(source, update, (x) => x.id);
1503
+ * // [{ id: 1, val: "a" }, { id: 2, val: "new" }] -> id:3 被忽略
1504
+ * ```
1505
+ */
1506
+ declare function arrayMerge<T>(initialList: readonly T[], mergeList: readonly T[]): T[];
1507
+ declare function arrayMerge<T, D = T>(initialList: readonly T[], mergeList: readonly D[], match: MatchFunction<T>): T[];
1508
+ //#endregion
1509
+ //#region src/utils/array/arrayPick.d.ts
1510
+ /**
1511
+ * 数组选择
1512
+ * - 一次性应用 `filter` 和 `map` 操作
1513
+ *
1514
+ * @param initialList 初始数组
1515
+ * @param filter filter 函数
1516
+ * @param mapper map 函数
1517
+ * @returns 处理后的新数组
1518
+ * @example
1519
+ * ```ts
1520
+ * const list = [1, 2, 3, 4];
1521
+ * arrayPick(list, (n) => n % 2 === 0); // [2, 4]
1522
+ * arrayPick(list, (n) => n % 2 === 0, (n) => n * 2); // [4, 8]
1523
+ * ```
1524
+ */
1525
+ declare function arrayPick<const T>(initialList: readonly T[], filter: (row: T, index: number) => boolean): T[];
1526
+ declare function arrayPick<const T, K$1 = T>(initialList: readonly T[], filter: (row: T, index: number) => boolean, mapper: ((row: T, index: number) => K$1)): K$1[];
1527
+ //#endregion
1528
+ //#region src/utils/array/arrayReplace.d.ts
1529
+ /**
1530
+ * 数组项替换
1531
+ * - 在给定的数组中,替换符合匹配函数结果的项目
1532
+ * - 只替换第一个匹配项
1533
+ *
1534
+ * @param initialList 初始数组
1535
+ * @param newItem 替换项
1536
+ * @param match 匹配函数
1537
+ * @returns 替换后的新数组
1538
+ * @example
1539
+ * ```ts
1540
+ * arrayReplace([1, 2, 3], 4, (n) => n === 2); // [1, 4, 3]
1541
+ * ```
1542
+ */
1543
+ declare function arrayReplace<const T>(initialList: readonly T[], newItem: T, match: MatchFunction<T, boolean>): T[];
1544
+ declare function arrayReplace<const T, K$1 extends T>(initialList: readonly T[], newItem: K$1, match: MatchFunction<T, boolean>): T[];
1545
+ declare function arrayReplace<const T, K$1>(initialList: readonly T[], newItem: K$1, match: MatchFunction<T, boolean>): (T | K$1)[];
1546
+ //#endregion
1547
+ //#region src/utils/array/arrayReplaceMove.d.ts
1548
+ type PositionType = "start" | "end" | number;
1549
+ /**
1550
+ * 数组项替换并移动
1551
+ * - 在给定的数组中,替换并移动符合匹配函数结果的项目
1552
+ * - 只替换和移动第一个匹配项
1553
+ * - 未匹配时,根据 `position` 在指定位置插入 `newItem`
1554
+ *
1555
+ * @param initialList 初始数组
1556
+ * @param newItem 替换项
1557
+ * @param match 匹配函数
1558
+ * @param position 移动位置,可选 `start` | `end` | 索引位置, 默认为 `end`
1559
+ * @returns
1560
+ * @example
1561
+ * ```ts
1562
+ * arrayReplaceMove([1, 2, 3, 4], 5, (n) => n === 2, 0); // [5, 1, 3, 4]
1563
+ * arrayReplaceMove([1, 2, 3, 4], 5, (n) => n === 2, 2); // [1, 3, 5, 4]
1564
+ * arrayReplaceMove([1, 2, 3, 4], 5, (n) => n === 2, "start"); // [5, 1, 3, 4]
1565
+ * arrayReplaceMove([1, 2, 3, 4], 5, (n) => n === 2); // [1, 3, 4, 5]
1566
+ * ```
1567
+ */
1568
+ declare function arrayReplaceMove<const T>(initialList: readonly T[], newItem: T, match: MatchFunction<T, boolean>, position?: PositionType): T[];
1569
+ //#endregion
1570
+ //#region src/utils/array/arraySplit.d.ts
1571
+ /**
1572
+ * 数组切分
1573
+ * - 将数组以指定的长度切分后,组合在高维数组中
1574
+ *
1575
+ * @param initialList 初始数组
1576
+ * @param size 分割尺寸,默认 `10`
1577
+ * @returns 切分后的二维数组
1578
+ * @example
1579
+ * ```ts
1580
+ * arraySplit([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
1581
+ * ```
1582
+ */
1583
+ declare function arraySplit<T>(initialList: readonly T[], size?: number): T[][];
1584
+ //#endregion
1585
+ //#region src/utils/array/arrayZip.d.ts
1586
+ /**
1587
+ * 数组解压
1588
+ * - `arrayZip` 的反向操作
1589
+ *
1590
+ * @param arrays 压缩后的数组
1591
+ * @returns 解压后的二维数组
1592
+ * @example
1593
+ * ```ts
1594
+ * arrayUnzip([[1, "a"], [2, "b"]]); // [[1, 2], ["a", "b"]]
1595
+ * ```
1596
+ */
1597
+ declare function arrayUnzip<T>(arrays: readonly (readonly T[])[]): T[][];
1598
+ /**
1599
+ * 数组压缩
1600
+ * - 将多个数组的元素按索引组合成元组
1601
+ *
1602
+ * @param arrays 多个数组
1603
+ * @returns 压缩后的元组数组
1604
+ * @example
1605
+ * ```ts
1606
+ * arrayZip([1, 2], ["a", "b"]); // [[1, "a"], [2, "b"]]
1607
+ * ```
1608
+ */
1609
+ declare function arrayZip<T1, T2, T3, T4, T5>(array1: readonly T1[], array2: readonly T2[], array3: readonly T3[], array4: readonly T4[], array5: readonly T5[]): [T1, T2, T3, T4, T5][];
1610
+ declare function arrayZip<T1, T2, T3, T4>(array1: readonly T1[], array2: readonly T2[], array3: readonly T3[], array4: readonly T4[]): [T1, T2, T3, T4][];
1611
+ declare function arrayZip<T1, T2, T3>(array1: readonly T1[], array2: readonly T2[], array3: readonly T3[]): [T1, T2, T3][];
1612
+ declare function arrayZip<T1, T2>(array1: readonly T1[], array2: readonly T2[]): [T1, T2][];
1613
+ declare function arrayZip(): [];
1614
+ //#endregion
1615
+ //#region src/utils/array/arrayZipToObject.d.ts
1616
+ /**
1617
+ * 数组压缩为对象
1618
+ * - 将键数组和值(数组、函数或静态值)组合成对象
1619
+ *
1620
+ * @param keys 键数组
1621
+ * @param values 值数组、生成值的函数或静态值
1622
+ * @returns 生成的对象
1623
+ * @example
1624
+ * ```ts
1625
+ * arrayZipToObject(["a", "b"], [1, 2]); // { a: 1, b: 2 }
1626
+ * arrayZipToObject(["a", "b"], (k, i) => k + i); // { a: "a0", b: "b1" }
1627
+ * arrayZipToObject(["a", "b"], 1); // { a: 1, b: 1 }
1628
+ * ```
1629
+ */
1630
+ declare function arrayZipToObject<const K$1 extends PropertyKey, const V$1>(keys: readonly K$1[], array: readonly V$1[]): Record<K$1, V$1>;
1631
+ declare function arrayZipToObject<const K$1 extends PropertyKey, const V$1>(keys: readonly K$1[], match: MatchFunction<K$1, V$1>): Record<K$1, V$1>;
1632
+ declare function arrayZipToObject<const K$1 extends PropertyKey, const V$1>(keys: readonly K$1[], value: V$1): Record<K$1, V$1>;
1633
+ //#endregion
1634
+ //#region src/utils/device/isBrowser.d.ts
1635
+ declare function isBrowser(): boolean;
1636
+ declare function isWebWorker(): boolean;
1637
+ //#endregion
1638
+ //#region src/utils/device/isMobile.d.ts
1639
+ /**
1640
+ * 检测当前设备是否为移动设备
1641
+ *
1642
+ * @param maxWidth - 移动设备最大宽度(默认 768px)
1643
+ * @param dpi - 标准 DPI 基准(默认 160)
1644
+ * @returns 是否为移动设备
1645
+ * @example
1646
+ * ```ts
1647
+ * // 假设 window.innerWidth = 500
1648
+ * isMobile(); // true
1649
+ * ```
1650
+ */
1651
+ declare function isMobile(maxWidth?: number, dpi?: number): boolean;
1652
+ /**
1653
+ * 检测当前设备是否为IOS移动设备
1654
+ *
1655
+ * @param maxWidth - 移动设备最大宽度(默认 768px)
1656
+ * @param dpi - 标准 DPI 基准(默认 160)
1657
+ * @returns 是否为 iOS 移动设备 (iPhone/iPad/iPod 且非平板)
1658
+ * @example
1659
+ * ```ts
1660
+ * // UA contains iPhone
1661
+ * isIOSMobile(); // true
1662
+ * ```
1663
+ */
1664
+ declare function isIOSMobile(maxWidth?: number, dpi?: number): boolean;
1665
+ //#endregion
1666
+ //#region src/utils/device/isTablet.d.ts
1667
+ /**
1668
+ * 检测当前设备是否为平板
1669
+ *
1670
+ * @param minWidth - 平板最小宽度(默认 768px)
1671
+ * @param maxWidth - 平板最大宽度(默认 1200px)
1672
+ * @param dpi - 标准 DPI 基准(默认 160)
1673
+ * @returns 是否为平板设备
1674
+ * @example
1675
+ * ```ts
1676
+ * // 假设 window.innerWidth = 1000
1677
+ * isTablet(); // true
1678
+ * ```
1679
+ */
1680
+ declare function isTablet(minWidth?: number, maxWidth?: number, dpi?: number): boolean;
1681
+ //#endregion
1682
+ //#region src/utils/function/to.d.ts
1683
+ /**
1684
+ *将 Promise 转换为 `[err, result]` 格式,方便 async/await 错误处理
1685
+ *
1686
+ * @param promise 待处理的 Promise
1687
+ * @param errorExt 附加到 error 对象的扩展信息(注意:如果原 error 是 Error 实例,扩展属性可能会覆盖或无法正确合并非枚举属性)
1688
+ * @returns `[err, null]` 或 `[null, data]`
1689
+ * @example
1690
+ * ```ts
1691
+ * const [err, data] = await to(someAsyncFunc());
1692
+ * if (err) return;
1693
+ * console.log(data);
1694
+ * ```
1695
+ */
1696
+ declare function to<T, U$1 = Error>(promise: Readonly<Promise<T>>, errorExt?: PlainObject): Promise<[U$1, undefined] | [null, T]>;
1697
+ //#endregion
1698
+ //#region src/utils/math/mathToBignumber.d.ts
1699
+ /**
1700
+ * 将任意类型的值转换为 `math.bignumber`
1701
+ *
1702
+ * @param mathJsInstance mathJs 实例
1703
+ * @param value 任意类型的值
1704
+ * @param saveValue 安全值
1705
+ * @returns 转换后的 BigNumber
1706
+ * @example
1707
+ * ```ts
1708
+ * import { create, all } from "mathjs";
1709
+ * const math = create(all);
1710
+ * mathToBignumber(math, "0.1");
1711
+ * ```
1712
+ */
1713
+ declare function mathToBignumber(mathJsInstance: MathJsInstance, value: unknown, saveValue?: BigNumber | undefined): BigNumber;
1714
+ //#endregion
1715
+ //#region src/utils/math/mathToDecimal.d.ts
1716
+ /**
1717
+ * 将任意类型的值转换为十进制数字字符串
1718
+ *
1719
+ * @param mathJsInstance mathJs 实例
1720
+ * @param value 任意类型的值
1721
+ * @param precision 精度
1722
+ * @param isFormat 是否格式化为字符串
1723
+ * @returns 格式化后的字符串或 BigNumber
1724
+ * @example
1725
+ * ```ts
1726
+ * mathToDecimal(math, 0.12345, 2); // "0.12"
1727
+ * ```
1728
+ */
1729
+ declare function mathToDecimal(mathJsInstance: MathJsInstance, value: unknown, precision?: number | undefined, isFormat?: true): string;
1730
+ declare function mathToDecimal(mathJsInstance: MathJsInstance, value: unknown, precision?: number | undefined, isFormat?: false): BigNumber;
1731
+ //#endregion
1732
+ //#region src/utils/math/mathToEvaluate.d.ts
1733
+ /**
1734
+ * 数学表达式求值
1735
+ *
1736
+ * @param mathJsInstance mathJs 实例
1737
+ * @param expr 表达式
1738
+ * @param scope 键值映射
1739
+ * @returns 计算结果的字符串表示
1740
+ * @example
1741
+ * ```ts
1742
+ * mathToEvaluate(math, "a + b", { a: 1, b: 2 }); // "3"
1743
+ * ```
1744
+ */
1745
+ declare function mathToEvaluate(mathJsInstance: MathJsInstance, expr: MathExpression | Matrix, scope?: Record<string, BigNumber>): string;
1746
+ //#endregion
1747
+ //#region src/utils/number/numberWithin.d.ts
1748
+ /**
1749
+ * 数字区间检查函数
1750
+ *
1751
+ * @param input 待检查数字
1752
+ * @param interval 由两个数字组成的元组 [left, right]
1753
+ * @param includeLeft 是否包含左边界(默认 true)
1754
+ * @param includeRight 是否包含右边界(默认 false)
1755
+ * @returns 是否在区间内
1756
+ * @example
1757
+ * ```ts
1758
+ * numberWithin(5, [1, 10]); // true
1759
+ * numberWithin(1, [1, 10], false); // false
1760
+ * ```
1761
+ */
1762
+ declare function numberWithin(input: number, interval: [number, number], includeLeft?: boolean, includeRight?: boolean): boolean;
1763
+ //#endregion
1764
+ //#region src/utils/object/enumEntries.d.ts
1765
+ /**
1766
+ * 获取所有枚举成员的键/值数组
1767
+ *
1768
+ * @param enumeration 枚举对象
1769
+ * @returns 键值对数组
1770
+ * @example
1771
+ * ```ts
1772
+ * enum A { k = "v" }
1773
+ * enumEntries(A); // [["k", "v"]]
1774
+ * ```
1775
+ */
1776
+ declare function enumEntries<E extends PlainObject>(enumeration: E): [keyof E, E[keyof E]][];
1777
+ declare function enumEntries<E extends AnyObject>(enumeration: E): [keyof E, E[keyof E]][];
1778
+ //#endregion
1779
+ //#region src/utils/object/enumKeys.d.ts
1780
+ /**
1781
+ * 获取所有枚举成员的键
1782
+ *
1783
+ * @param enumeration 枚举对象
1784
+ * @returns 键数组
1785
+ * @example
1786
+ * ```ts
1787
+ * enum A { k = "v" }
1788
+ * enumKeys(A); // ["k"]
1789
+ * ```
1790
+ */
1791
+ declare function enumKeys<E extends PlainObject>(enumeration: E): (keyof E)[];
1792
+ declare function enumKeys<E extends AnyObject>(enumeration: E): (keyof E)[];
1793
+ //#endregion
1794
+ //#region src/utils/object/enumValues.d.ts
1795
+ /**
1796
+ * 获取所有枚举成员的值
1797
+ *
1798
+ * @param enumeration 枚举对象
1799
+ * @returns 值数组
1800
+ * @example
1801
+ * ```ts
1802
+ * enum A { k = "v" }
1803
+ * enumValues(A); // ["v"]
1804
+ * ```
1383
1805
  */
1384
- declare function enumKeys<E extends AnyObject>(enumeration: NonEmptyObject<E>): [keyof E, ...(keyof E)[]];
1385
- //#endregion
1386
- //#region src/utils/object/enumTypeCheck.d.ts
1387
- declare function enumTypeCheck<E extends AnyObject>(enumeration: E): E & Record<PropertyKey, unknown>;
1806
+ declare function enumValues<E extends PlainObject>(enumeration: E): UnionToTuple<ValueOf<E>>;
1807
+ declare function enumValues<E extends AnyObject>(enumeration: E): UnionToTuple<ValueOf<E>>;
1388
1808
  //#endregion
1389
- //#region src/utils/object/enumValues.d.ts
1809
+ //#region src/utils/object/objectMapEntries.d.ts
1390
1810
  /**
1391
- * 获取枚举所有属性的值
1811
+ * 映射对象条目
1812
+ * - 将对象的键值对映射为新的键值对
1392
1813
  *
1393
- * @param enumeration 枚举
1814
+ * @param plainObject 对象
1815
+ * @param toEntry 映射函数
1816
+ * @returns 映射后的新对象
1817
+ * @example
1818
+ * ```ts
1819
+ * const obj = { a: 1, b: 2 };
1820
+ * objectMapEntries(obj, (k, v) => [k, v * 2]); // { a: 2, b: 4 }
1821
+ * ```
1394
1822
  */
1395
- declare function enumValues<E extends AnyObject>(enumeration: NonEmptyObject<E>): UnionToTuple<ValueOf<E>>;
1823
+ declare function objectMapEntries<O extends PlainObject, NK extends PropertyKey, NV>(plainObject: O, toEntry: (key: keyof O, value: O[keyof O]) => [NK, NV]): PlainObject<NK, NV>;
1396
1824
  //#endregion
1397
- //#region src/utils/object/mapEntries.d.ts
1398
- declare function mapEntries<K$1 extends PropertyKey, V, NK extends PropertyKey, NV>(obj: PlainObject<K$1, V>, toEntry: (key: K$1, value: V) => [NK, NV]): PlainObject<NK, NV>;
1399
- //#endregion
1400
- //#region node_modules/.pnpm/radashi@12.7.1/node_modules/radashi/dist/radashi.d.cts
1401
-
1825
+ //#region node_modules/.pnpm/radashi@12.7.2/node_modules/radashi/dist/radashi.d.cts
1402
1826
  interface BigInt {
1403
1827
  /**
1404
1828
  * Returns a string representation of an object.
@@ -2076,54 +2500,144 @@ TOverride | (IsOptional extends true ? TInitial : never) : Extract<TOverride, ob
2076
2500
  /**
2077
2501
  * 递归地将第二个对象合并到第一个对象的副本中
2078
2502
  * - 只有普通对象才会递归合并
2503
+ * - 会处理循环引用,避免无限递归
2079
2504
  *
2080
2505
  * @param initial 初始对象
2081
2506
  * @param override 待合并对象
2507
+ * @returns 合并后的新对象
2508
+ * @example
2509
+ * ```ts
2510
+ * const initial = { a: 1, b: { c: 2 } };
2511
+ * const override = { b: { d: 3 } };
2512
+ * objectAssign(initial, override); // { a: 1, b: { c: 2, d: 3 } }
2513
+ * ```
2082
2514
  */
2083
2515
  declare function objectAssign<I$1 extends PlainObject, O extends PlainObject>(initial: I$1, override: O): Assign<I$1, O>;
2516
+ declare function objectAssign<I$1 extends AnyObject, O extends AnyObject>(initial: I$1, override: O): Assign<I$1, O>;
2084
2517
  //#endregion
2085
2518
  //#region src/utils/object/objectCrush.d.ts
2086
2519
  type Crush<T> = T extends readonly (infer U)[] ? Record<string, U extends object ? unknown : U> : Simplify<UnionToIntersection<keyof T extends infer Prop ? Prop extends keyof T ? T[Prop] extends infer Value ? ([Extract<Value, object>] extends [never] ? never : Record<string, unknown>) | ([Exclude<Value, object>] extends [never] ? never : [Extract<Value, object>] extends [never] ? { [P in Prop]: Value } : Record<string, unknown>) : never : never : never>>;
2087
- declare function objectCrush<T extends PlainObject>(value: T): Crush<T>;
2520
+ /**
2521
+ * 压平对象
2522
+ * - 将多层级的对象转换为单层级的对象,键名使用点号连接
2523
+ *
2524
+ * @param plainObject 平面对象
2525
+ * @returns 压平后的对象
2526
+ * @example
2527
+ * ```ts
2528
+ * const obj = { a: { b: 1 } };
2529
+ * objectCrush(obj); // { "a.b": 1 }
2530
+ * ```
2531
+ */
2532
+ declare function objectCrush<T extends PlainObject>(plainObject: T): Crush<T>;
2533
+ declare function objectCrush<T extends AnyObject>(anyObject: T): Crush<T>;
2088
2534
  //#endregion
2089
2535
  //#region src/utils/object/objectEntries.d.ts
2090
2536
  /**
2091
2537
  * 返回对象的可枚举属性的键/值数组
2092
2538
  *
2539
+ * @param value 对象
2540
+ * @returns 键值对数组
2541
+ * @example
2542
+ * ```ts
2543
+ * objectEntries({ a: 1 }); // [["a", 1]]
2544
+ * ```
2545
+ */
2546
+ declare function objectEntries<const S extends string>(string: S): TupleToEntries<Split<S, "">>;
2547
+ declare function objectEntries<const A$1 extends readonly unknown[]>(array: A$1): TupleToGroups<A$1>;
2548
+ declare function objectEntries<const O extends PlainObject>(plainObject: O): [`${keyof Except<O, symbol>}`, O[keyof Except<O, symbol>]][];
2549
+ declare function objectEntries<const O extends AnyObject>(anyObject: O): [`${keyof Except<O, symbol>}`, O[keyof Except<O, symbol>]][];
2550
+ //#endregion
2551
+ //#region src/utils/object/objectInvert.d.ts
2552
+ type IntersectOf<U$1> = (U$1 extends unknown ? (k: U$1) => void : never) extends ((k: infer I) => void) ? I : never;
2553
+ type ComputeRaw<A$1> = A$1 extends AnyFunction ? A$1 : { [K in keyof A$1]: A$1[K] } & unknown;
2554
+ type _Invert<O extends Record<PropertyKey, PropertyKey>> = ComputeRaw<IntersectOf<{ [K in keyof O]: Record<O[K], K> }[keyof O]>>;
2555
+ type Invert<O extends Record<keyof O, PropertyKey>> = O extends unknown ? _Invert<O> : never;
2556
+ /**
2557
+ * 尽可能地交换对象的键和值
2558
+ *
2093
2559
  * @param obj 对象
2560
+ * @returns 键值互换后的对象
2561
+ * @example
2562
+ * ```ts
2563
+ * const obj = { a: "1", b: 2 };
2564
+ * objectInvert(obj); // { "1": "a", 2: "b" }
2565
+ * ```
2094
2566
  */
2095
- declare function objectEntries<O extends AnyObject>(obj: O): [string & keyof O, O[keyof O]][];
2567
+ declare function objectInvert<const O extends Record<keyof O, PropertyKey>>(plainObject: O): Invert<O>;
2568
+ declare function objectInvert<const O extends AnyObject>(anyObject: O): Invert<O>;
2096
2569
  //#endregion
2097
2570
  //#region src/utils/object/objectKeys.d.ts
2098
2571
  /**
2099
- * 返回对象的可枚举属性和方法的名称
2572
+ * 返回对象可枚举属性和方法的名称
2100
2573
  * - `Object.keys` 始终返回 `string[]` 类型,此函数可以返回具体类型
2101
2574
  *
2102
- * @param obj 对象
2575
+ * @param value 对象
2576
+ * @returns 键数组
2577
+ * @example
2578
+ * ```ts
2579
+ * objectKeys({ a: 1, b: 2 }); // ["a", "b"]
2580
+ * ```
2103
2581
  */
2104
- declare function objectKeys<O extends AnyObject>(obj: O): (keyof O)[];
2582
+ declare function objectKeys<const S extends string>(string: S): UnionToTuple<Range<0, Split<S, "">["length"]>>;
2583
+ declare function objectKeys<const A$1 extends ArrayLike<unknown>>(array: A$1): UnionToTuple<Range<0, A$1["length"]>>;
2584
+ declare function objectKeys<O extends PlainObject>(plainObject: O): `${Extract<keyof O, string | number>}`[];
2585
+ declare function objectKeys<O extends AnyObject>(anyObject: O): `${Extract<keyof O, string | number>}`[];
2105
2586
  //#endregion
2106
- //#region src/utils/object/objectPick.d.ts
2107
- declare function objectPick<O extends AnyObject, K$1 extends keyof O>(obj: O, keys: readonly K$1[]): Pick<O, K$1>;
2587
+ //#region src/utils/object/objectOmit.d.ts
2588
+ /**
2589
+ * 排除对象的指定属性
2590
+ *
2591
+ * @param plainObject 对象
2592
+ * @param keys 要排除的属性键数组
2593
+ * @returns 排除指定属性后的新对象
2594
+ * @example
2595
+ * ```ts
2596
+ * objectOmit({ a: 1, b: 2 }, ["a"]); // { b: 2 }
2597
+ * ```
2598
+ */
2599
+ declare function objectOmit<O extends PlainObject, K$1 extends keyof O>(plainObject: O, keys: readonly K$1[]): Omit<O, K$1>;
2600
+ declare function objectOmit<O extends AnyObject, K$1 extends keyof O>(anyObject: O, keys: readonly K$1[]): Omit<O, K$1>;
2108
2601
  //#endregion
2109
- //#region src/utils/object/objectSwitch.d.ts
2602
+ //#region src/utils/object/objectPick.d.ts
2110
2603
  /**
2111
- * 对象反转
2112
- * - 返回交换了对象的可枚举属性的值/键对象
2604
+ * 选取对象的指定属性
2113
2605
  *
2114
- * @param obj 对象
2606
+ * @param plainObject 对象
2607
+ * @param keys 要选取的属性键数组
2608
+ * @returns 包含指定属性的新对象
2609
+ * @example
2610
+ * ```ts
2611
+ * objectPick({ a: 1, b: 2 }, ["a"]); // { a: 1 }
2612
+ * ```
2115
2613
  */
2116
- declare function objectSwitch<O extends AnyObject>(obj: NonEmptyObject<O>): Record<O[keyof O], keyof O>;
2614
+ declare function objectPick<O extends PlainObject, K$1 extends keyof O>(plainObject: O, keys: readonly K$1[]): Pick<O, K$1>;
2615
+ declare function objectPick<O extends AnyObject, K$1 extends keyof O>(anyObject: O, keys: readonly K$1[]): Pick<O, K$1>;
2117
2616
  //#endregion
2118
2617
  //#region src/utils/object/objectValues.d.ts
2119
2618
  /**
2120
- * 返回对象的可枚举属性的值数组
2619
+ * 返回对象可枚举属性的值的数组
2121
2620
  *
2122
- * @param obj 对象
2621
+ * @param value 对象
2622
+ * @returns 值数组
2623
+ * @example
2624
+ * ```ts
2625
+ * objectValues({ a: 1, b: 2 }); // [1, 2]
2626
+ * ```
2123
2627
  */
2124
- declare function objectValues<O extends AnyObject>(obj: O): UnionToTuple<ValueOf<O>>;
2628
+ declare function objectValues<S extends string>(string: S): Split<S, "">;
2629
+ declare function objectValues<A$1 extends ArrayLike<unknown>>(array: A$1): A$1;
2630
+ declare function objectValues<O extends PlainObject>(plainObject: O): O[keyof O][];
2631
+ declare function objectValues<O extends AnyObject>(anyObject: O): O[keyof O][];
2125
2632
  //#endregion
2126
2633
  //#region src/utils/string/stringInitialCase.d.ts
2634
+ /**
2635
+ * 字符串首字母大小写
2636
+ * - 包含非西欧字母字符时,不处理
2637
+ * - 纯字母且全大写时,不处理
2638
+ * - 纯字母且非全大写时,首字母小写,其余保留
2639
+ * - 纯字母且非全大写时,首字母大写,其余保留
2640
+ *
2127
2641
  /**
2128
2642
  * 字符串首字母大小写
2129
2643
  * - 包含非西欧字母字符时,不处理
@@ -2133,10 +2647,20 @@ declare function objectValues<O extends AnyObject>(obj: O): UnionToTuple<ValueOf
2133
2647
  *
2134
2648
  * @param input 待处理字符串
2135
2649
  * @param caseType 大小写类型
2650
+ * @returns 处理后的字符串
2651
+ * @example
2652
+ * ```ts
2653
+ * stringInitialCase("Hello", "lower"); // "hello"
2654
+ * stringInitialCase("hello", "upper"); // "Hello"
2655
+ * ```
2136
2656
  */
2137
2657
  declare function stringInitialCase(input: string, caseType?: "lower" | "upper" | undefined): string;
2138
2658
  //#endregion
2139
2659
  //#region src/utils/string/stringReplace.d.ts
2660
+ /**
2661
+ * 字符串替换
2662
+ * - 替换第一个匹配项
2663
+ *
2140
2664
  /**
2141
2665
  * 字符串替换
2142
2666
  * - 替换第一个匹配项
@@ -2144,52 +2668,106 @@ declare function stringInitialCase(input: string, caseType?: "lower" | "upper" |
2144
2668
  * @param input 待处理字符串
2145
2669
  * @param search 匹配项
2146
2670
  * @param replacement 替换项
2671
+ * @returns 替换后的字符串
2672
+ * @example
2673
+ * ```ts
2674
+ * stringReplace("hello world", "world", "context"); // "hello context"
2675
+ * ```
2147
2676
  */
2148
2677
  declare function stringReplace<I$1 extends string, S extends string, R$1 extends string>(input: I$1, search: S, replacement: R$1): Replace<I$1, S, R$1>;
2149
2678
  //#endregion
2150
2679
  //#region src/utils/string/stringTemplate.d.ts
2151
2680
  /**
2152
2681
  * 字符串模板替换
2682
+ * - 使用对象的属性值替换字符串中的 {{key}} 模板
2153
2683
  *
2154
2684
  * @param input 待处理字符串
2155
2685
  * @param template 模板对象
2156
- * @param regex 模板匹配正则
2686
+ * @param regex 模板匹配正则 (默认: `\{\{(.+?)\}\}`)
2687
+ * @returns 替换后的字符串
2688
+ * @example
2689
+ * ```ts
2690
+ * stringTemplate("Hello {{name}}", { name: "World" }); // "Hello World"
2691
+ * ```
2157
2692
  */
2158
2693
  declare function stringTemplate(input: string, template: PlainObject, regex?: RegExp): string;
2159
2694
  //#endregion
2160
2695
  //#region src/utils/string/stringToJson.d.ts
2696
+ /**
2697
+ * 处理 JSON 字符串
2698
+ *
2161
2699
  /**
2162
2700
  * 处理 JSON 字符串
2163
2701
  *
2164
2702
  * @param input 待处理字符串
2165
- * @param safeValue 安全值
2703
+ * @param safeValue 安全值 (当解析失败或输入无效时返回)
2704
+ * @returns 解析后的对象 或 安全值
2705
+ * @example
2706
+ * ```ts
2707
+ * stringToJson('{"a": 1}', {}); // { a: 1 }
2708
+ * stringToJson('invalid', {}); // {}
2709
+ * ```
2166
2710
  */
2167
- declare function stringToJson<R$1 extends AnyObject = AnyObject, D extends R$1 = R$1>(input: string | null | undefined, safeValue: D): R$1;
2711
+ declare function stringToJson<D extends AnyObject = AnyObject>(input: string | null | undefined, safeValue: D): D;
2168
2712
  //#endregion
2169
2713
  //#region src/utils/string/stringToNumber.d.ts
2170
2714
  /**
2171
2715
  * 从字符串中提取数字字符串
2716
+ * - 移除非数字字符,保留符号和小数点
2172
2717
  *
2173
2718
  * @param input 待处理字符串
2719
+ * @returns 提取出的数字字符串
2720
+ * @example
2721
+ * ```ts
2722
+ * stringToNumber("$1,234.56"); // "1234.56"
2723
+ * stringToNumber("abc-123"); // "-123"
2724
+ * ```
2174
2725
  */
2175
2726
  declare function stringToNumber(input: string): string;
2176
2727
  //#endregion
2177
2728
  //#region src/utils/string/stringToPosix.d.ts
2178
2729
  /**
2179
2730
  * 将路径转换为 POSIX 风格
2731
+ * - 统一使用正斜杠 (/)
2732
+ * - 可选移除 Windows 盘符 (如 C:)
2733
+ * - 可选移除开头的斜杠
2734
+ * - 规范化连续斜杠为单个斜杠
2180
2735
  *
2181
2736
  * @param input 待处理字符串
2182
- * @param removeLeadingSlash 是否移除开头斜杠,默认为 `false`
2737
+ * @param removeLeadingSlash 是否移除开头斜杠,默认为 `false`。如果移除了盘符,路径通常会以 / 开头,此参数可控制是否保留该 /
2738
+ * @returns 转换后的路径,如果输入无效则返回空字符串
2739
+ *
2740
+ * @example
2741
+ * ```ts
2742
+ * stringToPosix("C:\\Windows\\System32");
2743
+ * // 默认: "/Windows/System32" (移除了 C: 并标准化)
2744
+ *
2745
+ * stringToPosix("C:\\Windows\\System32", true);
2746
+ * // 移除开头斜杠: "Windows/System32"
2747
+ *
2748
+ * stringToPosix("\\\\server\\share\\file.txt");
2749
+ * // UNC 路径: "/server/share/file.txt"
2750
+ *
2751
+ * stringToPosix("folder\\subfolder\\file.txt");
2752
+ * // 相对路径: "folder/subfolder/file.txt"
2753
+ * ```
2183
2754
  */
2184
2755
  declare function stringToPosix(input: string | null | undefined, removeLeadingSlash?: boolean): string;
2185
2756
  //#endregion
2186
2757
  //#region src/utils/string/stringToValues.d.ts
2187
2758
  /**
2188
2759
  * 字符串分割为数组
2760
+ * - 按指定分隔符分割字符串,并转换类型
2189
2761
  *
2190
2762
  * @param input 待处理字符串
2191
- * @param valueType 数组中每一项的类型
2763
+ * @param valueType 数组中每一项的类型,默认为 "number"
2192
2764
  * @param splitSymbol 分隔符,默认为 `,`
2765
+ * @returns 分割后的数组
2766
+ * @example
2767
+ * ```ts
2768
+ * stringToValues("1,2,3"); // [1, 2, 3]
2769
+ * stringToValues("a-b-c", "string", "-"); // ["a", "b", "c"]
2770
+ * ```
2193
2771
  */
2194
2772
  declare function stringToValues(input: string | null | undefined, valueType?: "number" | undefined, splitSymbol?: string | undefined): number[];
2195
2773
  declare function stringToValues(input: string | null | undefined, valueType: "string", splitSymbol?: string | undefined): string[];
@@ -2200,20 +2778,46 @@ declare function stringToValues(input: string | null | undefined, valueType: "st
2200
2778
  *
2201
2779
  * @param input 待处理字符串
2202
2780
  * @param charsToTrim 裁切字符,默认为 `" "`
2781
+ * @returns 裁切后的字符串
2782
+ * @example
2783
+ * ```ts
2784
+ * stringTrim(" hello "); // "hello"
2785
+ * stringTrim("__hello__", "_"); // "hello"
2786
+ * ```
2203
2787
  */
2204
2788
  declare function stringTrim(input: string | null | undefined, charsToTrim?: string): string;
2205
2789
  //#endregion
2206
2790
  //#region src/utils/string/stringTruncate.d.ts
2207
2791
  /**
2208
2792
  * 截取字符串
2209
- * - 支持中英文混排,不会在汉字中间截断
2793
+ * - 支持自定义省略符,不会截断在汉字中间(因为JS字符串本身按字符处理)
2210
2794
  *
2211
2795
  * @param input 待处理字符串
2212
- * @param maxLength 最大长度
2796
+ * @param maxLength 最大长度 (包含省略符)
2213
2797
  * @param ellipsis 省略符,默认为 `...`
2798
+ * @returns 截取后的字符串
2799
+ * @example
2800
+ * ```ts
2801
+ * stringTruncate("hello world", 8); // "hello..."
2802
+ * ```
2214
2803
  */
2215
2804
  declare function stringTruncate(input: string, maxLength: number, ellipsis?: string): string;
2216
2805
  //#endregion
2806
+ //#region src/utils/time/timeZone.d.ts
2807
+ /**
2808
+ * 获取当前时区信息
2809
+ *
2810
+ * @returns 时区信息对象 (UTC偏移和时区名称)
2811
+ * @example
2812
+ * ```ts
2813
+ * getTimeZone(); // { UTC: "UTC+8", timeZone: "Asia/Shanghai" }
2814
+ * ```
2815
+ */
2816
+ declare function getTimeZone(): {
2817
+ UTC: string;
2818
+ timeZone: string;
2819
+ };
2820
+ //#endregion
2217
2821
  //#region src/utils/tree/types.d.ts
2218
2822
  type RowKey = "id";
2219
2823
  type ParentIdKey = "parentId";
@@ -2232,6 +2836,22 @@ interface BaseOptions<T, CK extends string> {
2232
2836
  //#region src/utils/tree/treeFilter.d.ts
2233
2837
  type TreeFilterOptions<T extends AnyObject, CK extends string = ChildrenKey> = BaseOptions<T, CK>;
2234
2838
  type TreeFilterCallback<T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => boolean;
2839
+ /**
2840
+ * 过滤树节点
2841
+ * - 返回新的树结构,包含所有回调返回 true 的节点
2842
+ * - 如果父节点被过滤,则其子节点也会被过滤 (pre 策略下)
2843
+ *
2844
+ * @param tree 树结构数据
2845
+ * @param callback 回调函数
2846
+ * @param options 配置项 (childrenKey, strategy等)
2847
+ * @returns 过滤后的树结构数组
2848
+ * @example
2849
+ * ```ts
2850
+ * const tree = [{ id: 1, visible: true, children: [{ id: 2, visible: false }] }];
2851
+ * treeFilter(tree, (node) => node.visible);
2852
+ * // [{ id: 1, visible: true, children: [] }]
2853
+ * ```
2854
+ */
2235
2855
  declare function treeFilter<T extends AnyObject, CK extends string = ChildrenKey>(tree: T[], callback: TreeFilterCallback<T>, options?: TreeFilterOptions<T, CK>): T[];
2236
2856
  declare function treeFilter<T extends AnyObject, CK extends string = ChildrenKey>(tree: T, callback: TreeFilterCallback<T>, options?: TreeFilterOptions<T, CK>): T;
2237
2857
  //#endregion
@@ -2239,18 +2859,58 @@ declare function treeFilter<T extends AnyObject, CK extends string = ChildrenKey
2239
2859
  type TreeFindOptions<T extends AnyObject, CK extends string = ChildrenKey> = BaseOptions<T, CK>;
2240
2860
  type TreeFindCallback<T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => boolean;
2241
2861
  /**
2242
- * 查找树节点,找到第一个返回非空值的节点
2862
+ * 查找树节点
2863
+ * - 返回第一个回调返回 true 的节点
2864
+ *
2865
+ * @param tree 树结构数据
2866
+ * @param callback 回调函数
2867
+ * @param options 配置项
2868
+ * @returns 找到的节点,未找到则返回 undefined
2869
+ * @example
2870
+ * ```ts
2871
+ * const tree = [{ id: 1, children: [{ id: 2 }] }];
2872
+ * treeFind(tree, (node) => node.id === 2); // { id: 2, ... }
2873
+ * ```
2243
2874
  */
2244
2875
  declare function treeFind<T extends AnyObject, CK extends string = ChildrenKey>(tree: T | T[], callback: TreeFindCallback<T>, options?: TreeFindOptions<T, CK>): T | undefined;
2245
2876
  //#endregion
2246
2877
  //#region src/utils/tree/treeForEach.d.ts
2247
2878
  type TreeForeachOptions<T extends AnyObject, CK extends string = ChildrenKey> = BaseOptions<T, CK>;
2248
2879
  type TreeForeachCallback<T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => void;
2880
+ /**
2881
+ * 遍历树节点
2882
+ *
2883
+ * @param tree 树结构数据
2884
+ * @param callback 回调函数
2885
+ * @param options 配置项
2886
+ * @example
2887
+ * ```ts
2888
+ * const tree = [{ id: 1, children: [{ id: 2 }] }];
2889
+ * const ids: number[] = [];
2890
+ * treeForEach(tree, (node) => ids.push(node.id));
2891
+ * // ids: [1, 2] (pre-order default)
2892
+ * ```
2893
+ */
2249
2894
  declare function treeForEach<T extends AnyObject, CK extends string = ChildrenKey>(tree: T | T[], callback: TreeForeachCallback<T>, options?: TreeForeachOptions<T, CK>): void;
2250
2895
  //#endregion
2251
2896
  //#region src/utils/tree/treeMap.d.ts
2252
2897
  type TreeMapOptions<T extends AnyObject, CK extends string> = BaseOptions<T, CK>;
2253
2898
  type TreeMapCallback<R$1 extends AnyObject, T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => R$1;
2899
+ /**
2900
+ * 映射树节点
2901
+ * - 返回新的树结构,保持层级关系
2902
+ *
2903
+ * @param tree 树结构数据
2904
+ * @param callback 回调函数 (返回映射后的节点内容)
2905
+ * @param options 配置项
2906
+ * @returns 映射后的树结构数组
2907
+ * @example
2908
+ * ```ts
2909
+ * const tree = [{ id: 1, val: 10, children: [{ id: 2, val: 20 }] }];
2910
+ * treeMap(tree, (node) => ({ ...node, val: node.val * 2 }));
2911
+ * // [{ id: 1, val: 20, children: [{ id: 2, val: 40 }] }]
2912
+ * ```
2913
+ */
2254
2914
  declare function treeMap<R$1 extends AnyObject, T extends AnyObject, CK extends string = ChildrenKey>(tree: T[], callback: TreeMapCallback<R$1, T>, options?: TreeMapOptions<T, CK>): TreeLike<R$1, CK>[];
2255
2915
  declare function treeMap<R$1 extends AnyObject, T extends AnyObject, CK extends string = ChildrenKey>(tree: T, callback: TreeMapCallback<R$1, T>, options?: TreeMapOptions<T, CK>): TreeLike<R$1, CK>;
2256
2916
  //#endregion
@@ -2262,6 +2922,20 @@ interface RowsToTreeOptions<RK extends string = RowKey, PK extends string = Pare
2262
2922
  }
2263
2923
  /**
2264
2924
  * 行结构 转 树结构
2925
+ * - 将平铺的数组转换为树形结构
2926
+ *
2927
+ * @param rows 行数据数组
2928
+ * @param options 配置项
2929
+ * @returns 树结构数组
2930
+ * @example
2931
+ * ```ts
2932
+ * const rows = [
2933
+ * { id: 1, parentId: null },
2934
+ * { id: 2, parentId: 1 },
2935
+ * ];
2936
+ * rowsToTree(rows);
2937
+ * // [{ id: 1, parentId: null, children: [{ id: 2, parentId: 1 }] }]
2938
+ * ```
2265
2939
  */
2266
2940
  declare function rowsToTree<T extends AnyObject = AnyObject, CK extends string = ChildrenKey, R$1 = TreeLike<T, CK>, RK extends string = RowKey, PK extends string = ParentIdKey>(rows: T[], options?: RowsToTreeOptions<RK, PK, CK> | undefined): R$1[];
2267
2941
  //#endregion
@@ -2269,68 +2943,224 @@ declare function rowsToTree<T extends AnyObject = AnyObject, CK extends string =
2269
2943
  type TreeToRowsOptions<T extends AnyObject, CK extends string = ChildrenKey> = TreeForeachOptions<T, CK>;
2270
2944
  /**
2271
2945
  * 树结构 转 行结构
2946
+ * - 将树形结构扁平化为数组
2947
+ *
2948
+ * @param tree 树结构数据 (单个节点或节点数组)
2949
+ * @param options 配置项
2950
+ * @returns 扁平化后的数组
2951
+ * @example
2952
+ * ```ts
2953
+ * const tree = [{ id: 1, children: [{ id: 2 }] }];
2954
+ * treeToRows(tree);
2955
+ * // [{ id: 1, children: undefined }, { id: 2, children: undefined }]
2956
+ * ```
2272
2957
  */
2273
2958
  declare function treeToRows<T extends AnyObject, CK extends string = ChildrenKey, R$1 extends AnyObject = SetOptional<T, CK>>(tree: T | T[], options?: TreeToRowsOptions<T, CK>): R$1[];
2274
2959
  //#endregion
2275
2960
  //#region src/utils/typeof/isAbortSignal.d.ts
2961
+ /**
2962
+ * 检查 value 是否为 AbortSignal
2963
+ * @param value 待检查值
2964
+ * @returns 是否为 AbortSignal
2965
+ */
2276
2966
  declare function isAbortSignal(value: unknown): value is AbortSignal;
2277
2967
  //#endregion
2278
2968
  //#region src/utils/typeof/isArray.d.ts
2279
2969
  type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
2970
+ /**
2971
+ * 检查 value 是否为数组
2972
+ *
2973
+ * @param value 待检查值
2974
+ * @returns 是否为数组
2975
+ * @example
2976
+ * ```ts
2977
+ * isArray([]); // true
2978
+ * ```
2979
+ */
2280
2980
  declare function isArray(value: unknown): value is unknown[];
2981
+ /**
2982
+ * 检查 value 是否为 TypedArray
2983
+ *
2984
+ * @param value 待检查值
2985
+ * @returns 是否为 TypedArray
2986
+ * @example
2987
+ * ```ts
2988
+ * isTypedArray(new Int8Array()); // true
2989
+ * ```
2990
+ */
2281
2991
  declare function isTypedArray(value: unknown): value is TypedArray;
2282
2992
  //#endregion
2283
2993
  //#region src/utils/typeof/isBigInt.d.ts
2994
+ /**
2995
+ * 检查 value 是否为 BigInt
2996
+ * @param value 待检查值
2997
+ * @returns 是否为 BigInt
2998
+ */
2284
2999
  declare function isBigInt(value: unknown): value is bigint;
2285
3000
  //#endregion
2286
3001
  //#region src/utils/typeof/isBlob.d.ts
3002
+ /**
3003
+ * 检查 value 是否为 Blob
3004
+ * @param value 待检查值
3005
+ * @returns 是否为 Blob
3006
+ */
2287
3007
  declare function isBlob(value: unknown): value is Blob;
3008
+ declare function isFile(value: unknown): value is File;
2288
3009
  //#endregion
2289
3010
  //#region src/utils/typeof/isBoolean.d.ts
3011
+ /**
3012
+ * 检查 value 是否为 Boolean
3013
+ * @param value 待检查值
3014
+ * @returns 是否为 Boolean
3015
+ */
2290
3016
  declare function isBoolean(value: unknown): value is boolean;
2291
3017
  //#endregion
2292
3018
  //#region src/utils/typeof/isClass.d.ts
3019
+ /**
3020
+ * 检查 value 是否为 Class
3021
+ *
3022
+ * @param value 待检查值
3023
+ * @returns 是否为 Class
3024
+ * @example
3025
+ * ```ts
3026
+ * class A {}
3027
+ * isClass(A); // true
3028
+ * isClass(() => {}); // false
3029
+ * ```
3030
+ */
2293
3031
  declare function isClass(value: unknown): value is Class<AnyObject>;
2294
3032
  //#endregion
2295
3033
  //#region src/utils/typeof/isDate.d.ts
2296
- declare function isDate(value: unknown): value is Date;
3034
+ /**
3035
+ * 检查 value 是否为 Date 对象
3036
+ *
3037
+ * @param value 待检查值
3038
+ * @param invalidCheck 是否要求日期有效(非 Invalid Date)。默认 true
3039
+ * - true: 仅当是有效 Date 对象时返回 true(排除 new Date('invalid'))
3040
+ * - false: 只要 [[Prototype]] 是 Date 即返回 true(包含 Invalid Date)
3041
+ * @returns 是否为 Date 对象,根据 invalidCheck 返回不同语义的 Date 判定
3042
+ *
3043
+ * @example
3044
+ * ```ts
3045
+ * isDate(new Date()); // true
3046
+ * isDate(new Date('invalid')); // false
3047
+ * isDate(new Date('invalid'), false); // true
3048
+ * isDate(null); // false
3049
+ * isDate({}); // false
3050
+ * ```
3051
+ */
3052
+ declare function isDate(value: unknown, invalidCheck?: boolean): value is Date;
3053
+ //#endregion
3054
+ //#region src/utils/typeof/isEnumeration.d.ts
3055
+ /**
3056
+ * 判断一个对象是否为有效的枚举
3057
+ * - 枚举成员不能为空
3058
+ * - 枚举成员的键不能具有数值名
3059
+ * - 枚举成员的值必须类型一致且为 `string` 或 `number` 类型
3060
+ * - 枚举成员的值不能重复
3061
+ * - 枚举成员的值必须全部为双向映射或非双向映射
3062
+ *
3063
+ * @param enumeration 待检查值
3064
+ * @returns [是否为有效的枚举, 是否为双向枚举]
3065
+ */
3066
+ declare function isEnumeration(enumeration: PlainObject): [boolean, boolean];
2297
3067
  //#endregion
2298
3068
  //#region src/utils/typeof/isEqual.d.ts
2299
3069
  /**
2300
- * 检查给定的值是否相等
2301
- * @reference https://github.com/radashi-org/radashi/blob/main/src/typed/isEqual.ts
3070
+ * 深度比较两个值是否相等
2302
3071
  *
2303
- * @param {T} x
2304
- * @param {T} y
3072
+ * @param value 待比较值 A
3073
+ * @param other 待比较值 B
3074
+ * @returns 是否相等
3075
+ * @example
3076
+ * ```ts
3077
+ * isEqual({ a: 1 }, { a: 1 }); // true
3078
+ * ```
2305
3079
  */
2306
- declare function isEqual<T>(x: T, y: T): boolean;
3080
+ declare function isEqual(x: unknown, y: unknown): boolean;
2307
3081
  //#endregion
2308
3082
  //#region src/utils/typeof/isError.d.ts
3083
+ /**
3084
+ * 检查 value 是否为 Error 对象
3085
+ * @param value 待检查值
3086
+ * @returns 是否为 Error
3087
+ */
2309
3088
  declare function isError(value: unknown): value is Error;
2310
3089
  //#endregion
2311
3090
  //#region src/utils/typeof/isFalsy.d.ts
2312
- declare function isFalsy(value: unknown): boolean;
3091
+ /**
3092
+ * 检查 value 是否为 Falsy 值 (false, 0, "", null, undefined, NaN)
3093
+ * @param value 待检查值
3094
+ * @returns 是否为 Falsy
3095
+ */
3096
+ declare function isFalsy(value: unknown): value is false | 0 | "" | null | undefined;
2313
3097
  declare function isFalsyLike(value: unknown): boolean;
2314
3098
  //#endregion
2315
- //#region src/utils/typeof/isFile.d.ts
2316
- declare function isFile(value: unknown): value is File;
2317
- //#endregion
2318
3099
  //#region src/utils/typeof/isFunction.d.ts
3100
+ /**
3101
+ * 检查 value 是否为 Function
3102
+ * @param value 待检查值
3103
+ * @returns 是否为 Function
3104
+ */
2319
3105
  declare function isFunction(value: unknown): value is AnyFunction;
3106
+ /**
3107
+ * 检查 value 是否为 AsyncFunction
3108
+ * @param value 待检查值
3109
+ * @returns 是否为 AsyncFunction
3110
+ */
2320
3111
  declare function isAsyncFunction(value: unknown): value is AnyAsyncFunction;
3112
+ /**
3113
+ * 检查 value 是否为 GeneratorFunction
3114
+ * @param value 待检查值
3115
+ * @returns 是否为 GeneratorFunction
3116
+ */
2321
3117
  declare function isGeneratorFunction(value: unknown): value is AnyGeneratorFunction;
3118
+ /**
3119
+ * 检查 value 是否为 AsyncGeneratorFunction
3120
+ * @param value 待检查值
3121
+ * @returns 是否为 AsyncGeneratorFunction
3122
+ */
2322
3123
  declare function isAsyncGeneratorFunction(value: unknown): value is AnyAsyncGeneratorFunction;
2323
3124
  //#endregion
3125
+ //#region src/utils/typeof/isIframe.d.ts
3126
+ /**
3127
+ * 检查 value 是否为 HTMLIFrameElement
3128
+ * @param value 待检查值
3129
+ * @returns 是否为 HTMLIFrameElement
3130
+ */
3131
+ declare function isIframe(value: unknown): value is HTMLIFrameElement;
3132
+ declare function isInIframe(): boolean;
3133
+ //#endregion
2324
3134
  //#region src/utils/typeof/isIterable.d.ts
3135
+ /**
3136
+ * 检查 value 是否为可迭代对象 (Iterable)
3137
+ * @param value 待检查值
3138
+ * @returns 是否为 Iterable
3139
+ */
2325
3140
  declare function isIterable(value: unknown): value is {
2326
3141
  [Symbol.iterator]: () => Iterator<unknown>;
2327
3142
  };
2328
3143
  //#endregion
2329
3144
  //#region src/utils/typeof/isMap.d.ts
3145
+ /**
3146
+ * 检查 value 是否为 Map
3147
+ * @param value 待检查值
3148
+ * @returns 是否为 Map
3149
+ */
2330
3150
  declare function isMap(value: unknown): value is Map<unknown, unknown>;
3151
+ /**
3152
+ * 检查 value 是否为 WeakMap
3153
+ * @param value 待检查值
3154
+ * @returns 是否为 WeakMap
3155
+ */
2331
3156
  declare function isWeakMap(value: unknown): value is WeakMap<AnyObject, unknown>;
2332
3157
  //#endregion
2333
3158
  //#region src/utils/typeof/isNull.d.ts
3159
+ /**
3160
+ * 检查 value 是否为 null
3161
+ * @param value 待检查值
3162
+ * @returns 是否为 null
3163
+ */
2334
3164
  declare function isNull(value: unknown): value is null;
2335
3165
  //#endregion
2336
3166
  //#region src/utils/typeof/isNumber.d.ts
@@ -2338,20 +3168,29 @@ declare function isNull(value: unknown): value is null;
2338
3168
  * 检查 value 是否为 number 类型
2339
3169
  *
2340
3170
  * @param value 待检查值
2341
- * @param checkNaN 是否排除 `NaN`,默认为 `true`
3171
+ * @param NaNCheck 是否排除 `NaN`,默认为 `true`
3172
+ * @returns 是否为 number
3173
+ * @example
3174
+ * ```ts
3175
+ * isNumber(1); // true
3176
+ * isNumber(NaN); // false (default)
3177
+ * isNumber(NaN, false); // true
3178
+ * ```
2342
3179
  */
2343
- declare function isNumber(value: unknown, checkNaN?: boolean): value is number;
3180
+ declare function isNumber(value: unknown, NaNCheck?: boolean): value is number;
2344
3181
  /**
2345
3182
  * 检查 value 是否为 NaN
2346
3183
  *
2347
3184
  * @param value 待检查值
3185
+ * @returns 是否为 NaN
2348
3186
  */
2349
3187
  declare function isNaN(value: unknown): value is number;
2350
3188
  /**
2351
3189
  * 检查 value 是否为整数
2352
3190
  *
2353
3191
  * @param value 待检查值
2354
- * @param safeCheck 是否附加安全数检查
3192
+ * @param safeCheck 是否附加安全整数检查
3193
+ * @returns 是否为整数
2355
3194
  */
2356
3195
  declare function isInteger(value: unknown, safeCheck?: boolean): value is number;
2357
3196
  /**
@@ -2359,7 +3198,7 @@ declare function isInteger(value: unknown, safeCheck?: boolean): value is number
2359
3198
  * - 此函数中 `0` 不被视为正整数
2360
3199
  *
2361
3200
  * @param value 待检查值
2362
- * @param safeCheck 是否附加安全数检查
3201
+ * @param safeCheck 是否附加安全整数检查
2363
3202
  */
2364
3203
  declare function isPositiveInteger(value: unknown, safeCheck?: boolean): value is number;
2365
3204
  /**
@@ -2367,7 +3206,7 @@ declare function isPositiveInteger(value: unknown, safeCheck?: boolean): value i
2367
3206
  * - 此函数中 `0` 不被视为负整数
2368
3207
  *
2369
3208
  * @param value 待检查值
2370
- * @param safeCheck 是否附加安全数检查
3209
+ * @param safeCheck 是否附加安全整数检查
2371
3210
  */
2372
3211
  declare function isNegativeInteger(value: unknown, safeCheck?: boolean): value is number;
2373
3212
  /**
@@ -2387,35 +3226,71 @@ declare function isInfinityLike(value: unknown): boolean;
2387
3226
  //#endregion
2388
3227
  //#region src/utils/typeof/isObject.d.ts
2389
3228
  /**
2390
- * 判断是否为对象类型
3229
+ * 判断是否为普通对象类型
2391
3230
  * - 可选是否检查原型为 `Object.prototype`,防止原型链污染
2392
3231
  *
2393
3232
  * @param value 待检查值
2394
3233
  * @param prototypeCheck 是否进行原型检查,默认 `true`
3234
+ * @returns 是否为 Plain Object (当 checkPrototype=true) 或 object
3235
+ * @example
3236
+ * ```ts
3237
+ * isObject({}); // true
3238
+ * isObject([]); // false
3239
+ * isObject(new Date()); // false (because prototype is not Object.prototype)
3240
+ * isObject(new Date(), false); // true (is object type)
3241
+ * isObject(Object.create(null)) // false
3242
+ * isObject(Object.create(null), false) // true
3243
+ * ```
2395
3244
  */
2396
3245
  declare function isObject(value: unknown, prototypeCheck?: boolean): value is Record<PropertyKey, unknown>;
2397
3246
  //#endregion
2398
3247
  //#region src/utils/typeof/isPromise.d.ts
3248
+ /**
3249
+ * 检查 value 是否为 Promise
3250
+ * @param value 待检查值
3251
+ * @returns 是否为 Promise
3252
+ */
2399
3253
  declare function isPromise(value: unknown): value is Promise<unknown>;
3254
+ /**
3255
+ * 检查 value 是否为 PromiseLike (thenable)
3256
+ * @param value 待检查值
3257
+ * @returns 是否为 PromiseLike
3258
+ */
2400
3259
  declare function isPromiseLike(value: unknown): value is PromiseLike<unknown>;
2401
3260
  //#endregion
2402
3261
  //#region src/utils/typeof/isReadableStream.d.ts
2403
3262
  /**
2404
- * Checks if a value is a WHATWG ReadableStream instance.
2405
- *
3263
+ * 检查 value 是否为 ReadableStream
2406
3264
  * - Uses `Object.prototype.toString` where supported (modern browsers, Node.js ≥18).
2407
3265
  * - Falls back to duck-typing in older environments.
2408
3266
  * - Resistant to basic forgery, but not 100% secure in all polyfill scenarios.
3267
+ * - ⚠️ Note: In older Node.js (<18) or with non-compliant polyfills, this may return false positives or negatives.
2409
3268
  *
2410
- * ⚠️ Note: In older Node.js (<18) or with non-compliant polyfills, this may return false positives or negatives.
3269
+ * @param value 待检查值
3270
+ * @returns 是否为 ReadableStream
2411
3271
  */
2412
3272
  declare function isReadableStream(value: unknown): value is ReadableStream;
2413
3273
  //#endregion
2414
3274
  //#region src/utils/typeof/isRegExp.d.ts
3275
+ /**
3276
+ * 检查 value 是否为 RegExp
3277
+ * @param value 待检查值
3278
+ * @returns 是否为 RegExp
3279
+ */
2415
3280
  declare function isRegExp(value: unknown): value is RegExp;
2416
3281
  //#endregion
2417
3282
  //#region src/utils/typeof/isSet.d.ts
3283
+ /**
3284
+ * 检查 value 是否为 Set
3285
+ * @param value 待检查值
3286
+ * @returns 是否为 Set
3287
+ */
2418
3288
  declare function isSet(value: unknown): value is Set<unknown>;
3289
+ /**
3290
+ * 检查 value 是否为 WeakSet
3291
+ * @param value 待检查值
3292
+ * @returns 是否为 WeakSet
3293
+ */
2419
3294
  declare function isWeakSet(value: unknown): value is WeakSet<AnyObject>;
2420
3295
  //#endregion
2421
3296
  //#region src/utils/typeof/isString.d.ts
@@ -2424,23 +3299,55 @@ declare function isWeakSet(value: unknown): value is WeakSet<AnyObject>;
2424
3299
  *
2425
3300
  * @param value 待检查值
2426
3301
  * @param checkEmpty 是否排除空字符串
3302
+ * @returns 是否为字符串
3303
+ * @example
3304
+ * ```ts
3305
+ * isString("abc"); // true
3306
+ * isString(""); // true
3307
+ * isString("", true); // false
3308
+ * ```
2427
3309
  */
2428
3310
  declare function isString(value: unknown, checkEmpty?: boolean): value is string;
2429
3311
  //#endregion
2430
3312
  //#region src/utils/typeof/isSymbol.d.ts
3313
+ /**
3314
+ * 检查 value 是否为 Symbol
3315
+ * @param value 待检查值
3316
+ * @returns 是否为 Symbol
3317
+ */
2431
3318
  declare function isSymbol(value: unknown): value is symbol;
2432
3319
  //#endregion
2433
3320
  //#region src/utils/typeof/isUndefined.d.ts
3321
+ /**
3322
+ * 检查 value 是否为 undefined
3323
+ * @param value 待检查值
3324
+ * @returns 是否为 undefined
3325
+ */
2434
3326
  declare function isUndefined(value: unknown): value is undefined;
2435
3327
  //#endregion
2436
3328
  //#region src/utils/typeof/isURLSearchParams.d.ts
3329
+ /**
3330
+ * 检查 value 是否为 URLSearchParams
3331
+ * @param value 待检查值
3332
+ * @returns 是否为 URLSearchParams
3333
+ */
2437
3334
  declare function isURLSearchParams(value: unknown): value is URLSearchParams;
2438
3335
  //#endregion
2439
3336
  //#region src/utils/typeof/isWebSocket.d.ts
3337
+ /**
3338
+ * 检查 value 是否为 WebSocket
3339
+ * @param value 待检查值
3340
+ * @returns 是否为 WebSocket
3341
+ */
2440
3342
  declare function isWebSocket(value: unknown): value is WebSocket;
2441
3343
  //#endregion
2442
3344
  //#region src/utils/typeof/isWindow.d.ts
3345
+ /**
3346
+ * 检查 value 是否为 Window
3347
+ * @param value 待检查值
3348
+ * @returns 是否为 Window
3349
+ */
2443
3350
  declare function isWindow(value: unknown): value is Window;
2444
3351
  //#endregion
2445
- export { arrayCast, arrayCompete, arrayCounting, arrayDifference, arrayFirst, arrayFork, arrayIntersection, arrayLast, arrayMerge, arrayPick, arrayReplace, arraySplit, cloneDeep, enumEntries, enumKeys, enumTypeCheck, enumValues, isAbortSignal, isArray, isAsyncFunction, isAsyncGeneratorFunction, isBigInt, isBlob, isBoolean, isClass, isDate, isEqual, isError, isFalsy, isFalsyLike, isFile, isFunction, isGeneratorFunction, isInfinity, isInfinityLike, isInteger, isIterable, isMap, isNaN, isNegativeInteger, isNull, isNumber, isObject, isPositiveInteger, isPromise, isPromiseLike, isReadableStream, isRegExp, isSet, isString, isSymbol, isTypedArray, isURLSearchParams, isUndefined, isWeakMap, isWeakSet, isWebSocket, isWindow, mapEntries, objectAssign, objectCrush, objectEntries, objectKeys, objectPick, objectSwitch, objectValues, rowsToTree, stringInitialCase, stringReplace, stringTemplate, stringToJson, stringToNumber, stringToPosix, stringToValues, stringTrim, stringTruncate, to, toMathBignumber, toMathDecimal, toMathEvaluate, treeFilter, treeFind, treeForEach, treeMap, treeToRows };
3352
+ export { arrayCast, arrayCompete, arrayCounting, arrayDifference, arrayFirst, arrayFork, arrayIntersection, arrayLast, arrayMerge, arrayPick, arrayReplace, arrayReplaceMove, arraySplit, arrayUnzip, arrayZip, arrayZipToObject, clone, cloneDeep, cloneDeepWith, enumEntries, enumKeys, enumValues, getTimeZone, isAbortSignal, isArray, isAsyncFunction, isAsyncGeneratorFunction, isBigInt, isBlob, isBoolean, isBrowser, isClass, isDate, isEnumeration, isEqual, isError, isFalsy, isFalsyLike, isFile, isFunction, isGeneratorFunction, isIOSMobile, isIframe, isInIframe, isInfinity, isInfinityLike, isInteger, isIterable, isMap, isMobile, isNaN, isNegativeInteger, isNull, isNumber, isObject, isPositiveInteger, isPromise, isPromiseLike, isReadableStream, isRegExp, isSet, isString, isSymbol, isTablet, isTypedArray, isURLSearchParams, isUndefined, isWeakMap, isWeakSet, isWebSocket, isWebWorker, isWindow, mathToBignumber, mathToDecimal, mathToEvaluate, numberWithin, objectAssign, objectCrush, objectEntries, objectInvert, objectKeys, objectMapEntries, objectOmit, objectPick, objectValues, rowsToTree, stringInitialCase, stringReplace, stringTemplate, stringToJson, stringToNumber, stringToPosix, stringToValues, stringTrim, stringTruncate, to, treeFilter, treeFind, treeForEach, treeMap, treeToRows };
2446
3353
  //# sourceMappingURL=index.d.ts.map