@pawover/kit 0.0.0-beta.2 → 0.0.0-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,181 +1,8 @@
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-C38JazcR.js";
2
+ import { a as AnyObject, i as AnyGeneratorFunction, n as AnyAsyncGeneratorFunction, o as PlainObject, r as AnyFunction, s as TreeLike, t as AnyAsyncFunction } from "./index-CjoMz104.js";
1
3
  import { BigNumber, MathExpression, MathJsInstance, Matrix } from "mathjs";
2
4
 
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
5
+ //#region node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/basic.d.ts
179
6
  /**
180
7
  Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
181
8
 
@@ -186,1015 +13,654 @@ type Class<T, Arguments extends unknown[] = any[]> = {
186
13
  new (...arguments_: Arguments): T;
187
14
  };
188
15
  //#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).
16
+ //#region node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/internal/array.d.ts
192
17
 
193
- Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
18
+ /**
19
+ 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
20
 
195
21
  @example
196
22
  ```
197
- import type {UnionToIntersection} from 'type-fest';
23
+ type A = CollapseRestElement<[string, string, ...number[]]>;
24
+ //=> [string, string, number]
25
+
26
+ type B = CollapseRestElement<[...string[], number, number]>;
27
+ //=> [string, number, number]
198
28
 
199
- type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
29
+ type C = CollapseRestElement<[string, string, ...Array<number | bigint>]>;
30
+ //=> [string, string, number | bigint]
200
31
 
201
- type Intersection = UnionToIntersection<Union>;
202
- //=> {the(): void; great(arg: string): void; escape: boolean};
32
+ type D = CollapseRestElement<[string, number]>;
33
+ //=> [string, number]
203
34
  ```
204
35
 
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
36
+ 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
37
 
231
38
  @example
232
39
  ```
233
- import type {KeysOfUnion} from 'type-fest';
234
-
235
- type A = {
236
- common: string;
237
- a: number;
238
- };
239
-
240
- type B = {
241
- common: string;
242
- b: string;
243
- };
244
-
245
- type C = {
246
- common: string;
247
- c: boolean;
248
- };
40
+ // `exactOptionalPropertyTypes` enabled
41
+ type A = CollapseRestElement<[string?, string?, ...number[]]>;
42
+ //=> [string, string, number]
249
43
 
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'
44
+ // `exactOptionalPropertyTypes` disabled
45
+ type B = CollapseRestElement<[string?, string?, ...number[]]>;
46
+ //=> [string | undefined, string | undefined, number]
257
47
  ```
258
-
259
- @category Object
260
48
  */
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>;
49
+ type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, _CollapseRestElement<TArray>>;
50
+ type _CollapseRestElement<TArray extends UnknownArray, ForwardAccumulator extends UnknownArray = [], BackwardAccumulator extends UnknownArray = []> = TArray extends UnknownArray // For distributing `TArray`
51
+ ? keyof TArray & `${number}` extends never
52
+ // Enters this branch, if `TArray` is empty (e.g., []),
53
+ // or `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
54
+ ? TArray extends readonly [...infer Rest, infer Last] ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
55
+ : TArray extends readonly [] ? [...ForwardAccumulator, ...BackwardAccumulator] : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
56
+ : 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.
57
+ : First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
58
+ : never; // Should never happen
264
59
  //#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`.
60
+ //#region node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/numeric.d.ts
61
+ type _Numeric = number | bigint;
62
+ type Zero = 0 | 0n;
268
63
 
269
- @link https://stackoverflow.com/a/49928360/1490091
64
+ /**
65
+ Matches the hidden `Infinity` type.
270
66
 
271
- Useful in type utilities, such as disallowing `any`s to be passed to a function.
67
+ 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
68
 
273
- @example
274
- ```
275
- import type {IsAny} from 'type-fest';
69
+ @see {@link NegativeInfinity}
276
70
 
277
- const typedObject = {a: 1, b: 2} as const;
278
- const anyObject: any = {a: 1, b: 2};
71
+ @category Numeric
72
+ */
73
+ // See https://github.com/microsoft/TypeScript/issues/31752
74
+ // eslint-disable-next-line no-loss-of-precision
279
75
 
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
- }
76
+ /**
77
+ A negative `number`/`bigint` (`-∞ < x < 0`)
283
78
 
284
- const typedA = get(typedObject, 'a');
285
- //=> 1
79
+ Use-case: Validating and documenting parameters.
286
80
 
287
- const anyA = get(anyObject, 'a');
288
- //=> any
289
- ```
81
+ @see {@link NegativeInteger}
82
+ @see {@link NonNegative}
290
83
 
291
- @category Type Guard
292
- @category Utilities
84
+ @category Numeric
293
85
  */
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
86
+ type Negative<T extends _Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never;
297
87
  /**
298
- Returns a boolean for whether the given key is an optional key of type.
88
+ Returns a boolean for whether the given number is a negative number.
299
89
 
300
- This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
90
+ @see {@link Negative}
301
91
 
302
92
  @example
303
93
  ```
304
- import type {IsOptionalKeyOf} from 'type-fest';
94
+ import type {IsNegative} from 'type-fest';
305
95
 
306
- type User = {
307
- name: string;
308
- surname: string;
96
+ type ShouldBeFalse = IsNegative<1>;
97
+ type ShouldBeTrue = IsNegative<-1>;
98
+ ```
309
99
 
310
- luckyNumber?: number;
100
+ @category Numeric
101
+ */
102
+ type IsNegative<T extends _Numeric> = T extends Negative<T> ? true : false;
103
+ //#endregion
104
+ //#region node_modules/.pnpm/tagged-tag@1.0.0/node_modules/tagged-tag/index.d.ts
105
+ declare const tag: unique symbol;
106
+ //#endregion
107
+ //#region node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/tagged.d.ts
108
+ // eslint-disable-next-line type-fest/require-exported-types
109
+ type TagContainer<Token> = {
110
+ readonly [tag]: Token;
311
111
  };
112
+ type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{ [K in Token]: TagMetadata }>;
312
113
 
313
- type Admin = {
314
- name: string;
315
- surname?: string;
316
- };
114
+ /**
115
+ 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
116
 
318
- type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
319
- //=> true
117
+ A type returned by `Tagged` can be passed to `Tagged` again, to create a type with multiple tags.
320
118
 
321
- type T2 = IsOptionalKeyOf<User, 'name'>;
322
- //=> false
119
+ [Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
323
120
 
324
- type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
325
- //=> boolean
121
+ 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
122
 
327
- type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
328
- //=> false
123
+ A type `A` returned by `Tagged` is assignable to another type `B` returned by `Tagged` if and only if:
124
+ - the underlying (untagged) type of `A` is assignable to the underlying type of `B`;
125
+ - `A` contains at least all the tags `B` has;
126
+ - and the metadata type for each of `A`'s tags is assignable to the metadata type of `B`'s corresponding tag.
329
127
 
330
- type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
331
- //=> boolean
128
+ There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
129
+ - [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
130
+ - [Microsoft/TypeScript#4895](https://github.com/microsoft/TypeScript/issues/4895)
131
+ - [Microsoft/TypeScript#33290](https://github.com/microsoft/TypeScript/pull/33290)
132
+
133
+ @example
332
134
  ```
135
+ import type {Tagged} from 'type-fest';
333
136
 
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.
137
+ type AccountNumber = Tagged<number, 'AccountNumber'>;
138
+ type AccountBalance = Tagged<number, 'AccountBalance'>;
342
139
 
343
- This is useful when you want to create a new type that contains different type values for the optional keys only.
140
+ function createAccountNumber(): AccountNumber {
141
+ // As you can see, casting from a `number` (the underlying type being tagged) is allowed.
142
+ return 2 as AccountNumber;
143
+ }
344
144
 
345
- @example
346
- ```
347
- import type {OptionalKeysOf, Except} from 'type-fest';
145
+ declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
348
146
 
349
- type User = {
350
- name: string;
351
- surname: string;
147
+ // This will compile successfully.
148
+ getMoneyForAccount(createAccountNumber());
352
149
 
353
- luckyNumber?: number;
354
- };
150
+ // But this won't, because it has to be explicitly passed as an `AccountNumber` type!
151
+ // Critically, you could not accidentally use an `AccountBalance` as an `AccountNumber`.
152
+ // @ts-expect-error
153
+ getMoneyForAccount(2);
355
154
 
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
- };
155
+ // You can also use tagged values like their underlying, untagged type.
156
+ // I.e., this will compile successfully because an `AccountNumber` can be used as a regular `number`.
157
+ // In this sense, the underlying base type is not hidden, which differentiates tagged types from opaque types in other languages.
158
+ const accountNumber = createAccountNumber() + 2;
159
+ ```
360
160
 
361
- const update1: UpdateOperation<User> = {
362
- name: 'Alice',
363
- };
161
+ @example
162
+ ```
163
+ import type {Tagged} from 'type-fest';
364
164
 
365
- const update2: UpdateOperation<User> = {
366
- name: 'Bob',
367
- luckyNumber: REMOVE_FIELD,
368
- };
165
+ // You can apply multiple tags to a type by using `Tagged` repeatedly.
166
+ type Url = Tagged<string, 'URL'>;
167
+ type SpecialCacheKey = Tagged<Url, 'SpecialCacheKey'>;
168
+
169
+ // 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.
170
+ type SpecialCacheKey2 = Tagged<string, 'URL' | 'SpecialCacheKey'>;
369
171
  ```
370
172
 
371
- @category Utilities
173
+ @category Type
372
174
  */
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
175
+ type Tagged<Type$1, TagName extends PropertyKey, TagMetadata = never> = Type$1 & Tag<TagName, TagMetadata>;
378
176
  /**
379
- Extract all required keys from the given type.
177
+ Revert a tagged type back to its original type by removing all tags.
178
+
179
+ Why is this necessary?
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
+ 1. Use a `Tagged` type as object keys
182
+ 2. Prevent TS4058 error: "Return type of exported function has or is using name X from external module Y but cannot be named"
382
183
 
383
184
  @example
384
185
  ```
385
- import type {RequiredKeysOf} from 'type-fest';
186
+ import type {Tagged, UnwrapTagged} from 'type-fest';
386
187
 
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;
188
+ type AccountType = Tagged<'SAVINGS' | 'CHECKING', 'AccountType'>;
391
189
 
392
- type User = {
393
- name: string;
394
- surname: string;
395
- luckyNumber?: number;
190
+ const moneyByAccountType: Record<UnwrapTagged<AccountType>, number> = {
191
+ SAVINGS: 99,
192
+ CHECKING: 0.1,
396
193
  };
397
194
 
398
- const validator1 = createValidation<User>('name', value => value.length < 25);
399
- const validator2 = createValidation<User>('surname', value => value.length < 25);
195
+ // Without UnwrapTagged, the following expression would throw a type error.
196
+ const money = moneyByAccountType.SAVINGS; // TS error: Property 'SAVINGS' does not exist
400
197
 
198
+ // Attempting to pass an non-Tagged type to UnwrapTagged will raise a type error.
401
199
  // @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"'.
200
+ type WontWork = UnwrapTagged<string>;
404
201
  ```
405
202
 
406
- @category Utilities
203
+ @category Type
407
204
  */
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
412
- /**
413
- Creates a type that represents `true` or `false` depending on whether the given type has any required fields.
414
-
415
- This is useful when you want to create an API whose behavior depends on the presence or absence of required fields.
205
+ type UnwrapTagged<TaggedType extends Tag<PropertyKey, any>> = RemoveAllTags<TaggedType>;
206
+ 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;
416
207
 
417
- @example
418
- ```
419
- import type {HasRequiredKeys} from 'type-fest';
208
+ /**
209
+ Note: The `Opaque` type is deprecated in favor of `Tagged`.
420
210
 
421
- type GeneratorOptions<Template extends object> = {
422
- prop1: number;
423
- prop2: string;
424
- } & (HasRequiredKeys<Template> extends true
425
- ? {template: Template}
426
- : {template?: Template});
211
+ 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.)
427
212
 
428
- type Template1 = {
429
- optionalSubParam?: string;
430
- };
213
+ The generic type parameters can be anything.
431
214
 
432
- type Template2 = {
433
- requiredSubParam: string;
434
- };
215
+ 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.)
435
216
 
436
- type Options1 = GeneratorOptions<Template1>;
437
- type Options2 = GeneratorOptions<Template2>;
217
+ Also note that this implementation is limited to a single tag. If you want to allow multiple tags, use `Tagged` instead.
438
218
 
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
- };
219
+ [Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
455
220
 
456
- const optD: Options2 = {
457
- prop1: 0,
458
- prop2: 'hi',
459
- template: {
460
- requiredSubParam: 'required value',
461
- },
462
- };
221
+ There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
222
+ - [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
223
+ - [Microsoft/TypeScript#15408](https://github.com/Microsoft/TypeScript/issues/15408)
224
+ - [Microsoft/TypeScript#15807](https://github.com/Microsoft/TypeScript/issues/15807)
463
225
 
226
+ @example
464
227
  ```
228
+ import type {Opaque} from 'type-fest';
465
229
 
466
- @category Utilities
467
- */
468
- type HasRequiredKeys<BaseType extends object> = RequiredKeysOf<BaseType> extends never ? false : true;
469
- //#endregion
470
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-never.d.ts
471
- /**
472
- Returns a boolean for whether the given type is `never`.
230
+ type AccountNumber = Opaque<number, 'AccountNumber'>;
231
+ type AccountBalance = Opaque<number, 'AccountBalance'>;
473
232
 
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
233
+ // The `Token` parameter allows the compiler to differentiate between types, whereas "unknown" will not. For example, consider the following structures:
234
+ type ThingOne = Opaque<string>;
235
+ type ThingTwo = Opaque<string>;
477
236
 
478
- Useful in type utilities, such as checking if something does not occur.
237
+ // 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 }`.
238
+ // To avoid this behaviour, you would instead pass the "Token" parameter, like so.
239
+ type NewThingOne = Opaque<string, 'ThingOne'>;
240
+ type NewThingTwo = Opaque<string, 'ThingTwo'>;
479
241
 
480
- @example
481
- ```
482
- import type {IsNever, And} from 'type-fest';
242
+ // Now they're completely separate types, so the following will fail to compile.
243
+ function createNewThingOne(): NewThingOne {
244
+ // As you can see, casting from a string is still allowed. However, you may not cast NewThingOne to NewThingTwo, and vice versa.
245
+ return 'new thing one' as NewThingOne;
246
+ }
483
247
 
484
- type A = IsNever<never>;
485
- //=> true
248
+ // This will fail to compile, as they are fundamentally different types.
249
+ // @ts-expect-error
250
+ const thingTwo = createNewThingOne() as NewThingTwo;
486
251
 
487
- type B = IsNever<any>;
488
- //=> false
252
+ // Here's another example of opaque typing.
253
+ function createAccountNumber(): AccountNumber {
254
+ return 2 as AccountNumber;
255
+ }
489
256
 
490
- type C = IsNever<unknown>;
491
- //=> false
257
+ declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
492
258
 
493
- type D = IsNever<never[]>;
494
- //=> false
495
-
496
- type E = IsNever<object>;
497
- //=> false
498
-
499
- type F = IsNever<string>;
500
- //=> false
501
- ```
502
-
503
- @example
504
- ```
505
- import type {IsNever} from 'type-fest';
259
+ // This will compile successfully.
260
+ getMoneyForAccount(createAccountNumber());
506
261
 
507
- type IsTrue<T> = T extends true ? true : false;
262
+ // But this won't, because it has to be explicitly passed as an `AccountNumber` type.
263
+ // @ts-expect-error
264
+ getMoneyForAccount(2);
508
265
 
509
- // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
510
- type A = IsTrue<never>;
511
- // ^? type A = never
266
+ // You can use opaque values like they aren't opaque too.
267
+ const accountNumber = createAccountNumber();
512
268
 
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;
269
+ // This will compile successfully.
270
+ const newAccountNumber = accountNumber + 2;
516
271
 
517
- type B = IsTrueFixed<never>;
518
- // ^? type B = false
272
+ // As a side note, you can (and should) use recursive types for your opaque types to make them stronger and hopefully easier to type.
273
+ type Person = {
274
+ id: Opaque<number, Person>;
275
+ name: string;
276
+ };
519
277
  ```
520
278
 
521
- @category Type Guard
522
- @category Utilities
279
+ @category Type
280
+ @deprecated Use {@link Tagged} instead
523
281
  */
524
- type IsNever<T> = [T] extends [never] ? true : false;
525
282
  //#endregion
