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