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