526
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/if.d.ts
283
+ //#region node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/is-literal.d.ts
527
284
  /**
528
- An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
285
+ 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).
529
286
 
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'>`.
287
+ Useful for:
288
+ - providing strongly-typed string manipulation functions
289
+ - constraining strings to be a string literal
290
+ - type utilities, such as when constructing parsers and ASTs
532
291
 
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'`.
292
+ The implementation of this type is inspired by the trick mentioned in this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
536
293
 
537
294
  @example
538
295
  ```
539
- import type {If} from 'type-fest';
540
-
541
- type A = If<true, 'yes', 'no'>;
542
- //=> 'yes'
543
-
544
- type B = If<false, 'yes', 'no'>;
545
- //=> 'no'
546
-
547
- type C = If<boolean, 'yes', 'no'>;
548
- //=> 'yes' | 'no'
549
-
550
- type D = If<any, 'yes', 'no'>;
551
- //=> 'yes' | 'no'
552
-
553
- type E = If<never, 'yes', 'no'>;
554
- //=> 'no'
555
- ```
296
+ import type {IsStringLiteral} from 'type-fest';
556
297
 
557
- @example
558
- ```
559
- import type {If, IsAny, IsNever} from 'type-fest';
298
+ type CapitalizedString<T extends string> = IsStringLiteral<T> extends true ? Capitalize<T> : string;
560
299
 
561
- type A = If<IsAny<unknown>, 'is any', 'not any'>;
562
- //=> 'not any'
300
+ // https://github.com/yankeeinlondon/native-dash/blob/master/src/capitalize.ts
301
+ function capitalize<T extends Readonly<string>>(input: T): CapitalizedString<T> {
302
+ return (input.slice(0, 1).toUpperCase() + input.slice(1)) as CapitalizedString<T>;
303
+ }
563
304
 
564
- type B = If<IsNever<never>, 'is never', 'not never'>;
565
- //=> 'is never'
305
+ const output = capitalize('hello, world!');
306
+ //=> 'Hello, world!'
566
307
  ```
567
308
 
568
309
  @example
569
310
  ```
570
- import type {If, IsEqual} from 'type-fest';
311
+ // String types with infinite set of possible values return `false`.
571
312
 
572
- type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
313
+ import type {IsStringLiteral} from 'type-fest';
573
314
 
574
- type A = IfEqual<string, string, 'equal', 'not equal'>;
575
- //=> 'equal'
576
-
577
- type B = IfEqual<string, number, 'equal', 'not equal'>;
578
- //=> 'not equal'
579
- ```
315
+ type AllUppercaseStrings = IsStringLiteral<Uppercase<string>>;
316
+ //=> false
580
317
 
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:
318
+ type StringsStartingWithOn = IsStringLiteral<`on${string}`>;
319
+ //=> false
582
320
 
583
- @example
584
- ```
585
- import type {If, IsEqual, StringRepeat} from 'type-fest';
321
+ // This behaviour is particularly useful in string manipulation utilities, as infinite string types often require separate handling.
586
322
 
587
- type HundredZeroes = StringRepeat<'0', 100>;
323
+ type Length<S extends string, Counter extends never[] = []> =
324
+ IsStringLiteral<S> extends false
325
+ ? number // return `number` for infinite string types
326
+ : S extends `${string}${infer Tail}`
327
+ ? Length<Tail, [...Counter, never]>
328
+ : Counter['length'];
588
329
 
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';
330
+ type L1 = Length<Lowercase<string>>;
331
+ //=> number
596
332
 
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'
333
+ type L2 = Length<`${number}`>;
334
+ //=> number
614
335
  ```
615
336
 
616
337
  @category Type Guard
617
338
  @category Utilities
618
339
  */
619
- type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
340
+ type IsStringLiteral<S> = IfNotAnyOrNever<S, _IsStringLiteral<CollapseLiterals<S extends TagContainer<any> ? UnwrapTagged<S> : S>>, false, false>;
341
+ type _IsStringLiteral<S> =
342
+ // If `T` is an infinite string type (e.g., `on${string}`), `Record<T, never>` produces an index signature,
343
+ // and since `{}` extends index signatures, the result becomes `false`.
344
+ S extends string ? {} extends Record<S, never> ? false : true : false;
620
345
  //#endregion
621
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/internal/type.d.ts
346
+ //#region node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/tuple-of.d.ts
622
347
  /**
623
- An if-else-like type that resolves depending on whether the given type is `any` or `never`.
348
+ Create a tuple type of the specified length with elements of the specified type.
624
349
 
625
350
  @example
626
351
  ```
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'
352
+ import type {TupleOf} from 'type-fest';
630
353
 
631
- // When `T` is `any` => Returns `IfAny` branch
632
- type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
633
- //=> 'IS_ANY'
354
+ type RGB = TupleOf<3, number>;
355
+ //=> [number, number, number]
634
356
 
635
- // When `T` is `never` => Returns `IfNever` branch
636
- type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
637
- //=> 'IS_NEVER'
638
- ```
357
+ type Line = TupleOf<2, {x: number; y: number}>;
358
+ //=> [{x: number; y: number}, {x: number; y: number}]
639
359
 
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:
360
+ type TicTacToeBoard = TupleOf<3, TupleOf<3, 'X' | 'O' | null>>;
361
+ //=> [['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]]
362
+ ```
641
363
 
642
364
  @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>;
650
-
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.
365
+ ```
366
+ import type {TupleOf} from 'type-fest';
656
367
 
657
- // To fix this, move the recursion into a helper type
658
- type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S>>;
368
+ type Range<Start extends number, End extends number> = Exclude<keyof TupleOf<End>, keyof TupleOf<Start>>;
659
369
 
660
- type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
370
+ type ZeroToFour = Range<0, 5>;
371
+ //=> '0' | '1' | '2' | '3' | '4'
661
372
 
662
- type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
663
- //=> ''
373
+ type ThreeToEight = Range<3, 9>;
374
+ //=> '5' | '3' | '4' | '6' | '7' | '8'
664
375
  ```
665
- */
666
- type IfNotAnyOrNever<T, IfNotAnyOrNever$1, IfAny = any, IfNever = never> = If<IsAny<T>, IfAny, If<IsNever<T>, IfNever, IfNotAnyOrNever$1>>;
667
- //#endregion
668
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/simplify.d.ts
669
- /**
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.
376
+
377
+ Note: If the specified length is the non-literal `number` type, the result will not be a tuple but a regular array.
671
378
 
672
379
  @example
673
380
  ```
674
- import type {Simplify} from 'type-fest';
675
-
676
- type PositionProps = {
677
- top: number;
678
- left: number;
679
- };
381
+ import type {TupleOf} from 'type-fest';
680
382
 
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>;
383
+ type StringArray = TupleOf<number, string>;
384
+ //=> string[]
688
385
  ```
689
386
 
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.
691
-
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`.
387
+ Note: If the type for elements is not specified, it will default to `unknown`.
693
388
 
694
389
  @example
695
390
  ```
696
- import type {Simplify} from 'type-fest';
697
-
698
- interface SomeInterface {
699
- foo: number;
700
- bar?: string;
701
- baz: number | undefined;
702
- }
391
+ import type {TupleOf} from 'type-fest';
703
392
 
704
- type SomeType = {
705
- foo: number;
706
- bar?: string;
707
- baz: number | undefined;
708
- };
393
+ type UnknownTriplet = TupleOf<3>;
394
+ //=> [unknown, unknown, unknown]
395
+ ```
709
396
 
710
- const literal = {foo: 123, bar: 'hello', baz: 456};
711
- const someType: SomeType = literal;
712
- const someInterface: SomeInterface = literal;
397
+ Note: If the specified length is negative, the result will be an empty tuple.
713
398
 
714
- declare function fn(object: Record<string, unknown>): void;
399
+ @example
400
+ ```
401
+ import type {TupleOf} from 'type-fest';
715
402
 
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`
403
+ type EmptyTuple = TupleOf<-3, string>;
404
+ //=> []
721
405
  ```
722
406
 
723
- @link https://github.com/microsoft/TypeScript/issues/15300
724
- @see {@link SimplifyDeep}
725
- @category Object
407
+ 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>>`.
408
+
409
+ @category Array
726
410
  */
727
- type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
411
+ type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length, _TupleOf<If<IsNegative<Length>, 0, Length>, Fill, []>, Fill[], []>;
412
+ type _TupleOf<L extends number, Fill, Accumulator extends UnknownArray> = number extends L ? Fill[] : L extends Accumulator['length'] ? Accumulator : _TupleOf<L, Fill, [...Accumulator, Fill]>;
728
413
  //#endregion
729
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-equal.d.ts
414
+ //#region node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/or.d.ts
730
415
  /**
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
416
+ Returns a boolean for whether either of two given types is true.
735
417
 
736
- Use-cases:
737
- - If you want to make a conditional branch based on the result of a comparison of two types.
418
+ Use-case: Constructing complex conditional types where at least one condition must be satisfied.
738
419
 
739
420
  @example
740
421
  ```
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.
422
+ import type {Or} from 'type-fest';
763
423
 
764
- This is the counterpart of `PickIndexSignature`.
424
+ type TT = Or<true, true>;
425
+ //=> true
765
426
 
766
- Use-cases:
767
- - Remove overly permissive signatures from third-party types.
427
+ type TF = Or<true, false>;
428
+ //=> true
768
429
 
769
- This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
430
+ type FT = Or<false, true>;
431
+ //=> true
770
432
 
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>`.
433
+ type FF = Or<false, false>;
434
+ //=> false
435
+ ```
772
436
 
773
- (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
437
+ Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
438
+ For example, `Or<false, boolean>` expands to `Or<false, true> | Or<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
774
439
 
440
+ @example
775
441
  ```
776
- const indexed: Record<string, unknown> = {}; // Allowed
442
+ import type {Or} from 'type-fest';
777
443
 
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
781
- ```
444
+ type A = Or<false, boolean>;
445
+ //=> boolean
782
446
 
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:
447
+ type B = Or<boolean, false>;
448
+ //=> boolean
784
449
 
785
- ```
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
- ```
450
+ type C = Or<true, boolean>;
451
+ //=> true
796
452
 
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`...
453
+ type D = Or<boolean, true>;
454
+ //=> true
798
455
 
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
- };
456
+ type E = Or<boolean, boolean>;
457
+ //=> boolean
804
458
  ```
805
459
 
806
- ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
460
+ Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
807
461
 
462
+ @example
808
463
  ```
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
- ```
464
+ import type {Or} from 'type-fest';
818
465
 
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.
466
+ type A = Or<true, never>;
467
+ //=> true
820
468
 
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
- };
469
+ type B = Or<never, true>;
470
+ //=> true
840
471
 
841
- type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
842
- // => { foo: 'bar'; qux?: 'baz' | undefined; }
843
- ```
472
+ type C = Or<false, never>;
473
+ //=> false
844
474
 
845
- @see {@link PickIndexSignature}
846
- @category Object
847
- */
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.
475
+ type D = Or<never, false>;
476
+ //=> false
853
477
 
854
- This is the counterpart of `OmitIndexSignature`.
478
+ type E = Or<boolean, never>;
479
+ //=> boolean
855
480
 
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
- };
481
+ type F = Or<never, boolean>;
482
+ //=> boolean
879
483
 
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
- // }
484
+ type G = Or<never, never>;
485
+ //=> false
891
486
  ```
892
487
 
893
- @see {@link OmitIndexSignature}
894
- @category Object
488
+ @see {@link And}
489
+ @see {@link Xor}
895
490
  */
896
- type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
897
- //#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;
491
+ 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>>;
492
+ // `never` is treated as `false`
901
493
 
494
+ type _Or<A$1 extends boolean, B$1 extends boolean> = A$1 extends true ? true : B$1 extends true ? true : false;
495
+ //#endregion
496
+ //#region node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/all-extend.d.ts
902
497
  /**
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;
498
+ @see {@link AllExtend}
499
+ */
500
+ type AllExtendOptions = {
501
+ /**
502
+ Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
503
+ - 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`).
504
+ - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
505
+ @default true
506
+ @example
507
+ ```
508
+ import type {AllExtend} from 'type-fest';
509
+ type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
510
+ //=> false
511
+ type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
512
+ //=> true
513
+ type C = AllExtend<[never, never], never, {strictNever: true}>;
514
+ //=> true
515
+ type D = AllExtend<[never, never], never, {strictNever: false}>;
516
+ //=> true
517
+ type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
518
+ //=> true
519
+ type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
520
+ //=> true
521
+ type G = AllExtend<[never, 1], never, {strictNever: true}>;
522
+ //=> false
523
+ type H = AllExtend<[never, 1], never, {strictNever: false}>;
524
+ //=> false
525
+ ```
526
+ */
527
+ strictNever?: boolean;
914
528
  };
915
-
916
- type Bar = {
917
- [x: number]: number;
918
- [x: symbol]: unknown;
919
- bar: Date;
920
- baz: boolean;
529
+ type DefaultAllExtendOptions = {
530
+ strictNever: true;
921
531
  };
922
532
 
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
533
  /**
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.
534
+ Returns a boolean for whether every element in an array type extends another type.
945
535
 
946
536
  @example
947
537
  ```
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
- };
959
-
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}
538
+ import type {AllExtend} from 'type-fest';
963
539
 
964
- // Primitive types are returned as-is
965
- type Primitive = HomomorphicPick<string | number, 'toUpperCase' | 'toString'>;
966
- //=> string | number
540
+ type A = AllExtend<[1, 2, 3], number>;
541
+ //=> true
967
542
 
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}
543
+ type B = AllExtend<[1, 2, '3'], number>;
544
+ //=> false
971
545
 
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.
546
+ type C = AllExtend<[number, number | string], number>;
547
+ //=> boolean
979
548
 
980
- @example
549
+ type D = AllExtend<[true, boolean, true], true>;
550
+ //=> boolean
981
551
  ```
982
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
983
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
984
- type SpecifiedOptions = {leavesOnly: true};
985
552
 
986
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
987
- //=> {maxRecursionDepth: 10; leavesOnly: true}
988
- ```
553
+ 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
554
 
990
- @example
991
555
  ```
992
- // Complains if default values are not provided for optional options
556
+ // @exactOptionalPropertyTypes: true
557
+ import type {AllExtend} from 'type-fest';
993
558
 
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; }'.
559
+ type A = AllExtend<[1?, 2?, 3?], number>;
560
+ //=> true
1001
561
  ```
1002
562
 
1003
- @example
1004
563
  ```
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 = {};
564
+ // @exactOptionalPropertyTypes: false
565
+ import type {AllExtend} from 'type-fest';
1010
566
 
1011
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1012
- // ~~~~~~~~~~~~~~~~~~~
1013
- // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
1014
- ```
567
+ type A = AllExtend<[1?, 2?, 3?], number>;
568
+ //=> boolean
1015
569
 
1016
- @example
570
+ type B = AllExtend<[1?, 2?, 3?], number | undefined>;
571
+ //=> true
1017
572
  ```
1018
- // Complains if an option's specified type does not conform to the expected type
1019
573
 
1020
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1021
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
1022
- type SpecifiedOptions = {leavesOnly: 'yes'};
574
+ @see {@link AllExtendOptions}
1023
575
 
1024
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1025
- // ~~~~~~~~~~~~~~~~
1026
- // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
1027
- ```
576
+ @category Utilities
577
+ @category Array
1028
578
  */
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>>>>;
579
+ type AllExtend<TArray extends UnknownArray, Type$1, Options extends AllExtendOptions = {}> = _AllExtend<CollapseRestElement<TArray>, Type$1, ApplyDefaultOptions<AllExtendOptions, DefaultAllExtendOptions, Options>>;
580
+ 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
581
+ // If target `Type` is also `never` OR `strictNever` is disabled, recurse further.
582
+ ? _AllExtend<Rest, Type$1, Options> : false : First extends Type$1 ? _AllExtend<Rest, Type$1, Options> : false : true>, false, false>;
1030
583
  //#endregion
1031
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/except.d.ts
584
+ //#region node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/and.d.ts
1032
585
  /**
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
- ```
586
+ Returns a boolean for whether two given types are both true.
1044
587
 
1045
- @example
1046
- ```
1047
- type Filtered = Filter<'bar', string>;
1048
- //=> never
1049
- ```
588
+ Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
1050
589
 
1051
590
  @example
1052
591
  ```
1053
- type Filtered = Filter<'bar', 'foo'>;
1054
- //=> 'bar'
1055
- ```
592
+ import type {And} from 'type-fest';
1056
593
 
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
- };
594
+ type TT = And<true, true>;
595
+ //=> true
1071
596
 
1072
- /**
1073
- Create a type from an object type without certain keys.
597
+ type TF = And<true, false>;
598
+ //=> false
1074
599
 
1075
- We recommend setting the `requireExactProps` option to `true`.
600
+ type FT = And<false, true>;
601
+ //=> false
1076
602
 
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.
603
+ type FF = And<false, false>;
604
+ //=> false
605
+ ```
1078
606
 
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)).
607
+ Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
608
+ For example, `And<true, boolean>` expands to `And<true, true> | And<true, false>`, which simplifies to `true | false` (i.e., `boolean`).
1080
609
 
1081
610
  @example
1082
611
  ```
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; }'
1096
-
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'.
612
+ import type {And} from 'type-fest';
1103
613
 
1104
- // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
614
+ type A = And<true, boolean>;
615
+ //=> boolean
1105
616
 
1106
- // Consider the following example:
617
+ type B = And<boolean, true>;
618
+ //=> boolean
1107
619
 
1108
- type UserData = {
1109
- [metadata: string]: string;
1110
- email: string;
1111
- name: string;
1112
- role: 'admin' | 'user';
1113
- };
620
+ type C = And<false, boolean>;
621
+ //=> false
1114
622
 
1115
- // `Omit` clearly doesn't behave as expected in this case:
1116
- type PostPayload = Omit<UserData, 'email'>;
1117
- //=> { [x: string]: string; [x: number]: string; }
623
+ type D = And<boolean, false>;
624
+ //=> false
1118
625
 
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'; }
626
+ type E = And<boolean, boolean>;
627
+ //=> boolean
1123
628
  ```
1124
629
 
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.
630
+ Note: If either of the types is `never`, the result becomes `false`.
1133
631
 
1134
632
  @example
1135
633
  ```
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
- ```
634
+ import type {And} from 'type-fest';
1149
635
 
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.
636
+ type A = And<true, never>;
637
+ //=> false
1165
638
 
1166
- This is useful when you need an object where all keys are optional, but there must be at least 1 key.
639
+ type B = And<never, true>;
640
+ //=> false
1167
641
 
1168
- @example
1169
- ```
1170
- import type {NonEmptyObject} from 'type-fest';
642
+ type C = And<false, never>;
643
+ //=> false
1171
644
 
1172
- type User = {
1173
- name: string;
1174
- surname: string;
1175
- id: number;
1176
- };
645
+ type D = And<never, false>;
646
+ //=> false
1177
647
 
1178
- type UpdateRequest<Entity extends object> = NonEmptyObject<Partial<Entity>>;
648
+ type E = And<boolean, never>;
649
+ //=> false
1179
650
 
1180
- const update1: UpdateRequest<User> = {
1181
- name: 'Alice',
1182
- surname: 'Acme',
1183
- };
651
+ type F = And<never, boolean>;
652
+ //=> false
1184
653
 
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> = {};
654
+ type G = And<never, never>;
655
+ //=> false
1189
656
  ```
1190
657
 
1191
- @see Use `IsEmptyObject` to check whether an object is empty.
1192
-
1193
- @category Object
658
+ @see {@link Or}
659
+ @see {@link Xor}
1194
660
  */
1195
- type NonEmptyObject<T extends object> = HasRequiredKeys<T> extends true ? T : RequireAtLeastOne<T, keyof T>;
661
+ type And<A$1 extends boolean, B$1 extends boolean> = AllExtend<[A$1, B$1], true>;
1196
662
  //#endregion
1197
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/union-to-tuple.d.ts
663
+ //#region node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/union-to-tuple.d.ts
1198
664
  /**
1199
665
  Returns the last element of a union type.
1200
666
 
@@ -1243,7 +709,7 @@ const petList = Object.keys(pets) as UnionToTuple<Pet>;
1243
709
  */
1244
710
  type UnionToTuple<T, L = LastOfUnion<T>> = IsNever<T> extends false ? [...UnionToTuple<Exclude<T, L>>, L] : [];
1245
711
  //#endregion
1246
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/set-optional.d.ts
712
+ //#region node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/set-optional.d.ts
1247
713
  /**
1248
714
  Create a type that makes the given keys optional. The remaining keys are kept as is. The sister of the `SetRequired` type.
1249
715
 
@@ -1277,7 +743,7 @@ Except<BaseType, Keys> &
1277
743
  // Pick the keys that should be mutable from the base type and make them mutable.
1278
744
  Partial<HomomorphicPick<BaseType, Keys>>> : never;
1279
745
  //#endregion
1280
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/value-of.d.ts
746
+ //#region node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/value-of.d.ts
1281
747
  /**
1282
748
  Create a union of the given object's values, and optionally specify which keys to get the values from.
1283
749
 
@@ -1288,20 +754,79 @@ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31438)
1288
754
  import type {ValueOf} from 'type-fest';
1289
755
 
1290
756
  type A = ValueOf<{id: number; name: string; active: boolean}>;
1291
- //=> number | string | boolean
757
+ //=> string | number | boolean
1292
758
 
1293
759
  type B = ValueOf<{id: number; name: string; active: boolean}, 'name'>;
1294
760
  //=> string
1295
761
 
1296
762
  type C = ValueOf<{id: number; name: string; active: boolean}, 'id' | 'name'>;
1297
- //=> number | string
763
+ //=> string | number
1298
764
  ```
1299
765
 
1300
766
  @category Object
1301
767
  */
1302
768
  type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
1303
769
  //#endregion
1304
- //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/replace.d.ts
770
+ //#region node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/split.d.ts
771
+ /**
772
+ Split options.
773
+
774
+ @see {@link Split}
775
+ */
776
+ type SplitOptions = {
777
+ /**
778
+ 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.
779
+ @default true
780
+ @example
781
+ ```ts
782
+ import type {Split} from 'type-fest';
783
+ type Example1 = Split<`foo.${string}.bar`, '.', {strictLiteralChecks: false}>;
784
+ //=> ['foo', string, 'bar']
785
+ type Example2 = Split<`foo.${string}`, '.', {strictLiteralChecks: true}>;
786
+ //=> string[]
787
+ type Example3 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: false}>;
788
+ //=> ['foo', 'r', 'z']
789
+ type Example4 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: true}>;
790
+ //=> string[]
791
+ ```
792
+ */
793
+ strictLiteralChecks?: boolean;
794
+ };
795
+ type DefaultSplitOptions = {
796
+ strictLiteralChecks: true;
797
+ };
798
+
799
+ /**
800
+ Represents an array of strings split using a given character or character set.
801
+
802
+ Use-case: Defining the return type of a method like `String.prototype.split`.
803
+
804
+ @example
805
+ ```
806
+ import type {Split} from 'type-fest';
807
+
808
+ declare function split<S extends string, D extends string>(string: S, separator: D): Split<S, D>;
809
+
810
+ type Item = 'foo' | 'bar' | 'baz' | 'waldo';
811
+ const items = 'foo,bar,baz,waldo';
812
+ const array: Item[] = split(items, ',');
813
+ ```
814
+
815
+ @see {@link SplitOptions}
816
+
817
+ @category String
818
+ @category Template literal
819
+ */
820
+ type Split<S extends string, Delimiter extends string, Options extends SplitOptions = {}> = SplitHelper<S, Delimiter, ApplyDefaultOptions<SplitOptions, DefaultSplitOptions, Options>>;
821
+ type SplitHelper<S extends string, Delimiter extends string, Options extends Required<SplitOptions>, Accumulator extends string[] = []> = S extends string // For distributing `S`
822
+ ? Delimiter extends string // For distributing `Delimiter`
823
+ // If `strictLiteralChecks` is `false` OR `S` and `Delimiter` both are string literals, then perform the split
824
+ ? 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]
825
+ // Otherwise, return `string[]`
826
+ : string[] : never // Should never happen
827
+ : never; // Should never happen
828
+ //#endregion
829
+ //#region node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/replace.d.ts
1305
830
  type ReplaceOptions = {
1306
831
  all?: boolean;
1307
832
  };
@@ -1310,92 +835,541 @@ type DefaultReplaceOptions = {
1310
835
  };
1311
836
 
1312
837
  /**
1313
- Represents a string with some or all matches replaced by a replacement.
1314
-
1315
- Use-case:
1316
- - `kebab-case-path` to `dotted.path.notation`
1317
- - Changing date/time format: `01-08-2042` → `01/08/2042`
1318
- - Manipulation of type properties, for example, removal of prefixes
1319
-
1320
- @example
1321
- ```
1322
- import type {Replace} from 'type-fest';
1323
-
1324
- declare function replace<
1325
- Input extends string,
1326
- Search extends string,
1327
- Replacement extends string,
1328
- >(
1329
- input: Input,
1330
- search: Search,
1331
- replacement: Replacement
1332
- ): Replace<Input, Search, Replacement>;
1333
-
1334
- declare function replaceAll<
1335
- Input extends string,
1336
- Search extends string,
1337
- Replacement extends string,
1338
- >(
1339
- input: Input,
1340
- search: Search,
1341
- replacement: Replacement
1342
- ): Replace<Input, Search, Replacement, {all: true}>;
1343
-
1344
- // The return type is the exact string literal, not just `string`.
1345
-
1346
- replace('hello ?', '?', '🦄');
1347
- //=> 'hello 🦄'
1348
-
1349
- replace('hello ??', '?', '❓');
1350
- //=> 'hello ❓?'
1351
-
1352
- replaceAll('10:42:00', ':', '-');
1353
- //=> '10-42-00'
1354
-
1355
- replaceAll('__userName__', '__', '');
1356
- //=> 'userName'
1357
-
1358
- replaceAll('My Cool Title', ' ', '');
1359
- //=> 'MyCoolTitle'
1360
- ```
1361
-
1362
- @category String
1363
- @category Template literal
1364
- */
1365
- type Replace<Input extends string, Search extends string, Replacement extends string, Options extends ReplaceOptions = {}> = _Replace<Input, Search, Replacement, ApplyDefaultOptions<ReplaceOptions, DefaultReplaceOptions, Options>>;
1366
- type _Replace<Input extends string, Search extends string, Replacement extends string, Options extends Required<ReplaceOptions>, Accumulator extends string = ''> = Search extends string // For distributing `Search`
1367
- ? Replacement extends string // For distributing `Replacement`
1368
- ? 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;
838
+ Represents a string with some or all matches replaced by a replacement.
839
+
840
+ Use-case:
841
+ - `kebab-case-path` to `dotted.path.notation`
842
+ - Changing date/time format: `01-08-2042` → `01/08/2042`
843
+ - Manipulation of type properties, for example, removal of prefixes
844
+
845
+ @example
846
+ ```
847
+ import type {Replace} from 'type-fest';
848
+
849
+ declare function replace<
850
+ Input extends string,
851
+ Search extends string,
852
+ Replacement extends string,
853
+ >(
854
+ input: Input,
855
+ search: Search,
856
+ replacement: Replacement
857
+ ): Replace<Input, Search, Replacement>;
858
+
859
+ declare function replaceAll<
860
+ Input extends string,
861
+ Search extends string,
862
+ Replacement extends string,
863
+ >(
864
+ input: Input,
865
+ search: Search,
866
+ replacement: Replacement
867
+ ): Replace<Input, Search, Replacement, {all: true}>;
868
+
869
+ // The return type is the exact string literal, not just `string`.
870
+
871
+ replace('hello ?', '?', '🦄');
872
+ //=> 'hello 🦄'
873
+
874
+ replace('hello ??', '?', '❓');
875
+ //=> 'hello ❓?'
876
+
877
+ replaceAll('10:42:00', ':', '-');
878
+ //=> '10-42-00'
879
+
880
+ replaceAll('__userName__', '__', '');
881
+ //=> 'userName'
882
+
883
+ replaceAll('My Cool Title', ' ', '');
884
+ //=> 'MyCoolTitle'
885
+ ```
886
+
887
+ @category String
888
+ @category Template literal
889
+ */
890
+ type Replace<Input extends string, Search extends string, Replacement extends string, Options extends ReplaceOptions = {}> = _Replace<Input, Search, Replacement, ApplyDefaultOptions<ReplaceOptions, DefaultReplaceOptions, Options>>;
891
+ type _Replace<Input extends string, Search extends string, Replacement extends string, Options extends Required<ReplaceOptions>, Accumulator extends string = ''> = Search extends string // For distributing `Search`
892
+ ? Replacement extends string // For distributing `Replacement`
893
+ ? 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;
894
+ //#endregion
895
+ //#region src/utils/array/arrayCast.d.ts
896
+ /**
897
+ * 构造数组
898
+ * @param candidate 待构造项
899
+ * @param checkEmpty 是否检查 `undefined` 和 `null`,默认为 `true`
900
+ * @returns 构造后的数组
901
+ * @example
902
+ * ```ts
903
+ * arrayCast(1); // [1]
904
+ * arrayCast([1, 2]); // [1, 2]
905
+ * arrayCast(null); // []
906
+ * arrayCast(undefined); // []
907
+ * arrayCast(null, false); // [null]
908
+ * ```
909
+ */
910
+ declare function arrayCast<T>(candidate: T | T[] | null | undefined, checkEmpty?: true): NonNullable<T>[];
911
+ declare function arrayCast<T>(candidate: T | T[] | null | undefined, checkEmpty?: false): T[];
912
+ //#endregion
913
+ //#region src/utils/array/arrayCompete.d.ts
914
+ /**
915
+ * 数组竞争
916
+ * - 返回在匹配函数的比较条件中获胜的最终项目,适用于更复杂的最小值/最大值计算
917
+ *
918
+ * @param initialList 数组
919
+ * @param match 匹配函数
920
+ * @returns 获胜的元素,如果数组为空或参数无效则返回 `null`
921
+ * @example
922
+ * ```ts
923
+ * const list = [1, 10, 5];
924
+ * arrayCompete(list, (a, b) => (a > b ? a : b)); // 10
925
+ * arrayCompete(list, (a, b) => (a < b ? a : b)); // 1
926
+ * ```
927
+ */
928
+ declare function arrayCompete<T>(initialList: readonly T[], match: (a: T, b: T) => T): T | null;
929
+ //#endregion
930
+ //#region src/utils/array/arrayCounting.d.ts
931
+ /**
932
+ * 统计数组的项目出现次数
933
+ * - 通过给定的标识符匹配函数,返回一个对象,其中键是回调函数返回的 key 值,每个值是一个整数,表示该 key 出现的次数
934
+ *
935
+ * @param initialList 初始数组
936
+ * @param match 匹配函数
937
+ * @returns 统计对象
938
+ * @example
939
+ * ```ts
940
+ * const list = ["a", "b", "a", "c"];
941
+ * arrayCounting(list, (x) => x); // { a: 2, b: 1, c: 1 }
942
+ *
943
+ * const users = [{ id: 1, group: "A" }, { id: 2, group: "B" }, { id: 3, group: "A" }];
944
+ * arrayCounting(users, (u) => u.group); // { A: 2, B: 1 }
945
+ * ```
946
+ */
947
+ declare function arrayCounting<T, K$1 extends PropertyKey>(initialList: readonly T[], match: (row: T) => K$1): Record<string, number>;
948
+ //#endregion
949
+ //#region src/utils/array/arrayDifference.d.ts
950
+ /**
951
+ * 求数组差集
952
+ * - 返回在 `initialList` 中存在,但在 `diffList` 中不存在的元素
953
+ *
954
+ * @param initialList 初始数组
955
+ * @param diffList 对比数组
956
+ * @param match 匹配函数
957
+ * @returns 差集数组
958
+ * @example
959
+ * ```ts
960
+ * arrayDifference([1, 2, 3], [2, 3, 4]); // [1]
961
+ * arrayDifference([{ id: 1 }, { id: 2 }], [{ id: 2 }], (x) => x.id); // [{ id: 1 }]
962
+ * ```
963
+ */
964
+ declare function arrayDifference<T>(initialList: readonly T[], diffList: readonly T[], match?: (row: T) => unknown): T[];
965
+ //#endregion
966
+ //#region src/utils/array/arrayFirst.d.ts
967
+ /**
968
+ * 获取数组第一项
969
+ *
970
+ * @param initialList 初始数组
971
+ * @param saveValue 安全值
972
+ * @returns 数组第一项,如果为空则返回安全值
973
+ * @example
974
+ * ```ts
975
+ * arrayFirst([1, 2]); // 1
976
+ * arrayFirst([], 0); // 0
977
+ * ```
978
+ */
979
+ declare function arrayFirst<T>(initialList: readonly T[]): T | undefined;
980
+ declare function arrayFirst<T>(initialList: readonly T[], saveValue: T): T;
981
+ //#endregion
982
+ //#region src/utils/array/arrayFork.d.ts
983
+ /**
984
+ * 数组分组过滤
985
+ * - 给定一个数组和一个条件,返回一个由两个数组组成的元组,其中第一个数组包含所有满足条件的项,第二个数组包含所有不满足条件的项
986
+ *
987
+ * @param initialList 初始数组
988
+ * @param match 条件匹配函数
989
+ * @returns [满足条件的项[], 不满足条件的项[]]
990
+ * @example
991
+ * ```ts
992
+ * arrayFork([1, 2, 3, 4], (n) => n % 2 === 0); // [[2, 4], [1, 3]]
993
+ * ```
994
+ */
995
+ declare function arrayFork<T>(initialList: readonly T[], match: (item: T) => boolean): [T[], T[]];
996
+ //#endregion
997
+ //#region src/utils/array/arrayIntersection.d.ts
998
+ /**
999
+ * 求数组交集
1000
+ * - 返回在 `initialList` 和 `diffList` 中都存在的元素
1001
+ *
1002
+ * @param initialList 初始数组
1003
+ * @param diffList 对比数组
1004
+ * @param match 匹配函数
1005
+ * @returns 交集数组
1006
+ * @example
1007
+ * ```ts
1008
+ * arrayIntersection([1, 2], [2, 3]); // [2]
1009
+ * arrayIntersection([{ id: 1 }, { id: 2 }], [{ id: 2 }], (x) => x.id); // [{ id: 2 }]
1010
+ * ```
1011
+ */
1012
+ declare function arrayIntersection<T>(initialList: readonly T[], diffList: readonly T[], match?: (row: T) => unknown): T[];
1013
+ //#endregion
1014
+ //#region src/utils/array/arrayLast.d.ts
1015
+ /**
1016
+ * 获取数组最后一项
1017
+ *
1018
+ * @param initialList 初始数组
1019
+ * @param saveValue 安全值
1020
+ * @returns 数组最后一项,如果为空则返回安全值
1021
+ * @example
1022
+ * ```ts
1023
+ * arrayLast([1, 2, 3]); // 3
1024
+ * arrayLast([], 0); // 0
1025
+ * ```
1026
+ */
1027
+ declare function arrayLast<T>(initialList: readonly T[]): T | undefined;
1028
+ declare function arrayLast<T>(initialList: readonly T[], saveValue: T): T;
1029
+ //#endregion
1030
+ //#region src/utils/array/arrayMerge.d.ts
1031
+ /**
1032
+ * 数组合并
1033
+ * - 如果未提供 `match` 函数,则合并两个数组并去重(Union)
1034
+ * - 如果提供了 `match` 函数,则仅更新 `initialList` 中匹配到的项(Left Join Update),不会追加 `mergeList` 中新增的项
1035
+ *
1036
+ * @param initialList 初始数组
1037
+ * @param mergeList 待合并数组
1038
+ * @param match 匹配函数
1039
+ * @returns 合并后的数组
1040
+ * @example
1041
+ * ```ts
1042
+ * // 基础合并去重
1043
+ * arrayMerge([1, 2], [2, 3]); // [1, 2, 3]
1044
+ *
1045
+ * // 按条件更新
1046
+ * const source = [{ id: 1, val: "a" }, { id: 2, val: "b" }];
1047
+ * const update = [{ id: 2, val: "new" }, { id: 3, val: "c" }];
1048
+ * arrayMerge(source, update, (x) => x.id);
1049
+ * // [{ id: 1, val: "a" }, { id: 2, val: "new" }] -> id:3 被忽略
1050
+ * ```
1051
+ */
1052
+ declare function arrayMerge<T>(initialList: readonly T[], mergeList: readonly T[], match?: (item: T) => unknown): T[];
1053
+ //#endregion
1054
+ //#region src/utils/array/arrayPick.d.ts
1055
+ /**
1056
+ * 数组选择
1057
+ * - 一次性应用 `filter` 和 `map` 操作
1058
+ *
1059
+ * @param initialList 初始数组
1060
+ * @param filter filter 函数
1061
+ * @param mapper map 函数
1062
+ * @returns 处理后的新数组
1063
+ * @example
1064
+ * ```ts
1065
+ * const list = [1, 2, 3, 4];
1066
+ * arrayPick(list, (n) => n % 2 === 0); // [2, 4]
1067
+ * arrayPick(list, (n) => n % 2 === 0, (n) => n * 2); // [4, 8]
1068
+ * ```
1069
+ */
1070
+ declare function arrayPick<const T>(initialList: readonly T[], filter: (row: T, index: number) => boolean): T[];
1071
+ 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[];
1072
+ //#endregion
1073
+ //#region src/utils/array/arrayReplace.d.ts
1074
+ /**
1075
+ * 数组项替换
1076
+ * - 在给定的数组中,替换符合匹配函数结果的项目。只替换第一个匹配项。始终返回原始数组的副本。
1077
+ *
1078
+ * @param initialList 初始数组
1079
+ * @param newItem 替换项
1080
+ * @param match 匹配函数
1081
+ * @returns 替换后的新数组
1082
+ * @example
1083
+ * ```ts
1084
+ * arrayReplace([1, 2, 3], 4, (n) => n === 2); // [1, 4, 3]
1085
+ * ```
1086
+ */
1087
+ declare function arrayReplace<T>(initialList: readonly T[], newItem: T, match: (row: T, index: number) => boolean): T[];
1088
+ //#endregion
1089
+ //#region src/utils/array/arraySplit.d.ts
1090
+ /**
1091
+ * 数组切分
1092
+ * - 将数组以指定的长度切分后,组合在高维数组中
1093
+ *
1094
+ * @param initialList 初始数组
1095
+ * @param size 分割尺寸,默认 `10`
1096
+ * @returns 切分后的二维数组
1097
+ * @example
1098
+ * ```ts
1099
+ * arraySplit([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
1100
+ * ```
1101
+ */
1102
+ declare function arraySplit<T>(initialList: readonly T[], size?: number): T[][];
1103
+ //#endregion
1104
+ //#region src/utils/array/arrayZip.d.ts
1105
+ /**
1106
+ * 数组解压
1107
+ * - `arrayZip` 的反向操作
1108
+ *
1109
+ * @param arrays 压缩后的数组
1110
+ * @returns 解压后的二维数组
1111
+ * @example
1112
+ * ```ts
1113
+ * arrayUnzip([[1, "a"], [2, "b"]]); // [[1, 2], ["a", "b"]]
1114
+ * ```
1115
+ */
1116
+ declare function arrayUnzip<T>(arrays: readonly (readonly T[])[]): T[][];
1117
+ /**
1118
+ * 数组压缩
1119
+ * - 将多个数组的元素按索引组合成元组
1120
+ *
1121
+ * @param arrays 多个数组
1122
+ * @returns 压缩后的元组数组
1123
+ * @example
1124
+ * ```ts
1125
+ * arrayZip([1, 2], ["a", "b"]); // [[1, "a"], [2, "b"]]
1126
+ * ```
1127
+ */
1128
+ 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][];
1129
+ declare function arrayZip<T1, T2, T3, T4>(array1: readonly T1[], array2: readonly T2[], array3: readonly T3[], array4: readonly T4[]): [T1, T2, T3, T4][];
1130
+ declare function arrayZip<T1, T2, T3>(array1: readonly T1[], array2: readonly T2[], array3: readonly T3[]): [T1, T2, T3][];
1131
+ declare function arrayZip<T1, T2>(array1: readonly T1[], array2: readonly T2[]): [T1, T2][];
1132
+ declare function arrayZip(): [];
1133
+ //#endregion
1134
+ //#region src/utils/array/arrayZipToObject.d.ts
1135
+ /**
1136
+ * 数组压缩为对象
1137
+ * - 将键数组和值(数组、函数或静态值)组合成对象
1138
+ *
1139
+ * @param keys 键数组
1140
+ * @param values 值数组、生成值的函数或静态值
1141
+ * @returns 生成的对象
1142
+ * @example
1143
+ * ```ts
1144
+ * arrayZipToObject(["a", "b"], [1, 2]); // { a: 1, b: 2 }
1145
+ * arrayZipToObject(["a", "b"], (k, i) => k + i); // { a: "a0", b: "b1" }
1146
+ * arrayZipToObject(["a", "b"], 1); // { a: 1, b: 1 }
1147
+ * ```
1148
+ */
1149
+ declare function arrayZipToObject<const K$1 extends PropertyKey, const V$1>(keys: readonly K$1[], array: readonly V$1[]): Record<K$1, V$1>;
1150
+ declare function arrayZipToObject<const K$1 extends PropertyKey, const V$1>(keys: readonly K$1[], match: ((key: K$1, index: number) => V$1)): Record<K$1, V$1>;
1151
+ declare function arrayZipToObject<const K$1 extends PropertyKey, const V$1>(keys: readonly K$1[], value: V$1): Record<K$1, V$1>;
1152
+ //#endregion
1153
+ //#region src/utils/device/isMobile.d.ts
1154
+ /**
1155
+ * 检测当前设备是否为移动设备
1156
+ *
1157
+ * @param maxWidth - 移动设备最大宽度(默认 768px)
1158
+ * @param dpi - 标准 DPI 基准(默认 160)
1159
+ * @returns 是否为移动设备
1160
+ * @example
1161
+ * ```ts
1162
+ * // 假设 window.innerWidth = 500
1163
+ * isMobile(); // true
1164
+ * ```
1165
+ */
1166
+ declare function isMobile(maxWidth?: number, dpi?: number): boolean;
1167
+ /**
1168
+ * 检测当前设备是否为IOS移动设备
1169
+ *
1170
+ * @param maxWidth - 移动设备最大宽度(默认 768px)
1171
+ * @param dpi - 标准 DPI 基准(默认 160)
1172
+ * @returns 是否为 iOS 移动设备 (iPhone/iPad/iPod 且非平板)
1173
+ * @example
1174
+ * ```ts
1175
+ * // UA contains iPhone
1176
+ * isIOSMobile(); // true
1177
+ * ```
1178
+ */
1179
+ declare function isIOSMobile(maxWidth?: number, dpi?: number): boolean;
1180
+ //#endregion
1181
+ //#region src/utils/device/isTablet.d.ts
1182
+ /**
1183
+ * 检测当前设备是否为平板
1184
+ *
1185
+ * @param minWidth - 平板最小宽度(默认 768px)
1186
+ * @param maxWidth - 平板最大宽度(默认 1200px)
1187
+ * @param dpi - 标准 DPI 基准(默认 160)
1188
+ * @returns 是否为平板设备
1189
+ * @example
1190
+ * ```ts
1191
+ * // 假设 window.innerWidth = 1000
1192
+ * isTablet(); // true
1193
+ * ```
1194
+ */
1195
+ declare function isTablet(minWidth?: number, maxWidth?: number, dpi?: number): boolean;
1196
+ //#endregion
1197
+ //#region src/utils/function/to.d.ts
1198
+ /**
1199
+ *将 Promise 转换为 `[err, result]` 格式,方便 async/await 错误处理
1200
+ *
1201
+ * @param promise 待处理的 Promise
1202
+ * @param errorExt 附加到 error 对象的扩展信息(注意:如果原 error 是 Error 实例,扩展属性可能会覆盖或无法正确合并非枚举属性)
1203
+ * @returns `[err, null]` 或 `[null, data]`
1204
+ * @example
1205
+ * ```ts
1206
+ * const [err, data] = await to(someAsyncFunc());
1207
+ * if (err) return;
1208
+ * console.log(data);
1209
+ * ```
1210
+ */
1211
+ declare function to<T, U$1 = Error>(promise: Readonly<Promise<T>>, errorExt?: PlainObject): Promise<[U$1, undefined] | [null, T]>;
1212
+ //#endregion
1213
+ //#region src/utils/math/toMathBignumber.d.ts
1214
+ /**
1215
+ * 将任意类型的值转换为 `math.bignumber`
1216
+ *
1217
+ * @param mathJsInstance mathJs 实例
1218
+ * @param value 任意类型的值
1219
+ * @param saveValue 安全值
1220
+ * @returns 转换后的 BigNumber
1221
+ * @example
1222
+ * ```ts
1223
+ * import { create, all } from "mathjs";
1224
+ * const math = create(all);
1225
+ * toMathBignumber(math, "0.1");
1226
+ * ```
1227
+ */
1228
+ declare function toMathBignumber(mathJsInstance: MathJsInstance, value: unknown, saveValue?: BigNumber | undefined): BigNumber;
1229
+ //#endregion
1230
+ //#region src/utils/math/toMathDecimal.d.ts
1231
+ /**
1232
+ * 将任意类型的值转换为十进制数字字符串
1233
+ *
1234
+ * @param mathJsInstance mathJs 实例
1235
+ * @param value 任意类型的值
1236
+ * @param precision 精度
1237
+ * @param isFormat 是否格式化为字符串
1238
+ * @returns 格式化后的字符串或 BigNumber
1239
+ * @example
1240
+ * ```ts
1241
+ * toMathDecimal(math, 0.12345, 2); // "0.12"
1242
+ * ```
1243
+ */
1244
+ declare function toMathDecimal(mathJsInstance: MathJsInstance, value: unknown, precision?: number | undefined, isFormat?: true): string;
1245
+ declare function toMathDecimal(mathJsInstance: MathJsInstance, value: unknown, precision?: number | undefined, isFormat?: false): BigNumber;
1246
+ //#endregion
1247
+ //#region src/utils/math/toMathEvaluate.d.ts
1248
+ /**
1249
+ * 数学表达式求值
1250
+ *
1251
+ * @param mathJsInstance mathJs 实例
1252
+ * @param expr 表达式
1253
+ * @param scope 键值映射
1254
+ * @returns 计算结果的字符串表示
1255
+ * @example
1256
+ * ```ts
1257
+ * toMathEvaluate(math, "a + b", { a: 1, b: 2 }); // "3"
1258
+ * ```
1259
+ */
1260
+ declare function toMathEvaluate(mathJsInstance: MathJsInstance, expr: MathExpression | Matrix, scope?: Record<string, BigNumber>): string;
1261
+ //#endregion
1262
+ //#region src/utils/number/isWithinInterval.d.ts
1263
+ /**
1264
+ * 数字区间检查函数
1265
+ *
1266
+ * @param input 待检查数字
1267
+ * @param interval 由两个数字组成的元组 [left, right]
1268
+ * @param includeLeft 是否包含左边界(默认 true)
1269
+ * @param includeRight 是否包含右边界(默认 false)
1270
+ * @returns 是否在区间内
1271
+ * @example
1272
+ * ```ts
1273
+ * isWithinInterval(5, [1, 10]); // true
1274
+ * isWithinInterval(1, [1, 10], false); // false
1275
+ * ```
1276
+ */
1277
+ declare function isWithinInterval(input: number, interval: [number, number], includeLeft?: boolean, includeRight?: boolean): boolean;
1278
+ //#endregion
1279
+ //#region src/utils/object/cloneDeep.d.ts
1280
+ interface CloningStrategy {
1281
+ cloneMap: typeof cloneMap;
1282
+ cloneSet: typeof cloneSet;
1283
+ cloneDate: typeof cloneDate;
1284
+ cloneArray: typeof cloneArray;
1285
+ cloneObject: typeof cloneObject;
1286
+ cloneOther: typeof cloneOther;
1287
+ }
1288
+ declare function cloneMap<K$1, V$1>(input: Map<K$1, V$1>, track: (newParent: Map<K$1, V$1>) => Map<K$1, V$1>, clone: <T>(value: T) => T): Map<K$1, V$1>;
1289
+ declare function cloneSet<T>(input: Set<T>, track: (newParent: Set<T>) => Set<T>, clone: <T>(value: T) => T): Set<T>;
1290
+ declare function cloneDate(input: Date, track: (newParent: Date) => Date): Date;
1291
+ declare function cloneArray<T>(input: readonly T[], track: (newParent: T[]) => T[], clone: <T>(value: T) => T): T[];
1292
+ declare function cloneObject<T extends AnyObject>(input: T, track: (newParent: T) => T, clone: <T>(value: T) => T): T;
1293
+ declare function cloneOther<T>(input: T, track: (newParent: T) => T): T;
1294
+ /**
1295
+ * 深度拷贝对象
1296
+ * - 支持 Array, Object, Map, Set
1297
+ * - 自动处理循环引用
1298
+ *
1299
+ * @param root 需要拷贝的对象
1300
+ * @param customStrategy 自定义拷贝策略
1301
+ * @returns 拷贝后的对象
1302
+ * @example
1303
+ * ```ts
1304
+ * const original = { a: 1, b: { c: 2 } };
1305
+ * const copy = cloneDeep(original);
1306
+ * copy.b.c = 3;
1307
+ * // original.b.c === 2
1308
+ * ```
1309
+ * @reference https://github.com/radashi-org/radashi/blob/main/src/object/cloneDeep.ts
1310
+ */
1311
+ declare function cloneDeep<T extends AnyObject>(root: T, customStrategy?: Partial<CloningStrategy>): T;
1369
1312
  //#endregion
1370
1313
  //#region src/utils/object/enumEntries.d.ts
1371
1314
  /**
1372
1315
  * 返回枚举的属性的键/值数组
1373
1316
  *
1374
- * @param enumeration 枚举
1317
+ * @param enumeration 枚举对象
1318
+ * @returns 键值对数组
1319
+ * @example
1320
+ * ```ts
1321
+ * enum A { k = "v" }
1322
+ * enumEntries(A); // [["k", "v"]]
1323
+ * ```
1375
1324
  */
1376
- declare function enumEntries<E extends AnyObject>(enumeration: NonEmptyObject<E>): [keyof E, E[keyof E]][];
1325
+ declare function enumEntries<E extends PlainObject>(enumeration: E): [keyof E, E[keyof E]][];
1326
+ declare function enumEntries<E extends AnyObject>(enumeration: E): [keyof E, E[keyof E]][];
1377
1327
  //#endregion
1378
1328
  //#region src/utils/object/enumKeys.d.ts
1379
1329
  /**
1380
1330
  * 获取枚举所有属性的键
1381
1331
  *
1382
- * @param enumeration 枚举
1332
+ * @param enumeration 枚举对象
1333
+ * @returns 键数组
1334
+ * @example
1335
+ * ```ts
1336
+ * enum A { k = "v" }
1337
+ * enumKeys(A); // ["k"]
1338
+ * ```
1383
1339
  */
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>;
1340
+ declare function enumKeys<E extends PlainObject>(enumeration: E): (keyof E)[];
1341
+ declare function enumKeys<E extends AnyObject>(enumeration: E): (keyof E)[];
1388
1342
  //#endregion
1389
1343
  //#region src/utils/object/enumValues.d.ts
1390
1344
  /**
1391
1345
  * 获取枚举所有属性的值
1392
1346
  *
1393
- * @param enumeration 枚举
1347
+ * @param enumeration 枚举对象
1348
+ * @returns 值数组
1349
+ * @example
1350
+ * ```ts
1351
+ * enum A { k = "v" }
1352
+ * enumValues(A); // ["v"]
1353
+ * ```
1394
1354
  */
1395
- declare function enumValues<E extends AnyObject>(enumeration: NonEmptyObject<E>): UnionToTuple<ValueOf<E>>;
1355
+ declare function enumValues<E extends PlainObject>(enumeration: E): UnionToTuple<ValueOf<E>>;
1356
+ declare function enumValues<E extends AnyObject>(enumeration: E): UnionToTuple<ValueOf<E>>;
1396
1357
  //#endregion
1397
1358
  //#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>;
1359
+ /**
1360
+ * 映射对象条目
1361
+ * - 将对象的键值对映射为新的键值对
1362
+ *
1363
+ * @param obj 对象
1364
+ * @param toEntry 映射函数
1365
+ * @returns 映射后的新对象
1366
+ * @example
1367
+ * ```ts
1368
+ * const obj = { a: 1, b: 2 };
1369
+ * mapEntries(obj, (k, v) => [k, v * 2]); // { a: 2, b: 4 }
1370
+ * ```
1371
+ */
1372
+ declare function mapEntries<K$1 extends PropertyKey, V$1, NK extends PropertyKey, NV>(obj: PlainObject<K$1, V$1>, toEntry: (key: K$1, value: V$1) => [NK, NV]): PlainObject<NK, NV>;
1399
1373
  //#endregion
1400
1374
  //#region node_modules/.pnpm/radashi@12.7.1/node_modules/radashi/dist/radashi.d.cts
1401
1375
 
@@ -2069,61 +2043,712 @@ TOverride | (IsOptional extends true ? TInitial : never) : Extract<TOverride, ob
2069
2043
  * original.b === cloned.b
2070
2044
  * // => true
2071
2045
  * ```
2072
- * @version 12.1.0
2046
+ * @version 12.1.0
2047
+ */
2048
+ //#endregion
2049
+ //#region src/utils/object/objectAssign.d.ts
2050
+ /**
2051
+ * 递归地将第二个对象合并到第一个对象的副本中
2052
+ * - 只有普通对象才会递归合并
2053
+ *
2054
+ * @param initial 初始对象
2055
+ * @param override 待合并对象
2056
+ * @returns 合并后的新对象
2057
+ * @example
2058
+ * ```ts
2059
+ * const base = { a: 1, b: { c: 2 } };
2060
+ * const override = { b: { d: 3 } };
2061
+ * objectAssign(base, override); // { a: 1, b: { c: 2, d: 3 } }
2062
+ * ```
2063
+ */
2064
+ declare function objectAssign<I$1 extends PlainObject, O extends PlainObject>(initial: I$1, override: O): Assign<I$1, O>;
2065
+ declare function objectAssign<I$1 extends AnyObject, O extends AnyObject>(initial: I$1, override: O): Assign<I$1, O>;
2066
+ //#endregion
2067
+ //#region src/utils/object/objectCrush.d.ts
2068
+ 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>>;
2069
+ /**
2070
+ * 压平对象
2071
+ * - 将多层级的对象转换为单层级的对象,键名使用点号连接
2072
+ *
2073
+ * @param plainObject 平面对象
2074
+ * @returns 压平后的对象
2075
+ * @example
2076
+ * ```ts
2077
+ * const obj = { a: { b: 1 } };
2078
+ * objectCrush(obj); // { "a.b": 1 }
2079
+ * ```
2080
+ */
2081
+ declare function objectCrush<T extends PlainObject>(plainObject: T): Crush<T>;
2082
+ declare function objectCrush<T extends AnyObject>(anyObject: T): Crush<T>;
2083
+ //#endregion
2084
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Any/Key.d.ts
2085
+ /**
2086
+ * Describes index keys for any type
2087
+ */
2088
+ declare type Key$1 = string | number | symbol;
2089
+ //#endregion
2090
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/List.d.ts
2091
+ /**
2092
+ * A [[List]]
2093
+ * @param A its type
2094
+ * @returns [[List]]
2095
+ * @example
2096
+ * ```ts
2097
+ * type list0 = [1, 2, 3]
2098
+ * type list1 = number[]
2099
+ * ```
2100
+ */
2101
+ declare type List<A$1 = any> = ReadonlyArray<A$1>;
2102
+ //#endregion
2103
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Any/Cast.d.ts
2104
+ /**
2105
+ * Ask TS to re-check that `A1` extends `A2`.
2106
+ * And if it fails, `A2` will be enforced anyway.
2107
+ * Can also be used to add constraints on parameters.
2108
+ * @param A1 to check against
2109
+ * @param A2 to cast to
2110
+ * @returns `A1 | A2`
2111
+ * @example
2112
+ * ```ts
2113
+ * import {A} from 'ts-toolbelt'
2114
+ *
2115
+ * type test0 = A.Cast<'42', string> // '42'
2116
+ * type test1 = A.Cast<'42', number> // number
2117
+ * ```
2118
+ */
2119
+ declare type Cast<A1 extends any, A2 extends any> = A1 extends A2 ? A1 : A2;
2120
+ //#endregion
2121
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Object/_Internal.d.ts
2122
+ /**
2123
+ * Describes the permissions/modifiers fields can have
2124
+ * `R`: readonly
2125
+ * `W`: writable
2126
+ * `!`: required
2127
+ * `?`: optional
2128
+ */
2129
+ declare type Modx = ['?' | '!', 'W' | 'R'];
2130
+ //#endregion
2131
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Any/Compute.d.ts
2132
+ /**
2133
+ * @hidden
2134
+ */
2135
+ declare type ComputeRaw<A$1 extends any> = A$1 extends Function ? A$1 : { [K in keyof A$1]: A$1[K] } & unknown;
2136
+ //#endregion
2137
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Any/Extends.d.ts
2138
+ /**
2139
+ * Check whether `A1` is part of `A2` or not. The difference with
2140
+ * `extends` is that it forces a [[Boolean]] return.
2141
+ * @param A1
2142
+ * @param A2
2143
+ * @returns [[Boolean]]
2144
+ * @example
2145
+ * ```ts
2146
+ * import {A} from 'ts-toolbelt'
2147
+ *
2148
+ * type test0 = A.Extends<'a' | 'b', 'b'> // Boolean
2149
+ * type test1 = A.Extends<'a', 'a' | 'b'> // True
2150
+ *
2151
+ * type test2 = A.Extends<{a: string}, {a: any}> // True
2152
+ * type test3 = A.Extends<{a: any}, {a: any, b: any}> // False
2153
+ *
2154
+ * type test4 = A.Extends<never, never> // False
2155
+ * /// Nothing cannot extend nothing, use `A.Equals`
2156
+ * ```
2157
+ */
2158
+ declare type Extends<A1 extends any, A2 extends any> = [A1] extends [never] ? 0 : A1 extends A2 ? 1 : 0;
2159
+ //#endregion
2160
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/Iteration.d.ts
2161
+ /**
2162
+ * An entry of `IterationMap`
2163
+ */
2164
+ declare type Iteration = [value: number, sign: '-' | '0' | '+', prev: keyof IterationMap, next: keyof IterationMap, oppo: keyof IterationMap];
2165
+ declare type IterationMap = {
2166
+ '__': [number, '-' | '0' | '+', '__', '__', '__'];
2167
+ '-100': [-100, '-', '__', '-99', '100'];
2168
+ '-99': [-99, '-', '-100', '-98', '99'];
2169
+ '-98': [-98, '-', '-99', '-97', '98'];
2170
+ '-97': [-97, '-', '-98', '-96', '97'];
2171
+ '-96': [-96, '-', '-97', '-95', '96'];
2172
+ '-95': [-95, '-', '-96', '-94', '95'];
2173
+ '-94': [-94, '-', '-95', '-93', '94'];
2174
+ '-93': [-93, '-', '-94', '-92', '93'];
2175
+ '-92': [-92, '-', '-93', '-91', '92'];
2176
+ '-91': [-91, '-', '-92', '-90', '91'];
2177
+ '-90': [-90, '-', '-91', '-89', '90'];
2178
+ '-89': [-89, '-', '-90', '-88', '89'];
2179
+ '-88': [-88, '-', '-89', '-87', '88'];
2180
+ '-87': [-87, '-', '-88', '-86', '87'];
2181
+ '-86': [-86, '-', '-87', '-85', '86'];
2182
+ '-85': [-85, '-', '-86', '-84', '85'];
2183
+ '-84': [-84, '-', '-85', '-83', '84'];
2184
+ '-83': [-83, '-', '-84', '-82', '83'];
2185
+ '-82': [-82, '-', '-83', '-81', '82'];
2186
+ '-81': [-81, '-', '-82', '-80', '81'];
2187
+ '-80': [-80, '-', '-81', '-79', '80'];
2188
+ '-79': [-79, '-', '-80', '-78', '79'];
2189
+ '-78': [-78, '-', '-79', '-77', '78'];
2190
+ '-77': [-77, '-', '-78', '-76', '77'];
2191
+ '-76': [-76, '-', '-77', '-75', '76'];
2192
+ '-75': [-75, '-', '-76', '-74', '75'];
2193
+ '-74': [-74, '-', '-75', '-73', '74'];
2194
+ '-73': [-73, '-', '-74', '-72', '73'];
2195
+ '-72': [-72, '-', '-73', '-71', '72'];
2196
+ '-71': [-71, '-', '-72', '-70', '71'];
2197
+ '-70': [-70, '-', '-71', '-69', '70'];
2198
+ '-69': [-69, '-', '-70', '-68', '69'];
2199
+ '-68': [-68, '-', '-69', '-67', '68'];
2200
+ '-67': [-67, '-', '-68', '-66', '67'];
2201
+ '-66': [-66, '-', '-67', '-65', '66'];
2202
+ '-65': [-65, '-', '-66', '-64', '65'];
2203
+ '-64': [-64, '-', '-65', '-63', '64'];
2204
+ '-63': [-63, '-', '-64', '-62', '63'];
2205
+ '-62': [-62, '-', '-63', '-61', '62'];
2206
+ '-61': [-61, '-', '-62', '-60', '61'];
2207
+ '-60': [-60, '-', '-61', '-59', '60'];
2208
+ '-59': [-59, '-', '-60', '-58', '59'];
2209
+ '-58': [-58, '-', '-59', '-57', '58'];
2210
+ '-57': [-57, '-', '-58', '-56', '57'];
2211
+ '-56': [-56, '-', '-57', '-55', '56'];
2212
+ '-55': [-55, '-', '-56', '-54', '55'];
2213
+ '-54': [-54, '-', '-55', '-53', '54'];
2214
+ '-53': [-53, '-', '-54', '-52', '53'];
2215
+ '-52': [-52, '-', '-53', '-51', '52'];
2216
+ '-51': [-51, '-', '-52', '-50', '51'];
2217
+ '-50': [-50, '-', '-51', '-49', '50'];
2218
+ '-49': [-49, '-', '-50', '-48', '49'];
2219
+ '-48': [-48, '-', '-49', '-47', '48'];
2220
+ '-47': [-47, '-', '-48', '-46', '47'];
2221
+ '-46': [-46, '-', '-47', '-45', '46'];
2222
+ '-45': [-45, '-', '-46', '-44', '45'];
2223
+ '-44': [-44, '-', '-45', '-43', '44'];
2224
+ '-43': [-43, '-', '-44', '-42', '43'];
2225
+ '-42': [-42, '-', '-43', '-41', '42'];
2226
+ '-41': [-41, '-', '-42', '-40', '41'];
2227
+ '-40': [-40, '-', '-41', '-39', '40'];
2228
+ '-39': [-39, '-', '-40', '-38', '39'];
2229
+ '-38': [-38, '-', '-39', '-37', '38'];
2230
+ '-37': [-37, '-', '-38', '-36', '37'];
2231
+ '-36': [-36, '-', '-37', '-35', '36'];
2232
+ '-35': [-35, '-', '-36', '-34', '35'];
2233
+ '-34': [-34, '-', '-35', '-33', '34'];
2234
+ '-33': [-33, '-', '-34', '-32', '33'];
2235
+ '-32': [-32, '-', '-33', '-31', '32'];
2236
+ '-31': [-31, '-', '-32', '-30', '31'];
2237
+ '-30': [-30, '-', '-31', '-29', '30'];
2238
+ '-29': [-29, '-', '-30', '-28', '29'];
2239
+ '-28': [-28, '-', '-29', '-27', '28'];
2240
+ '-27': [-27, '-', '-28', '-26', '27'];
2241
+ '-26': [-26, '-', '-27', '-25', '26'];
2242
+ '-25': [-25, '-', '-26', '-24', '25'];
2243
+ '-24': [-24, '-', '-25', '-23', '24'];
2244
+ '-23': [-23, '-', '-24', '-22', '23'];
2245
+ '-22': [-22, '-', '-23', '-21', '22'];
2246
+ '-21': [-21, '-', '-22', '-20', '21'];
2247
+ '-20': [-20, '-', '-21', '-19', '20'];
2248
+ '-19': [-19, '-', '-20', '-18', '19'];
2249
+ '-18': [-18, '-', '-19', '-17', '18'];
2250
+ '-17': [-17, '-', '-18', '-16', '17'];
2251
+ '-16': [-16, '-', '-17', '-15', '16'];
2252
+ '-15': [-15, '-', '-16', '-14', '15'];
2253
+ '-14': [-14, '-', '-15', '-13', '14'];
2254
+ '-13': [-13, '-', '-14', '-12', '13'];
2255
+ '-12': [-12, '-', '-13', '-11', '12'];
2256
+ '-11': [-11, '-', '-12', '-10', '11'];
2257
+ '-10': [-10, '-', '-11', '-9', '10'];
2258
+ '-9': [-9, '-', '-10', '-8', '9'];
2259
+ '-8': [-8, '-', '-9', '-7', '8'];
2260
+ '-7': [-7, '-', '-8', '-6', '7'];
2261
+ '-6': [-6, '-', '-7', '-5', '6'];
2262
+ '-5': [-5, '-', '-6', '-4', '5'];
2263
+ '-4': [-4, '-', '-5', '-3', '4'];
2264
+ '-3': [-3, '-', '-4', '-2', '3'];
2265
+ '-2': [-2, '-', '-3', '-1', '2'];
2266
+ '-1': [-1, '-', '-2', '0', '1'];
2267
+ '0': [0, '0', '-1', '1', '0'];
2268
+ '1': [1, '+', '0', '2', '-1'];
2269
+ '2': [2, '+', '1', '3', '-2'];
2270
+ '3': [3, '+', '2', '4', '-3'];
2271
+ '4': [4, '+', '3', '5', '-4'];
2272
+ '5': [5, '+', '4', '6', '-5'];
2273
+ '6': [6, '+', '5', '7', '-6'];
2274
+ '7': [7, '+', '6', '8', '-7'];
2275
+ '8': [8, '+', '7', '9', '-8'];
2276
+ '9': [9, '+', '8', '10', '-9'];
2277
+ '10': [10, '+', '9', '11', '-10'];
2278
+ '11': [11, '+', '10', '12', '-11'];
2279
+ '12': [12, '+', '11', '13', '-12'];
2280
+ '13': [13, '+', '12', '14', '-13'];
2281
+ '14': [14, '+', '13', '15', '-14'];
2282
+ '15': [15, '+', '14', '16', '-15'];
2283
+ '16': [16, '+', '15', '17', '-16'];
2284
+ '17': [17, '+', '16', '18', '-17'];
2285
+ '18': [18, '+', '17', '19', '-18'];
2286
+ '19': [19, '+', '18', '20', '-19'];
2287
+ '20': [20, '+', '19', '21', '-20'];
2288
+ '21': [21, '+', '20', '22', '-21'];
2289
+ '22': [22, '+', '21', '23', '-22'];
2290
+ '23': [23, '+', '22', '24', '-23'];
2291
+ '24': [24, '+', '23', '25', '-24'];
2292
+ '25': [25, '+', '24', '26', '-25'];
2293
+ '26': [26, '+', '25', '27', '-26'];
2294
+ '27': [27, '+', '26', '28', '-27'];
2295
+ '28': [28, '+', '27', '29', '-28'];
2296
+ '29': [29, '+', '28', '30', '-29'];
2297
+ '30': [30, '+', '29', '31', '-30'];
2298
+ '31': [31, '+', '30', '32', '-31'];
2299
+ '32': [32, '+', '31', '33', '-32'];
2300
+ '33': [33, '+', '32', '34', '-33'];
2301
+ '34': [34, '+', '33', '35', '-34'];
2302
+ '35': [35, '+', '34', '36', '-35'];
2303
+ '36': [36, '+', '35', '37', '-36'];
2304
+ '37': [37, '+', '36', '38', '-37'];
2305
+ '38': [38, '+', '37', '39', '-38'];
2306
+ '39': [39, '+', '38', '40', '-39'];
2307
+ '40': [40, '+', '39', '41', '-40'];
2308
+ '41': [41, '+', '40', '42', '-41'];
2309
+ '42': [42, '+', '41', '43', '-42'];
2310
+ '43': [43, '+', '42', '44', '-43'];
2311
+ '44': [44, '+', '43', '45', '-44'];
2312
+ '45': [45, '+', '44', '46', '-45'];
2313
+ '46': [46, '+', '45', '47', '-46'];
2314
+ '47': [47, '+', '46', '48', '-47'];
2315
+ '48': [48, '+', '47', '49', '-48'];
2316
+ '49': [49, '+', '48', '50', '-49'];
2317
+ '50': [50, '+', '49', '51', '-50'];
2318
+ '51': [51, '+', '50', '52', '-51'];
2319
+ '52': [52, '+', '51', '53', '-52'];
2320
+ '53': [53, '+', '52', '54', '-53'];
2321
+ '54': [54, '+', '53', '55', '-54'];
2322
+ '55': [55, '+', '54', '56', '-55'];
2323
+ '56': [56, '+', '55', '57', '-56'];
2324
+ '57': [57, '+', '56', '58', '-57'];
2325
+ '58': [58, '+', '57', '59', '-58'];
2326
+ '59': [59, '+', '58', '60', '-59'];
2327
+ '60': [60, '+', '59', '61', '-60'];
2328
+ '61': [61, '+', '60', '62', '-61'];
2329
+ '62': [62, '+', '61', '63', '-62'];
2330
+ '63': [63, '+', '62', '64', '-63'];
2331
+ '64': [64, '+', '63', '65', '-64'];
2332
+ '65': [65, '+', '64', '66', '-65'];
2333
+ '66': [66, '+', '65', '67', '-66'];
2334
+ '67': [67, '+', '66', '68', '-67'];
2335
+ '68': [68, '+', '67', '69', '-68'];
2336
+ '69': [69, '+', '68', '70', '-69'];
2337
+ '70': [70, '+', '69', '71', '-70'];
2338
+ '71': [71, '+', '70', '72', '-71'];
2339
+ '72': [72, '+', '71', '73', '-72'];
2340
+ '73': [73, '+', '72', '74', '-73'];
2341
+ '74': [74, '+', '73', '75', '-74'];
2342
+ '75': [75, '+', '74', '76', '-75'];
2343
+ '76': [76, '+', '75', '77', '-76'];
2344
+ '77': [77, '+', '76', '78', '-77'];
2345
+ '78': [78, '+', '77', '79', '-78'];
2346
+ '79': [79, '+', '78', '80', '-79'];
2347
+ '80': [80, '+', '79', '81', '-80'];
2348
+ '81': [81, '+', '80', '82', '-81'];
2349
+ '82': [82, '+', '81', '83', '-82'];
2350
+ '83': [83, '+', '82', '84', '-83'];
2351
+ '84': [84, '+', '83', '85', '-84'];
2352
+ '85': [85, '+', '84', '86', '-85'];
2353
+ '86': [86, '+', '85', '87', '-86'];
2354
+ '87': [87, '+', '86', '88', '-87'];
2355
+ '88': [88, '+', '87', '89', '-88'];
2356
+ '89': [89, '+', '88', '90', '-89'];
2357
+ '90': [90, '+', '89', '91', '-90'];
2358
+ '91': [91, '+', '90', '92', '-91'];
2359
+ '92': [92, '+', '91', '93', '-92'];
2360
+ '93': [93, '+', '92', '94', '-93'];
2361
+ '94': [94, '+', '93', '95', '-94'];
2362
+ '95': [95, '+', '94', '96', '-95'];
2363
+ '96': [96, '+', '95', '97', '-96'];
2364
+ '97': [97, '+', '96', '98', '-97'];
2365
+ '98': [98, '+', '97', '99', '-98'];
2366
+ '99': [99, '+', '98', '100', '-99'];
2367
+ '100': [100, '+', '99', '__', '-100'];
2368
+ };
2369
+ //#endregion
2370
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/Prev.d.ts
2371
+ /**
2372
+ * Move `I`'s position backwards
2373
+ * @param I to move
2374
+ * @returns [[Iteration]]
2375
+ * @example
2376
+ * ```ts
2377
+ * import {I} from 'ts-toolbelt'
2378
+ *
2379
+ * type i = I.IterationOf<'20'>
2380
+ *
2381
+ * type test0 = I.Pos<i> // 20
2382
+ * type test1 = I.Pos<I.Prev<i>> // 19
2383
+ * ```
2384
+ */
2385
+ declare type Prev<I$1 extends Iteration> = IterationMap[I$1[2]];
2386
+ //#endregion
2387
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/IterationOf.d.ts
2388
+ /**
2389
+ * Transform a number into an [[Iteration]]
2390
+ * (to use [[Prev]], [[Next]], & [[Pos]])
2391
+ * @param N to transform
2392
+ * @returns [[Iteration]]
2393
+ * @example
2394
+ * ```ts
2395
+ * import {I} from 'ts-toolbelt'
2396
+ *
2397
+ * type i = I.IterationOf<0> // ["-1", "1", "0", 0, "0"]
2398
+ *
2399
+ * type next = I.Next<i> // ["0", "2", "1", 1, "+"]
2400
+ * type prev = I.Prev<i> // ["-2", "0", "-1", -1, "-"]
2401
+ *
2402
+ * type nnext = I.Pos<next> // +1
2403
+ * type nprev = I.Pos<prev> // -1
2404
+ * ```
2405
+ */
2406
+ declare type IterationOf<N extends number> = `${N}` extends keyof IterationMap ? IterationMap[`${N}`] : IterationMap['__'];
2407
+ //#endregion
2408
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/Pos.d.ts
2409
+ /**
2410
+ * Get the position of `I` (**number**)
2411
+ * @param I to query
2412
+ * @returns `number`
2413
+ * @example
2414
+ * ```ts
2415
+ * import {I} from 'ts-toolbelt'
2416
+ *
2417
+ * type i = I.IterationOf<'20'>
2418
+ *
2419
+ * type test0 = I.Pos<i> // 20
2420
+ * type test1 = I.Pos<I.Next<i>> // 21
2421
+ * ```
2422
+ */
2423
+ declare type Pos<I$1 extends Iteration> = I$1[0];
2424
+ //#endregion
2425
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Tail.d.ts
2426
+ /**
2427
+ * Remove the first item out of a [[List]]
2428
+ * @param L
2429
+ * @returns [[List]]
2430
+ * @example
2431
+ * ```ts
2432
+ * ```
2433
+ */
2434
+ declare type Tail$1<L extends List> = L extends readonly [] ? L : L extends readonly [any?, ...infer LTail] ? LTail : L;
2435
+ //#endregion
2436
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Union/IntersectOf.d.ts
2437
+ /**
2438
+ * Transform a [[Union]] to an * *intersection**
2439
+ * @param U to transform
2440
+ * @returns `&`
2441
+ * @example
2442
+ * ```ts
2443
+ * ```
2444
+ */
2445
+ declare type IntersectOf<U$1 extends any> = (U$1 extends unknown ? (k: U$1) => void : never) extends ((k: infer I) => void) ? I : never;
2446
+ //#endregion
2447
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Object/Overwrite.d.ts
2448
+ /**
2449
+ * Update the fields of `O` with the ones of `O1`
2450
+ * (only the existing fields will be updated)
2451
+ * @param O to update
2452
+ * @param O1 to update with
2453
+ * @returns [[Object]]
2454
+ * @example
2455
+ * ```ts
2456
+ * ```
2457
+ */
2458
+ declare type Overwrite<O extends object, O1 extends object> = { [K in keyof O]: K extends keyof O1 ? O1[K] : O[K] } & {};
2459
+ //#endregion
2460
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/_Internal.d.ts
2461
+ /**
2462
+ * Remove `?` & `readonly` from a [[List]]
2463
+ */
2464
+ declare type Naked<L extends List> = Overwrite<Required<L>, L>;
2465
+ //#endregion
2466
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Prepend.d.ts
2467
+ /**
2468
+ * Add an element `A` at the beginning of `L`
2469
+ * @param L to append to
2470
+ * @param A to be added to
2471
+ * @returns [[List]]
2472
+ * @example
2473
+ * ```ts
2474
+ * ```
2475
+ */
2476
+ declare type Prepend<L extends List, A$1 extends any> = [A$1, ...L];
2477
+ //#endregion
2478
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/_Internal.d.ts
2479
+ /**
2480
+ * Describes how to perform iterations
2481
+ */
2482
+ declare type Way = '->' | '<-';
2483
+ //#endregion
2484
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Append.d.ts
2485
+ /**
2486
+ * Add an element `A` at the end of `L`.
2487
+ * @param L to append to
2488
+ * @param A to be added to
2489
+ * @returns [[List]]
2490
+ * @example
2491
+ * ```ts
2492
+ * import {L} from 'ts-toolbelt'
2493
+ *
2494
+ * type test0 = L.Append<[1, 2, 3], 4> // [1, 2, 3, 4]
2495
+ * type test1 = L.Append<[], 'a'> // ['a']
2496
+ * type test2 = L.Append<readonly ['a', 'b'], 'c'> // ['a', 'b', 'c']
2497
+ * type test3 = L.Append<[1, 2], [3, 4]> // [1, 2, [3, 4]]
2498
+ * ```
2499
+ */
2500
+ declare type Append<L extends List, A$1 extends any> = [...L, A$1];
2501
+ //#endregion
2502
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Object/Record.d.ts
2503
+ /**
2504
+ * Create an object filled with `A` for the fields `K`
2505
+ * @param K to choose fields
2506
+ * @param A (?=`unknown`) to fill fields with
2507
+ * @param modx (?=`['!', 'W']`) to set modifiers
2508
+ * @returns [[Object]]
2509
+ * @example
2510
+ * ```ts
2511
+ * ```
2512
+ */
2513
+ declare type Record$1<K$1 extends Key$1, A$1 extends any = unknown, modx extends Modx = ['!', 'W']> = {
2514
+ '!': {
2515
+ 'R': { readonly [P in K$1]: A$1 };
2516
+ 'W': { [P in K$1]: A$1 };
2517
+ };
2518
+ '?': {
2519
+ 'R': { readonly [P in K$1]?: A$1 };
2520
+ 'W': { [P in K$1]?: A$1 };
2521
+ };
2522
+ }[modx[0]][modx[1]];
2523
+ //#endregion
2524
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Object/Invert.d.ts
2525
+ /**
2526
+ * @hidden
2527
+ */
2528
+ declare type _Invert<O extends Record$1<Key$1, Key$1>> = ComputeRaw<IntersectOf<{ [K in keyof O]: Record$1<O[K], K> }[keyof O]>>;
2529
+ /**
2530
+ * Swaps the keys and values of an [[Object]] (if applicable)
2531
+ * @param O
2532
+ * @returns [[Object]]
2533
+ * @example
2534
+ * ```ts
2535
+ * import {O} from 'ts-toolbelt'
2536
+ *
2537
+ * enum E {
2538
+ * A = 'Av',
2539
+ * B = 'Bv',
2540
+ * C = 'Cv',
2541
+ * D = 'Dv',
2542
+ * X = 1
2543
+ * }
2544
+ *
2545
+ * type O = {
2546
+ * A: 'Av'
2547
+ * B: 'Bv'
2548
+ * C: 'Cv'
2549
+ * D: 'Dv'
2550
+ * X: 1
2551
+ * }
2552
+ *
2553
+ * type test0 = O.Invert<typeof E>
2554
+ * type test1 = O.Invert<O>
2555
+ * ```
2556
+ */
2557
+ declare type Invert<O extends Record$1<keyof O, Key$1>> = O extends unknown ? _Invert<O> : never;
2558
+ //#endregion
2559
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Drop.d.ts
2560
+ /**
2561
+ * @hidden
2562
+ */
2563
+ declare type DropForth<L extends List, N extends Iteration> = {
2564
+ 0: DropForth<Tail$1<L>, Prev<N>>;
2565
+ 1: L;
2566
+ }[Extends<0, Pos<N>>];
2567
+ /**
2568
+ * @hidden
2569
+ */
2570
+ declare type DropBack<L extends List, N extends Iteration, I$1 extends Iteration = Prev<N>, LN extends List = []> = {
2571
+ 0: DropBack<L, N, Prev<I$1>, Prepend<LN, L[Pos<I$1>]>>;
2572
+ 1: LN;
2573
+ }[Extends<-1, Pos<I$1>>];
2574
+ /**
2575
+ * @hidden
2576
+ */
2577
+ declare type __Drop<L extends List, N extends Iteration, way extends Way> = {
2578
+ '->': DropForth<L, N>;
2579
+ '<-': DropBack<L, N>;
2580
+ }[way];
2581
+ /**
2582
+ * @hidden
2583
+ */
2584
+ 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;
2585
+ /**
2586
+ * Remove `N` entries out of `L`
2587
+ * @param L to remove from
2588
+ * @param N to remove out
2589
+ * @param way (?=`'->'`) from front: '->', from end: '<-'
2590
+ * @returns [[List]]
2591
+ * @example
2592
+ * ```ts
2593
+ * ```
2594
+ */
2595
+ declare type Drop<L extends List, N extends number, way extends Way = '->'> = L extends unknown ? N extends unknown ? _Drop<L, N, way> : never : never;
2596
+ //#endregion
2597
+ //#region node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Take.d.ts
2598
+ /**
2599
+ * starts in reverse from `N` till `N` = 0
2600
+ * @hidden
2601
+ */
2602
+ declare type TakeForth<L extends List, N extends Iteration, I$1 extends Iteration = Prev<N>, LN extends List = []> = {
2603
+ 0: TakeForth<L, N, Prev<I$1>, Prepend<LN, L[Pos<I$1>]>>;
2604
+ 1: LN;
2605
+ }[Extends<-1, Pos<I$1>>];
2606
+ /**
2607
+ * starts in reverse from the end till `N` = 0
2608
+ * @hidden
2609
+ */
2610
+ declare type TakeBack<L extends List, N extends Iteration> = {
2611
+ 0: TakeBack<Tail$1<L>, Prev<N>>;
2612
+ 1: L;
2613
+ }[Extends<0, Pos<N>>];
2614
+ /**
2615
+ * @hidden
2616
+ */
2617
+ declare type __Take<L extends List, N extends Iteration, way extends Way> = {
2618
+ '->': TakeForth<L, N>;
2619
+ '<-': TakeBack<L, N>;
2620
+ }[way];
2621
+ /**
2622
+ * @hidden
2623
+ */
2624
+ declare type _Take<L extends List, N extends number, way extends Way = '->'> = __Take<L, IterationOf<N>, way> extends infer X ? Cast<X, List> : never;
2625
+ /**
2626
+ * Extract `N` entries out of `L`
2627
+ * @param L to extract from
2628
+ * @param N to extract out
2629
+ * @param way (?=`'->'`) to extract from end
2630
+ * @returns [[List]]
2631
+ * @example
2632
+ * ```ts
2633
+ * ```
2073
2634
  */
2635
+ declare type Take<L extends List, N extends number, way extends Way = '->'> = L extends unknown ? N extends unknown ? _Take<L, N, way> : never : never;
2074
2636
  //#endregion
2075
- //#region src/utils/object/objectAssign.d.ts
2637
+ //#region src/types/index.type.d.ts
2638
+ type AnyArray<A$1 = any> = readonly A$1[];
2639
+ type Range<Start extends number, End extends number> = Exclude<keyof TupleOf<End>, keyof TupleOf<Start>>;
2640
+ type TupleToEntries<A$1 extends readonly unknown[]> = If<IsAny<A$1>, unknown, { [Key in keyof A$1]: [Key, A$1[Key]] }>;
2641
+ type Groups<L extends AnyArray, LN extends AnyArray = [], D extends number[] = []> = D["length"] extends 40 ? LN : {
2642
+ 0: Groups<Drop<L, 1>, Append<LN, [`${LN["length"]}`, Take<L, 1>]>, [...D, 0]>;
2643
+ 1: LN;
2644
+ }[Extends<L, AnyArray<never>>];
2645
+ type TupleToGroups<L extends AnyArray> = Groups<L> extends infer X ? Cast<X, AnyArray> : never;
2646
+ //#endregion
2647
+ //#region src/utils/object/objectEntries.d.ts
2076
2648
  /**
2077
- * 递归地将第二个对象合并到第一个对象的副本中
2078
- * - 只有普通对象才会递归合并
2649
+ * 返回对象的可枚举属性的键/值数组
2079
2650
  *
2080
- * @param initial 初始对象
2081
- * @param override 待合并对象
2651
+ * @param value 对象
2652
+ * @returns 键值对数组
2653
+ * @example
2654
+ * ```ts
2655
+ * objectEntries({ a: 1 }); // [["a", 1]]
2656
+ * ```
2082
2657
  */
2083
- declare function objectAssign<I$1 extends PlainObject, O extends PlainObject>(initial: I$1, override: O): Assign<I$1, O>;
2084
- //#endregion
2085
- //#region src/utils/object/objectCrush.d.ts
2086
- 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>;
2658
+ declare function objectEntries<const S extends string>(string: S): TupleToEntries<Split<S, "">>;
2659
+ declare function objectEntries<const A$1 extends readonly unknown[]>(array: A$1): TupleToGroups<A$1>;
2660
+ declare function objectEntries<const O extends PlainObject>(plainObject: O): [string & keyof O, O[keyof O]][];
2661
+ declare function objectEntries<const O extends AnyObject>(anyObject: O): [string & keyof O, O[keyof O]][];
2088
2662
  //#endregion
2089
- //#region src/utils/object/objectEntries.d.ts
2663
+ //#region src/utils/object/objectInvert.d.ts
2090
2664
  /**
2091
- * 返回对象的可枚举属性的键/值数组
2665
+ * 尽可能地交换对象的键和值
2666
+ *
2667
+ /**
2668
+ * 尽可能地交换对象的键和值
2092
2669
  *
2093
2670
  * @param obj 对象
2671
+ * @returns 键值互换后的对象
2672
+ * @example
2673
+ * ```ts
2674
+ * const obj = { a: "1", b: 2 };
2675
+ * objectInvert(obj); // { "1": "a", 2: "b" }
2676
+ * ```
2094
2677
  */
2095
- declare function objectEntries<O extends AnyObject>(obj: O): [string & keyof O, O[keyof O]][];
2678
+ declare function objectInvert<const O extends Record<keyof O, PropertyKey>>(plainObject: O): Invert<O>;
2679
+ declare function objectInvert<const O extends AnyObject>(anyObject: O): Invert<O>;
2096
2680
  //#endregion
2097
2681
  //#region src/utils/object/objectKeys.d.ts
2098
2682
  /**
2099
- * 返回对象的可枚举属性和方法的名称
2683
+ * 返回对象可枚举属性和方法的名称
2100
2684
  * - `Object.keys` 始终返回 `string[]` 类型,此函数可以返回具体类型
2101
2685
  *
2102
- * @param obj 对象
2686
+ * @param value 对象
2687
+ * @returns 键数组
2688
+ * @example
2689
+ * ```ts
2690
+ * objectKeys({ a: 1, b: 2 }); // ["a", "b"]
2691
+ * ```
2103
2692
  */
2104
- declare function objectKeys<O extends AnyObject>(obj: O): (keyof O)[];
2693
+ declare function objectKeys<const S extends string>(string: S): UnionToTuple<Range<0, Split<S, "">["length"]>>;
2694
+ declare function objectKeys<const A$1 extends ArrayLike<unknown>>(array: A$1): UnionToTuple<Range<0, A$1["length"]>>;
2695
+ declare function objectKeys<O extends PlainObject>(plainObject: O): `${Extract<keyof O, string | number>}`[];
2696
+ declare function objectKeys<O extends AnyObject>(anyObject: O): `${Extract<keyof O, string | number>}`[];
2105
2697
  //#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>;
2698
+ //#region src/utils/object/objectOmit.d.ts
2699
+ /**
2700
+ * 排除对象的指定属性
2701
+ *
2702
+ * @param plainObject 对象
2703
+ * @param keys 要排除的属性键数组
2704
+ * @returns 排除指定属性后的新对象
2705
+ * @example
2706
+ * ```ts
2707
+ * objectOmit({ a: 1, b: 2 }, ["a"]); // { b: 2 }
2708
+ * ```
2709
+ */
2710
+ declare function objectOmit<O extends PlainObject, K$1 extends keyof O>(plainObject: O, keys: readonly K$1[]): Omit<O, K$1>;
2711
+ declare function objectOmit<O extends AnyObject, K$1 extends keyof O>(anyObject: O, keys: readonly K$1[]): Omit<O, K$1>;
2108
2712
  //#endregion
2109
- //#region src/utils/object/objectSwitch.d.ts
2713
+ //#region src/utils/object/objectPick.d.ts
2110
2714
  /**
2111
- * 对象反转
2112
- * - 返回交换了对象的可枚举属性的值/键对象
2715
+ * 选取对象的指定属性
2113
2716
  *
2114
- * @param obj 对象
2717
+ * @param plainObject 对象
2718
+ * @param keys 要选取的属性键数组
2719
+ * @returns 包含指定属性的新对象
2720
+ * @example
2721
+ * ```ts
2722
+ * objectPick({ a: 1, b: 2 }, ["a"]); // { a: 1 }
2723
+ * ```
2115
2724
  */
2116
- declare function objectSwitch<O extends AnyObject>(obj: NonEmptyObject<O>): Record<O[keyof O], keyof O>;
2725
+ declare function objectPick<O extends PlainObject, K$1 extends keyof O>(plainObject: O, keys: readonly K$1[]): Pick<O, K$1>;
2726
+ declare function objectPick<O extends AnyObject, K$1 extends keyof O>(anyObject: O, keys: readonly K$1[]): Pick<O, K$1>;
2117
2727
  //#endregion
2118
2728
  //#region src/utils/object/objectValues.d.ts
2119
2729
  /**
2120
- * 返回对象的可枚举属性的值数组
2730
+ * 返回对象可枚举属性的值的数组
2121
2731
  *
2122
- * @param obj 对象
2732
+ * @param value 对象
2733
+ * @returns 值数组
2734
+ * @example
2735
+ * ```ts
2736
+ * objectValues({ a: 1, b: 2 }); // [1, 2]
2737
+ * ```
2123
2738
  */
2124
- declare function objectValues<O extends AnyObject>(obj: O): UnionToTuple<ValueOf<O>>;
2739
+ declare function objectValues<S extends string>(string: S): Split<S, "">;
2740
+ declare function objectValues<A$1 extends ArrayLike<unknown>>(array: A$1): A$1;
2741
+ declare function objectValues<O extends PlainObject>(plainObject: O): UnionToTuple<ValueOf<O>>;
2742
+ declare function objectValues<O extends AnyObject>(anyObject: O): UnionToTuple<ValueOf<O>>;
2125
2743
  //#endregion
2126
2744
  //#region src/utils/string/stringInitialCase.d.ts
2745
+ /**
2746
+ * 字符串首字母大小写
2747
+ * - 包含非西欧字母字符时,不处理
2748
+ * - 纯字母且全大写时,不处理
2749
+ * - 纯字母且非全大写时,首字母小写,其余保留
2750
+ * - 纯字母且非全大写时,首字母大写,其余保留
2751
+ *
2127
2752
  /**
2128
2753
  * 字符串首字母大小写
2129
2754
  * - 包含非西欧字母字符时,不处理
@@ -2133,10 +2758,20 @@ declare function objectValues<O extends AnyObject>(obj: O): UnionToTuple<ValueOf
2133
2758
  *
2134
2759
  * @param input 待处理字符串
2135
2760
  * @param caseType 大小写类型
2761
+ * @returns 处理后的字符串
2762
+ * @example
2763
+ * ```ts
2764
+ * stringInitialCase("Hello", "lower"); // "hello"
2765
+ * stringInitialCase("hello", "upper"); // "Hello"
2766
+ * ```
2136
2767
  */
2137
2768
  declare function stringInitialCase(input: string, caseType?: "lower" | "upper" | undefined): string;
2138
2769
  //#endregion
2139
2770
  //#region src/utils/string/stringReplace.d.ts
2771
+ /**
2772
+ * 字符串替换
2773
+ * - 替换第一个匹配项
2774
+ *
2140
2775
  /**
2141
2776
  * 字符串替换
2142
2777
  * - 替换第一个匹配项
@@ -2144,33 +2779,65 @@ declare function stringInitialCase(input: string, caseType?: "lower" | "upper" |
2144
2779
  * @param input 待处理字符串
2145
2780
  * @param search 匹配项
2146
2781
  * @param replacement 替换项
2782
+ * @returns 替换后的字符串
2783
+ * @example
2784
+ * ```ts
2785
+ * stringReplace("hello world", "world", "context"); // "hello context"
2786
+ * ```
2147
2787
  */
2148
2788
  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
2789
  //#endregion
2150
2790
  //#region src/utils/string/stringTemplate.d.ts
2791
+ /**
2792
+ * 字符串模板替换
2793
+ *
2151
2794
  /**
2152
2795
  * 字符串模板替换
2153
2796
  *
2154
2797
  * @param input 待处理字符串
2155
2798
  * @param template 模板对象
2156
- * @param regex 模板匹配正则
2799
+ * @param regex 模板匹配正则 (默认: `\{\{(.+?)\}\}`)
2800
+ * @returns 替换后的字符串
2801
+ * @example
2802
+ * ```ts
2803
+ * stringTemplate("Hello {{name}}", { name: "World" }); // "Hello World"
2804
+ * ```
2157
2805
  */
2158
2806
  declare function stringTemplate(input: string, template: PlainObject, regex?: RegExp): string;
2159
2807
  //#endregion
2160
2808
  //#region src/utils/string/stringToJson.d.ts
2809
+ /**
2810
+ * 处理 JSON 字符串
2811
+ *
2161
2812
  /**
2162
2813
  * 处理 JSON 字符串
2163
2814
  *
2164
2815
  * @param input 待处理字符串
2165
- * @param safeValue 安全值
2816
+ * @param safeValue 安全值 (当解析失败或输入无效时返回)
2817
+ * @returns 解析后的对象 或 安全值
2818
+ * @example
2819
+ * ```ts
2820
+ * stringToJson('{"a": 1}', {}); // { a: 1 }
2821
+ * stringToJson('invalid', {}); // {}
2822
+ * ```
2166
2823
  */
2167
- declare function stringToJson<R$1 extends AnyObject = AnyObject, D extends R$1 = R$1>(input: string | null | undefined, safeValue: D): R$1;
2824
+ declare function stringToJson<D extends AnyObject = AnyObject>(input: string | null | undefined, safeValue: D): D;
2168
2825
  //#endregion
2169
2826
  //#region src/utils/string/stringToNumber.d.ts
2170
2827
  /**
2171
2828
  * 从字符串中提取数字字符串
2172
2829
  *
2830
+ /**
2831
+ * 从字符串中提取数字字符串
2832
+ * - 移除非数字字符,保留符号和小数点
2833
+ *
2173
2834
  * @param input 待处理字符串
2835
+ * @returns 提取出的数字字符串
2836
+ * @example
2837
+ * ```ts
2838
+ * stringToNumber("$1,234.56"); // "1234.56"
2839
+ * stringToNumber("abc-123"); // "-123"
2840
+ * ```
2174
2841
  */
2175
2842
  declare function stringToNumber(input: string): string;
2176
2843
  //#endregion
@@ -2178,17 +2845,35 @@ declare function stringToNumber(input: string): string;
2178
2845
  /**
2179
2846
  * 将路径转换为 POSIX 风格
2180
2847
  *
2848
+ /**
2849
+ * 将路径转换为 POSIX 风格
2850
+ * - 统一使用正斜杠
2851
+ * - 处理 Windows 盘符
2852
+ *
2181
2853
  * @param input 待处理字符串
2854
+ * @param removeLeadingSlash 是否移除开头斜杠,默认为 `false`
2855
+ * @returns 转换后的路径
2856
+ * @example
2857
+ * ```ts
2858
+ * stringToPosix("C:\\Windows\\System32"); // "/Windows/System32"
2859
+ * ```
2182
2860
  */
2183
- declare function stringToPosix(input: string | null | undefined): string;
2861
+ declare function stringToPosix(input: string | null | undefined, removeLeadingSlash?: boolean): string;
2184
2862
  //#endregion
2185
2863
  //#region src/utils/string/stringToValues.d.ts
2186
2864
  /**
2187
2865
  * 字符串分割为数组
2866
+ * - 按指定分隔符分割字符串,并转换类型
2188
2867
  *
2189
2868
  * @param input 待处理字符串
2190
- * @param valueType 数组中每一项的类型
2869
+ * @param valueType 数组中每一项的类型,默认为 "number"
2191
2870
  * @param splitSymbol 分隔符,默认为 `,`
2871
+ * @returns 分割后的数组
2872
+ * @example
2873
+ * ```ts
2874
+ * stringToValues("1,2,3"); // [1, 2, 3]
2875
+ * stringToValues("a-b-c", "string", "-"); // ["a", "b", "c"]
2876
+ * ```
2192
2877
  */
2193
2878
  declare function stringToValues(input: string | null | undefined, valueType?: "number" | undefined, splitSymbol?: string | undefined): number[];
2194
2879
  declare function stringToValues(input: string | null | undefined, valueType: "string", splitSymbol?: string | undefined): string[];
@@ -2199,20 +2884,47 @@ declare function stringToValues(input: string | null | undefined, valueType: "st
2199
2884
  *
2200
2885
  * @param input 待处理字符串
2201
2886
  * @param charsToTrim 裁切字符,默认为 `" "`
2887
+ * @returns 裁切后的字符串
2888
+ * @example
2889
+ * ```ts
2890
+ * stringTrim(" hello "); // "hello"
2891
+ * stringTrim("__hello__", "_"); // "hello"
2892
+ * ```
2202
2893
  */
2203
2894
  declare function stringTrim(input: string | null | undefined, charsToTrim?: string): string;
2204
2895
  //#endregion
2205
2896
  //#region src/utils/string/stringTruncate.d.ts
2897
+ /**
2206
2898
  /**
2207
2899
  * 截取字符串
2208
- * - 支持中英文混排,不会在汉字中间截断
2900
+ * - 支持自定义省略符,不会截断在汉字中间(因为JS字符串本身按字符处理)
2209
2901
  *
2210
2902
  * @param input 待处理字符串
2211
- * @param maxLength 最大长度
2903
+ * @param maxLength 最大长度 (包含省略符)
2212
2904
  * @param ellipsis 省略符,默认为 `...`
2905
+ * @returns 截取后的字符串
2906
+ * @example
2907
+ * ```ts
2908
+ * stringTruncate("hello world", 8); // "hello..."
2909
+ * ```
2213
2910
  */
2214
2911
  declare function stringTruncate(input: string, maxLength: number, ellipsis?: string): string;
2215
2912
  //#endregion
2913
+ //#region src/utils/time/timeZone.d.ts
2914
+ /**
2915
+ * 获取当前时区信息
2916
+ *
2917
+ * @returns 时区信息对象 (UTC偏移和时区名称)
2918
+ * @example
2919
+ * ```ts
2920
+ * getTimeZone(); // { UTC: "UTC+8", timeZone: "Asia/Shanghai" }
2921
+ * ```
2922
+ */
2923
+ declare function getTimeZone(): {
2924
+ UTC: string;
2925
+ timeZone: string;
2926
+ };
2927
+ //#endregion
2216
2928
  //#region src/utils/tree/types.d.ts
2217
2929
  type RowKey = "id";
2218
2930
  type ParentIdKey = "parentId";
@@ -2231,6 +2943,22 @@ interface BaseOptions<T, CK extends string> {
2231
2943
  //#region src/utils/tree/treeFilter.d.ts
2232
2944
  type TreeFilterOptions<T extends AnyObject, CK extends string = ChildrenKey> = BaseOptions<T, CK>;
2233
2945
  type TreeFilterCallback<T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => boolean;
2946
+ /**
2947
+ * 过滤树节点
2948
+ * - 返回新的树结构,包含所有回调返回 true 的节点
2949
+ * - 如果父节点被过滤,则其子节点也会被过滤 (pre 策略下)
2950
+ *
2951
+ * @param tree 树结构数据
2952
+ * @param callback 回调函数
2953
+ * @param options 配置项 (childrenKey, strategy等)
2954
+ * @returns 过滤后的树结构数组
2955
+ * @example
2956
+ * ```ts
2957
+ * const tree = [{ id: 1, visible: true, children: [{ id: 2, visible: false }] }];
2958
+ * treeFilter(tree, (node) => node.visible);
2959
+ * // [{ id: 1, visible: true, children: [] }]
2960
+ * ```
2961
+ */
2234
2962
  declare function treeFilter<T extends AnyObject, CK extends string = ChildrenKey>(tree: T[], callback: TreeFilterCallback<T>, options?: TreeFilterOptions<T, CK>): T[];
2235
2963
  declare function treeFilter<T extends AnyObject, CK extends string = ChildrenKey>(tree: T, callback: TreeFilterCallback<T>, options?: TreeFilterOptions<T, CK>): T;
2236
2964
  //#endregion
@@ -2238,18 +2966,58 @@ declare function treeFilter<T extends AnyObject, CK extends string = ChildrenKey
2238
2966
  type TreeFindOptions<T extends AnyObject, CK extends string = ChildrenKey> = BaseOptions<T, CK>;
2239
2967
  type TreeFindCallback<T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => boolean;
2240
2968
  /**
2241
- * 查找树节点,找到第一个返回非空值的节点
2969
+ * 查找树节点
2970
+ * - 返回第一个回调返回 true 的节点
2971
+ *
2972
+ * @param tree 树结构数据
2973
+ * @param callback 回调函数
2974
+ * @param options 配置项
2975
+ * @returns 找到的节点,未找到则返回 undefined
2976
+ * @example
2977
+ * ```ts
2978
+ * const tree = [{ id: 1, children: [{ id: 2 }] }];
2979
+ * treeFind(tree, (node) => node.id === 2); // { id: 2, ... }
2980
+ * ```
2242
2981
  */
2243
2982
  declare function treeFind<T extends AnyObject, CK extends string = ChildrenKey>(tree: T | T[], callback: TreeFindCallback<T>, options?: TreeFindOptions<T, CK>): T | undefined;
2244
2983
  //#endregion
2245
2984
  //#region src/utils/tree/treeForEach.d.ts
2246
2985
  type TreeForeachOptions<T extends AnyObject, CK extends string = ChildrenKey> = BaseOptions<T, CK>;
2247
2986
  type TreeForeachCallback<T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => void;
2987
+ /**
2988
+ * 遍历树节点
2989
+ *
2990
+ * @param tree 树结构数据
2991
+ * @param callback 回调函数
2992
+ * @param options 配置项
2993
+ * @example
2994
+ * ```ts
2995
+ * const tree = [{ id: 1, children: [{ id: 2 }] }];
2996
+ * const ids: number[] = [];
2997
+ * treeForEach(tree, (node) => ids.push(node.id));
2998
+ * // ids: [1, 2] (pre-order default)
2999
+ * ```
3000
+ */
2248
3001
  declare function treeForEach<T extends AnyObject, CK extends string = ChildrenKey>(tree: T | T[], callback: TreeForeachCallback<T>, options?: TreeForeachOptions<T, CK>): void;
2249
3002
  //#endregion
2250
3003
  //#region src/utils/tree/treeMap.d.ts
2251
3004
  type TreeMapOptions<T extends AnyObject, CK extends string> = BaseOptions<T, CK>;
2252
3005
  type TreeMapCallback<R$1 extends AnyObject, T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => R$1;
3006
+ /**
3007
+ * 映射树节点
3008
+ * - 返回新的树结构,保持层级关系
3009
+ *
3010
+ * @param tree 树结构数据
3011
+ * @param callback 回调函数 (返回映射后的节点内容)
3012
+ * @param options 配置项
3013
+ * @returns 映射后的树结构数组
3014
+ * @example
3015
+ * ```ts
3016
+ * const tree = [{ id: 1, val: 10, children: [{ id: 2, val: 20 }] }];
3017
+ * treeMap(tree, (node) => ({ ...node, val: node.val * 2 }));
3018
+ * // [{ id: 1, val: 20, children: [{ id: 2, val: 40 }] }]
3019
+ * ```
3020
+ */
2253
3021
  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>[];
2254
3022
  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
3023
  //#endregion
@@ -2261,6 +3029,20 @@ interface RowsToTreeOptions<RK extends string = RowKey, PK extends string = Pare
2261
3029
  }
2262
3030
  /**
2263
3031
  * 行结构 转 树结构
3032
+ * - 将平铺的数组转换为树形结构
3033
+ *
3034
+ * @param rows 行数据数组
3035
+ * @param options 配置项
3036
+ * @returns 树结构数组
3037
+ * @example
3038
+ * ```ts
3039
+ * const rows = [
3040
+ * { id: 1, parentId: null },
3041
+ * { id: 2, parentId: 1 },
3042
+ * ];
3043
+ * rowsToTree(rows);
3044
+ * // [{ id: 1, parentId: null, children: [{ id: 2, parentId: 1 }] }]
3045
+ * ```
2264
3046
  */
2265
3047
  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[];
2266
3048
  //#endregion
@@ -2268,68 +3050,212 @@ declare function rowsToTree<T extends AnyObject = AnyObject, CK extends string =
2268
3050
  type TreeToRowsOptions<T extends AnyObject, CK extends string = ChildrenKey> = TreeForeachOptions<T, CK>;
2269
3051
  /**
2270
3052
  * 树结构 转 行结构
3053
+ * - 将树形结构扁平化为数组
3054
+ *
3055
+ * @param tree 树结构数据 (单个节点或节点数组)
3056
+ * @param options 配置项
3057
+ * @returns 扁平化后的数组
3058
+ * @example
3059
+ * ```ts
3060
+ * const tree = [{ id: 1, children: [{ id: 2 }] }];
3061
+ * treeToRows(tree);
3062
+ * // [{ id: 1, children: undefined }, { id: 2, children: undefined }]
3063
+ * ```
2271
3064
  */
2272
3065
  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[];
2273
3066
  //#endregion
2274
3067
  //#region src/utils/typeof/isAbortSignal.d.ts
3068
+ /**
3069
+ * 检查 value 是否为 AbortSignal
3070
+ * @param value 待检查值
3071
+ * @returns 是否为 AbortSignal
3072
+ */
2275
3073
  declare function isAbortSignal(value: unknown): value is AbortSignal;
2276
3074
  //#endregion
2277
3075
  //#region src/utils/typeof/isArray.d.ts
2278
3076
  type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
3077
+ /**
3078
+ * 检查 value 是否为数组
3079
+ *
3080
+ * @param value 待检查值
3081
+ * @returns 是否为数组
3082
+ * @example
3083
+ * ```ts
3084
+ * isArray([]); // true
3085
+ * ```
3086
+ */
2279
3087
  declare function isArray(value: unknown): value is unknown[];
3088
+ /**
3089
+ * 检查 value 是否为 TypedArray
3090
+ *
3091
+ * @param value 待检查值
3092
+ * @returns 是否为 TypedArray
3093
+ * @example
3094
+ * ```ts
3095
+ * isTypedArray(new Int8Array()); // true
3096
+ * ```
3097
+ */
2280
3098
  declare function isTypedArray(value: unknown): value is TypedArray;
2281
3099
  //#endregion
2282
3100
  //#region src/utils/typeof/isBigInt.d.ts
3101
+ /**
3102
+ * 检查 value 是否为 BigInt
3103
+ * @param value 待检查值
3104
+ * @returns 是否为 BigInt
3105
+ */
2283
3106
  declare function isBigInt(value: unknown): value is bigint;
2284
3107
  //#endregion
2285
3108
  //#region src/utils/typeof/isBlob.d.ts
3109
+ /**
3110
+ * 检查 value 是否为 Blob
3111
+ * @param value 待检查值
3112
+ * @returns 是否为 Blob
3113
+ */
2286
3114
  declare function isBlob(value: unknown): value is Blob;
3115
+ declare function isFile(value: unknown): value is File;
2287
3116
  //#endregion
2288
3117
  //#region src/utils/typeof/isBoolean.d.ts
3118
+ /**
3119
+ * 检查 value 是否为 Boolean
3120
+ * @param value 待检查值
3121
+ * @returns 是否为 Boolean
3122
+ */
2289
3123
  declare function isBoolean(value: unknown): value is boolean;
2290
3124
  //#endregion
2291
3125
  //#region src/utils/typeof/isClass.d.ts
3126
+ /**
3127
+ * 检查 value 是否为 Class
3128
+ *
3129
+ * @param value 待检查值
3130
+ * @returns 是否为 Class
3131
+ * @example
3132
+ * ```ts
3133
+ * class A {}
3134
+ * isClass(A); // true
3135
+ * isClass(() => {}); // false
3136
+ * ```
3137
+ */
2292
3138
  declare function isClass(value: unknown): value is Class<AnyObject>;
2293
3139
  //#endregion
2294
3140
  //#region src/utils/typeof/isDate.d.ts
2295
- declare function isDate(value: unknown): value is Date;
3141
+ /**
3142
+ * 检查 value 是否为 Date 对象
3143
+ *
3144
+ * @param value 待检查值
3145
+ * @param invalidCheck 是否要求日期有效(非 Invalid Date)。默认 true
3146
+ * - true: 仅当是有效 Date 对象时返回 true(排除 new Date('invalid'))
3147
+ * - false: 只要 [[Prototype]] 是 Date 即返回 true(包含 Invalid Date)
3148
+ * @returns 是否为 Date 对象,根据 invalidCheck 返回不同语义的 Date 判定
3149
+ *
3150
+ * @example
3151
+ * ```ts
3152
+ * isDate(new Date()); // true
3153
+ * isDate(new Date('invalid')); // false
3154
+ * isDate(new Date('invalid'), false); // true
3155
+ * isDate(null); // false
3156
+ * isDate({}); // false
3157
+ * ```
3158
+ */
3159
+ declare function isDate(value: unknown, invalidCheck?: boolean): value is Date;
3160
+ //#endregion
3161
+ //#region src/utils/typeof/isEnumeration.d.ts
3162
+ /**
3163
+ * 判断一个值是否为有效的枚举
3164
+ * - 枚举不能为空
3165
+ * - 枚举所有的值必须是 string 或 number
3166
+ *
3167
+ * @param enumeration 待检查值
3168
+ * @returns 是否为有效的枚举
3169
+ */
3170
+ declare function isEnumeration(enumeration: unknown): [boolean, boolean];
2296
3171
  //#endregion
2297
3172
  //#region src/utils/typeof/isEqual.d.ts
2298
3173
  /**
2299
- * 检查给定的值是否相等
2300
- * @reference https://github.com/radashi-org/radashi/blob/main/src/typed/isEqual.ts
3174
+ * 深度比较两个值是否相等
2301
3175
  *
2302
- * @param {T} x
2303
- * @param {T} y
3176
+ * @param value 待比较值 A
3177
+ * @param other 待比较值 B
3178
+ * @returns 是否相等
3179
+ * @example
3180
+ * ```ts
3181
+ * isEqual({ a: 1 }, { a: 1 }); // true
3182
+ * ```
2304
3183
  */
2305
- declare function isEqual<T>(x: T, y: T): boolean;
3184
+ declare function isEqual(x: unknown, y: unknown): boolean;
2306
3185
  //#endregion
2307
3186
  //#region src/utils/typeof/isError.d.ts
3187
+ /**
3188
+ * 检查 value 是否为 Error 对象
3189
+ * @param value 待检查值
3190
+ * @returns 是否为 Error
3191
+ */
2308
3192
  declare function isError(value: unknown): value is Error;
2309
3193
  //#endregion
2310
3194
  //#region src/utils/typeof/isFalsy.d.ts
2311
- declare function isFalsy(value: unknown): boolean;
3195
+ /**
3196
+ * 检查 value 是否为 Falsy 值 (false, 0, "", null, undefined, NaN)
3197
+ * @param value 待检查值
3198
+ * @returns 是否为 Falsy
3199
+ */
3200
+ declare function isFalsy(value: unknown): value is false | 0 | "" | null | undefined;
2312
3201
  declare function isFalsyLike(value: unknown): boolean;
2313
3202
  //#endregion
2314
- //#region src/utils/typeof/isFile.d.ts
2315
- declare function isFile(value: unknown): value is File;
2316
- //#endregion
2317
3203
  //#region src/utils/typeof/isFunction.d.ts
3204
+ /**
3205
+ * 检查 value 是否为 Function
3206
+ * @param value 待检查值
3207
+ * @returns 是否为 Function
3208
+ */
2318
3209
  declare function isFunction(value: unknown): value is AnyFunction;
3210
+ /**
3211
+ * 检查 value 是否为 AsyncFunction
3212
+ * @param value 待检查值
3213
+ * @returns 是否为 AsyncFunction
3214
+ */
2319
3215
  declare function isAsyncFunction(value: unknown): value is AnyAsyncFunction;
3216
+ /**
3217
+ * 检查 value 是否为 GeneratorFunction
3218
+ * @param value 待检查值
3219
+ * @returns 是否为 GeneratorFunction
3220
+ */
2320
3221
  declare function isGeneratorFunction(value: unknown): value is AnyGeneratorFunction;
3222
+ /**
3223
+ * 检查 value 是否为 AsyncGeneratorFunction
3224
+ * @param value 待检查值
3225
+ * @returns 是否为 AsyncGeneratorFunction
3226
+ */
2321
3227
  declare function isAsyncGeneratorFunction(value: unknown): value is AnyAsyncGeneratorFunction;
2322
3228
  //#endregion
2323
3229
  //#region src/utils/typeof/isIterable.d.ts
3230
+ /**
3231
+ * 检查 value 是否为可迭代对象 (Iterable)
3232
+ * @param value 待检查值
3233
+ * @returns 是否为 Iterable
3234
+ */
2324
3235
  declare function isIterable(value: unknown): value is {
2325
3236
  [Symbol.iterator]: () => Iterator<unknown>;
2326
3237
  };
2327
3238
  //#endregion
2328
3239
  //#region src/utils/typeof/isMap.d.ts
3240
+ /**
3241
+ * 检查 value 是否为 Map
3242
+ * @param value 待检查值
3243
+ * @returns 是否为 Map
3244
+ */
2329
3245
  declare function isMap(value: unknown): value is Map<unknown, unknown>;
3246
+ /**
3247
+ * 检查 value 是否为 WeakMap
3248
+ * @param value 待检查值
3249
+ * @returns 是否为 WeakMap
3250
+ */
2330
3251
  declare function isWeakMap(value: unknown): value is WeakMap<AnyObject, unknown>;
2331
3252
  //#endregion
2332
3253
  //#region src/utils/typeof/isNull.d.ts
3254
+ /**
3255
+ * 检查 value 是否为 null
3256
+ * @param value 待检查值
3257
+ * @returns 是否为 null
3258
+ */
2333
3259
  declare function isNull(value: unknown): value is null;
2334
3260
  //#endregion
2335
3261
  //#region src/utils/typeof/isNumber.d.ts
@@ -2337,13 +3263,21 @@ declare function isNull(value: unknown): value is null;
2337
3263
  * 检查 value 是否为 number 类型
2338
3264
  *
2339
3265
  * @param value 待检查值
2340
- * @param checkNaN 是否排除 `NaN`,默认为 `true`
3266
+ * @param NaNCheck 是否排除 `NaN`,默认为 `true`
3267
+ * @returns 是否为 number
3268
+ * @example
3269
+ * ```ts
3270
+ * isNumber(1); // true
3271
+ * isNumber(NaN); // false (default)
3272
+ * isNumber(NaN, false); // true
3273
+ * ```
2341
3274
  */
2342
- declare function isNumber(value: unknown, checkNaN?: boolean): value is number;
3275
+ declare function isNumber(value: unknown, NaNCheck?: boolean): value is number;
2343
3276
  /**
2344
3277
  * 检查 value 是否为 NaN
2345
3278
  *
2346
3279
  * @param value 待检查值
3280
+ * @returns 是否为 NaN
2347
3281
  */
2348
3282
  declare function isNaN(value: unknown): value is number;
2349
3283
  /**
@@ -2351,6 +3285,7 @@ declare function isNaN(value: unknown): value is number;
2351
3285
  *
2352
3286
  * @param value 待检查值
2353
3287
  * @param safeCheck 是否附加安全数检查
3288
+ * @returns 是否为整数
2354
3289
  */
2355
3290
  declare function isInteger(value: unknown, safeCheck?: boolean): value is number;
2356
3291
  /**
@@ -2391,11 +3326,28 @@ declare function isInfinityLike(value: unknown): boolean;
2391
3326
  *
2392
3327
  * @param value 待检查值
2393
3328
  * @param prototypeCheck 是否进行原型检查,默认 `true`
3329
+ * @returns 是否为 Plain Object (当 checkPrototype=true) 或 object
3330
+ * @example
3331
+ * ```ts
3332
+ * isObject({}); // true
3333
+ * isObject(new Date()); // false (because prototype is not Object.prototype)
3334
+ * isObject(new Date(), false); // true (is object type)
3335
+ * ```
2394
3336
  */
2395
3337
  declare function isObject(value: unknown, prototypeCheck?: boolean): value is Record<PropertyKey, unknown>;
2396
3338
  //#endregion
2397
3339
  //#region src/utils/typeof/isPromise.d.ts
3340
+ /**
3341
+ * 检查 value 是否为 Promise
3342
+ * @param value 待检查值
3343
+ * @returns 是否为 Promise
3344
+ */
2398
3345
  declare function isPromise(value: unknown): value is Promise<unknown>;
3346
+ /**
3347
+ * 检查 value 是否为 PromiseLike (thenable)
3348
+ * @param value 待检查值
3349
+ * @returns 是否为 PromiseLike
3350
+ */
2399
3351
  declare function isPromiseLike(value: unknown): value is PromiseLike<unknown>;
2400
3352
  //#endregion
2401
3353
  //#region src/utils/typeof/isReadableStream.d.ts
@@ -2408,13 +3360,33 @@ declare function isPromiseLike(value: unknown): value is PromiseLike<unknown>;
2408
3360
  *
2409
3361
  * ⚠️ Note: In older Node.js (<18) or with non-compliant polyfills, this may return false positives or negatives.
2410
3362
  */
3363
+ /**
3364
+ * 检查 value 是否为 ReadableStream
3365
+ * @param value 待检查值
3366
+ * @returns 是否为 ReadableStream
3367
+ */
2411
3368
  declare function isReadableStream(value: unknown): value is ReadableStream;
2412
3369
  //#endregion
2413
3370
  //#region src/utils/typeof/isRegExp.d.ts
3371
+ /**
3372
+ * 检查 value 是否为 RegExp
3373
+ * @param value 待检查值
3374
+ * @returns 是否为 RegExp
3375
+ */
2414
3376
  declare function isRegExp(value: unknown): value is RegExp;
2415
3377
  //#endregion
2416
3378
  //#region src/utils/typeof/isSet.d.ts
3379
+ /**
3380
+ * 检查 value 是否为 Set
3381
+ * @param value 待检查值
3382
+ * @returns 是否为 Set
3383
+ */
2417
3384
  declare function isSet(value: unknown): value is Set<unknown>;
3385
+ /**
3386
+ * 检查 value 是否为 WeakSet
3387
+ * @param value 待检查值
3388
+ * @returns 是否为 WeakSet
3389
+ */
2418
3390
  declare function isWeakSet(value: unknown): value is WeakSet<AnyObject>;
2419
3391
  //#endregion
2420
3392
  //#region src/utils/typeof/isString.d.ts
@@ -2423,23 +3395,55 @@ declare function isWeakSet(value: unknown): value is WeakSet<AnyObject>;
2423
3395
  *
2424
3396
  * @param value 待检查值
2425
3397
  * @param checkEmpty 是否排除空字符串
3398
+ * @returns 是否为字符串
3399
+ * @example
3400
+ * ```ts
3401
+ * isString("abc"); // true
3402
+ * isString(""); // true
3403
+ * isString("", true); // false
3404
+ * ```
2426
3405
  */
2427
3406
  declare function isString(value: unknown, checkEmpty?: boolean): value is string;
2428
3407
  //#endregion
2429
3408
  //#region src/utils/typeof/isSymbol.d.ts
3409
+ /**
3410
+ * 检查 value 是否为 Symbol
3411
+ * @param value 待检查值
3412
+ * @returns 是否为 Symbol
3413
+ */
2430
3414
  declare function isSymbol(value: unknown): value is symbol;
2431
3415
  //#endregion
2432
3416
  //#region src/utils/typeof/isUndefined.d.ts
3417
+ /**
3418
+ * 检查 value 是否为 undefined
3419
+ * @param value 待检查值
3420
+ * @returns 是否为 undefined
3421
+ */
2433
3422
  declare function isUndefined(value: unknown): value is undefined;
2434
3423
  //#endregion
2435
3424
  //#region src/utils/typeof/isURLSearchParams.d.ts
3425
+ /**
3426
+ * 检查 value 是否为 URLSearchParams
3427
+ * @param value 待检查值
3428
+ * @returns 是否为 URLSearchParams
3429
+ */
2436
3430
  declare function isURLSearchParams(value: unknown): value is URLSearchParams;
2437
3431
  //#endregion
2438
3432
  //#region src/utils/typeof/isWebSocket.d.ts
3433
+ /**
3434
+ * 检查 value 是否为 WebSocket
3435
+ * @param value 待检查值
3436
+ * @returns 是否为 WebSocket
3437
+ */
2439
3438
  declare function isWebSocket(value: unknown): value is WebSocket;
2440
3439
  //#endregion
2441
3440
  //#region src/utils/typeof/isWindow.d.ts
3441
+ /**
3442
+ * 检查 value 是否为 Window
3443
+ * @param value 待检查值
3444
+ * @returns 是否为 Window
3445
+ */
2442
3446
  declare function isWindow(value: unknown): value is Window;
2443
3447
  //#endregion
2444
- 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 };
3448
+ export { arrayCast, arrayCompete, arrayCounting, arrayDifference, arrayFirst, arrayFork, arrayIntersection, arrayLast, arrayMerge, arrayPick, arrayReplace, arraySplit, arrayUnzip, arrayZip, arrayZipToObject, cloneDeep, enumEntries, enumKeys, enumValues, getTimeZone, isAbortSignal, isArray, isAsyncFunction, isAsyncGeneratorFunction, isBigInt, isBlob, isBoolean, isClass, isDate, isEnumeration, isEqual, isError, isFalsy, isFalsyLike, isFile, isFunction, isGeneratorFunction, isIOSMobile, 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, isWindow, isWithinInterval, mapEntries, objectAssign, objectCrush, objectEntries, objectInvert, objectKeys, objectOmit, objectPick, objectValues, rowsToTree, stringInitialCase, stringReplace, stringTemplate, stringToJson, stringToNumber, stringToPosix, stringToValues, stringTrim, stringTruncate, to, toMathBignumber, toMathDecimal, toMathEvaluate, treeFilter, treeFind, treeForEach, treeMap, treeToRows };
2445
3449
  //# sourceMappingURL=index.d.ts.map