@rzl-zone/utils-js 3.1.0-beta.2 → 3.1.1-beta.0
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/NumberRangeUnion-DC-C3_Kq.d.ts +23 -23
- package/dist/any-BmdI8UbK.d.ts +56 -56
- package/dist/arrays-normalize-recursive-CnjYJ9xg.d.ts +66 -66
- package/dist/assertions/index.cjs +1 -1
- package/dist/assertions/index.d.ts +396 -396
- package/dist/assertions/index.js +1 -1
- package/dist/chunk-26W3VZIK.cjs +1 -0
- package/dist/chunk-2KRCHXFG.cjs +2 -0
- package/dist/{chunk-TQMZ2LPI.js → chunk-33ZLH266.js} +1 -1
- package/dist/{chunk-VQLAPEL3.js → chunk-4L4EJTNZ.js} +1 -1
- package/dist/{chunk-CK3BZGEU.js → chunk-5Q37AP7P.js} +1 -1
- package/dist/chunk-7CHFAMS2.js +1 -0
- package/dist/{chunk-REFMEB4A.js → chunk-7MMJZ6HS.js} +1 -1
- package/dist/chunk-7TC6DE3J.cjs +1 -0
- package/dist/{chunk-K4PLGD7C.js → chunk-7VX33E3V.js} +1 -1
- package/dist/chunk-BEZPD44N.cjs +1 -0
- package/dist/{chunk-2AUUPGMN.js → chunk-BI263OHW.js} +1 -1
- package/dist/{chunk-LVUSFXQS.cjs → chunk-CII6WWLO.cjs} +1 -1
- package/dist/{chunk-OX6RLS2F.cjs → chunk-D5TYPCWU.cjs} +1 -1
- package/dist/{chunk-MWLEM7ED.js → chunk-EEQY5QUG.js} +1 -1
- package/dist/chunk-ESJYBIYH.js +1 -0
- package/dist/{chunk-MJAW5RAK.js → chunk-EWYPSKKM.js} +1 -1
- package/dist/chunk-EXCOQLWX.cjs +1 -0
- package/dist/chunk-FWQVTMYA.cjs +1 -0
- package/dist/{chunk-25G6B35W.js → chunk-G4EWCRKS.js} +1 -1
- package/dist/{chunk-PFLNHD4B.cjs → chunk-G7R5XZRM.cjs} +1 -1
- package/dist/{chunk-EXXLUO7L.cjs → chunk-GGEV7LXX.cjs} +1 -1
- package/dist/{chunk-VTR75UID.cjs → chunk-HJOZOENU.cjs} +1 -1
- package/dist/{chunk-HXTACM3O.cjs → chunk-IRDZVLNZ.cjs} +1 -1
- package/dist/chunk-IW73G523.cjs +1 -0
- package/dist/chunk-IY5OZAB3.cjs +1 -0
- package/dist/{chunk-467VEMJH.js → chunk-J4NCYYGS.js} +1 -1
- package/dist/{chunk-RHIBYOFQ.js → chunk-J7JAZAJD.js} +1 -1
- package/dist/{chunk-JQZUWBIX.js → chunk-JYNSO7ZY.js} +1 -1
- package/dist/{chunk-UUMKL74S.js → chunk-K3UVKYEU.js} +1 -1
- package/dist/{chunk-ME5OV5HN.js → chunk-LQ76EDZG.js} +1 -1
- package/dist/chunk-MROH35V3.cjs +1 -0
- package/dist/chunk-NJSAV73S.js +1 -0
- package/dist/{chunk-HXST7RJB.js → chunk-NR44SNYE.js} +1 -1
- package/dist/{chunk-BLCANGFS.js → chunk-NXMTWY77.js} +1 -1
- package/dist/chunk-OZCQZO2V.cjs +4 -0
- package/dist/chunk-Q3NTKN5I.cjs +1 -0
- package/dist/{chunk-NSVLG7NY.js → chunk-QDNSC57Z.js} +1 -1
- package/dist/{chunk-NUVGETPD.js → chunk-QGXTL5ZH.js} +1 -1
- package/dist/{chunk-D43GV6EF.cjs → chunk-QSQDP7L2.cjs} +1 -1
- package/dist/{chunk-U4TZO7WV.js → chunk-S5M33A4O.js} +1 -1
- package/dist/{chunk-S7GMG4TB.js → chunk-SGTHOQQ2.js} +1 -1
- package/dist/chunk-SL3RQOWA.js +1 -0
- package/dist/{chunk-NUHOOAUN.cjs → chunk-SZPWZZYG.cjs} +1 -1
- package/dist/{chunk-RHE3M2NJ.cjs → chunk-UA4B7JBO.cjs} +1 -1
- package/dist/chunk-UQDJF5RR.cjs +1 -0
- package/dist/chunk-UTQUYABU.cjs +1 -0
- package/dist/{chunk-G72VSVGO.js → chunk-VPW3DRV5.js} +1 -1
- package/dist/{chunk-PSWITZK5.js → chunk-W32WALNU.js} +1 -1
- package/dist/chunk-XGZ6K753.cjs +1 -0
- package/dist/chunk-YFTR64N5.cjs +1 -0
- package/dist/chunk-ZFDS7W6B.cjs +1 -0
- package/dist/chunk-ZQOLZE6Z.cjs +1 -0
- package/dist/conversions/index.cjs +1 -1
- package/dist/conversions/index.d.ts +1285 -1285
- package/dist/conversions/index.js +1 -1
- package/dist/env/index.d.ts +14 -14
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.d.ts +109 -109
- package/dist/events/index.js +1 -1
- package/dist/extends-Bk_SBGdT.d.ts +330 -330
- package/dist/formatting/index.cjs +1 -1
- package/dist/formatting/index.d.ts +855 -855
- package/dist/formatting/index.js +1 -1
- package/dist/generator/index.cjs +1 -1
- package/dist/generator/index.d.ts +155 -155
- package/dist/generator/index.js +1 -1
- package/dist/if-CvT4R7Kh.d.ts +16 -16
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/is-array--YjXV-Wx.d.ts +1084 -1084
- package/dist/isPlainObject-BVhBAPHX.d.ts +154 -154
- package/dist/never-BfayMBF9.d.ts +64 -64
- package/dist/next/index.cjs +5 -5
- package/dist/next/index.d.ts +183 -183
- package/dist/next/index.js +1 -1
- package/dist/next/server/index.cjs +1 -1
- package/dist/next/server/index.d.ts +25 -25
- package/dist/next/server/index.js +1 -1
- package/dist/nils-DMz3kU7M.d.ts +155 -155
- package/dist/omit-VvmIsZmX.d.ts +25 -25
- package/dist/operations/index.cjs +1 -1
- package/dist/operations/index.d.ts +120 -120
- package/dist/operations/index.js +1 -1
- package/dist/parsers/index.cjs +1 -1
- package/dist/parsers/index.d.ts +34 -34
- package/dist/parsers/index.js +1 -1
- package/dist/predicates/index.cjs +1 -1
- package/dist/predicates/index.d.ts +1674 -1674
- package/dist/predicates/index.js +1 -1
- package/dist/prettify-C4xLcYOP.d.ts +328 -328
- package/dist/promise/index.cjs +1 -1
- package/dist/promise/index.d.ts +29 -29
- package/dist/promise/index.js +1 -1
- package/dist/rzl-utils.global.js +1 -1
- package/dist/string-XA-til3C.d.ts +318 -318
- package/dist/strings/index.cjs +1 -1
- package/dist/strings/index.d.ts +690 -690
- package/dist/strings/index.js +1 -1
- package/dist/stylings/index.cjs +1 -1
- package/dist/stylings/index.d.ts +35 -35
- package/dist/stylings/index.js +1 -1
- package/dist/type-data-DDs-u2kq.d.ts +241 -241
- package/dist/types/index.d.ts +3264 -3264
- package/dist/urls/index.cjs +1 -1
- package/dist/urls/index.d.ts +373 -373
- package/dist/urls/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2JQQQ625.js +0 -1
- package/dist/chunk-445TAVT4.cjs +0 -1
- package/dist/chunk-6Q4I2RPC.cjs +0 -1
- package/dist/chunk-6SMJMZ7G.cjs +0 -1
- package/dist/chunk-DFSTVQFI.cjs +0 -1
- package/dist/chunk-DYRDBYPF.cjs +0 -1
- package/dist/chunk-GAJTFCUA.js +0 -1
- package/dist/chunk-GOJNH55O.cjs +0 -1
- package/dist/chunk-IJTZWWRJ.cjs +0 -1
- package/dist/chunk-ISJ33O2J.cjs +0 -1
- package/dist/chunk-JISH2VGG.js +0 -1
- package/dist/chunk-KZQB7H4E.cjs +0 -1
- package/dist/chunk-LUVV5KSD.cjs +0 -2
- package/dist/chunk-MF5Y5K4N.cjs +0 -1
- package/dist/chunk-O5VXBNUQ.cjs +0 -4
- package/dist/chunk-O7SJR4CY.cjs +0 -1
- package/dist/chunk-PYUVKHUF.cjs +0 -1
- package/dist/chunk-XFCJDSB2.cjs +0 -1
- package/dist/chunk-XOYX4PLZ.cjs +0 -1
- package/dist/chunk-Z6FLCEN6.js +0 -1
- package/dist/chunk-ZO5364A6.cjs +0 -1
|
@@ -1,367 +1,367 @@
|
|
|
1
1
|
import{I as If}from'./if-CvT4R7Kh.js';import{I as IsNever}from'./never-BfayMBF9.js';
|
|
2
2
|
/** -------------------------------------------------------
|
|
3
|
-
* * ***Arrayable.***
|
|
4
|
-
* -------------------------------------------------------
|
|
5
|
-
* Represents a type that can be either:
|
|
6
|
-
* - a single value of type `T`, or
|
|
7
|
-
* - an array of values of type `T`.
|
|
8
|
-
*
|
|
9
|
-
* Useful when a function or API accepts **either one item or multiple items**.
|
|
10
|
-
*
|
|
11
|
-
* @template T - The element type.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* function toArray<T>(input: Arrayable<T>): T[] {
|
|
16
|
-
* return Array.isArray(input) ? input : [input];
|
|
17
|
-
* }
|
|
18
|
-
*
|
|
19
|
-
* type A = Arrayable<string>;
|
|
20
|
-
* // ➔ string | string[]
|
|
21
|
-
*
|
|
22
|
-
* const a: A = "foo";
|
|
23
|
-
* const b: A = ["foo", "bar"];
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
3
|
+
* * ***Arrayable.***
|
|
4
|
+
* -------------------------------------------------------
|
|
5
|
+
* Represents a type that can be either:
|
|
6
|
+
* - a single value of type `T`, or
|
|
7
|
+
* - an array of values of type `T`.
|
|
8
|
+
*
|
|
9
|
+
* Useful when a function or API accepts **either one item or multiple items**.
|
|
10
|
+
*
|
|
11
|
+
* @template T - The element type.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* function toArray<T>(input: Arrayable<T>): T[] {
|
|
16
|
+
* return Array.isArray(input) ? input : [input];
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* type A = Arrayable<string>;
|
|
20
|
+
* // ➔ string | string[]
|
|
21
|
+
*
|
|
22
|
+
* const a: A = "foo";
|
|
23
|
+
* const b: A = ["foo", "bar"];
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
26
|
type Arrayable<T>=T|Array<T>;
|
|
27
27
|
/** -------------------------------------------------------
|
|
28
|
-
* * ***MutableArray.***
|
|
29
|
-
* -------------------------------------------------------
|
|
30
|
-
* Recursively creates a **mutable version** of a readonly array, tuple, or object type.
|
|
31
|
-
*
|
|
32
|
-
* By default, TypeScript infers tuple/array literals as `readonly` (especially with `as const`).
|
|
33
|
-
* This utility removes the `readonly` modifier from all elements recursively,
|
|
34
|
-
* turning a readonly tuple, array, or object into a mutable one.
|
|
35
|
-
*
|
|
36
|
-
* Optionally, if `Widen` is `true`, literal types (`1`, `'foo'`, `true`) are widened to
|
|
37
|
-
* their primitive equivalents (`number`, `string`, `boolean`) for easier assignment.
|
|
38
|
-
*
|
|
39
|
-
* @template T - The readonly array, tuple, or object type to make mutable.
|
|
40
|
-
* @template Widen - Whether to widen literal primitive types to their base types (default: `false`).
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```ts
|
|
44
|
-
* type A = readonly [1, 2, 3];
|
|
45
|
-
* type B = MutableArray<A>;
|
|
46
|
-
* // ➔ [1, 2, 3]
|
|
47
|
-
*
|
|
48
|
-
* const x: A = [1, 2, 3] as const;
|
|
49
|
-
* // x[0] = 9; // ❌ Error: read-only
|
|
50
|
-
*
|
|
51
|
-
* const y: MutableArray<B,true> = [1, 2, 3];
|
|
52
|
-
* y[0] = 9; // ✅ Allowed
|
|
53
|
-
*
|
|
54
|
-
* // Recursive example with objects
|
|
55
|
-
* type Obj = readonly [{ a: 1, b: readonly [2] }];
|
|
56
|
-
* type MutableObj = MutableArray<Obj, true>;
|
|
57
|
-
* // ➔ [{ a: number; b: [number]; }]
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
28
|
+
* * ***MutableArray.***
|
|
29
|
+
* -------------------------------------------------------
|
|
30
|
+
* Recursively creates a **mutable version** of a readonly array, tuple, or object type.
|
|
31
|
+
*
|
|
32
|
+
* By default, TypeScript infers tuple/array literals as `readonly` (especially with `as const`).
|
|
33
|
+
* This utility removes the `readonly` modifier from all elements recursively,
|
|
34
|
+
* turning a readonly tuple, array, or object into a mutable one.
|
|
35
|
+
*
|
|
36
|
+
* Optionally, if `Widen` is `true`, literal types (`1`, `'foo'`, `true`) are widened to
|
|
37
|
+
* their primitive equivalents (`number`, `string`, `boolean`) for easier assignment.
|
|
38
|
+
*
|
|
39
|
+
* @template T - The readonly array, tuple, or object type to make mutable.
|
|
40
|
+
* @template Widen - Whether to widen literal primitive types to their base types (default: `false`).
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* type A = readonly [1, 2, 3];
|
|
45
|
+
* type B = MutableArray<A>;
|
|
46
|
+
* // ➔ [1, 2, 3]
|
|
47
|
+
*
|
|
48
|
+
* const x: A = [1, 2, 3] as const;
|
|
49
|
+
* // x[0] = 9; // ❌ Error: read-only
|
|
50
|
+
*
|
|
51
|
+
* const y: MutableArray<B,true> = [1, 2, 3];
|
|
52
|
+
* y[0] = 9; // ✅ Allowed
|
|
53
|
+
*
|
|
54
|
+
* // Recursive example with objects
|
|
55
|
+
* type Obj = readonly [{ a: 1, b: readonly [2] }];
|
|
56
|
+
* type MutableObj = MutableArray<Obj, true>;
|
|
57
|
+
* // ➔ [{ a: number; b: [number]; }]
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
60
|
type MutableArray<T,Widen extends boolean=false>=T extends(...args:any)=>any?T:T extends readonly any[]?{-readonly [K in keyof T]:MutableArray<T[K],Widen>;}:T extends object?{-readonly [K in keyof T]:MutableArray<T[K],Widen>;}:Widen extends true?T extends number?number:T extends string?string:T extends boolean?boolean:T extends bigint?bigint:T extends symbol?symbol:T:T;
|
|
61
61
|
/** --------------------------------------------------
|
|
62
|
-
* * ***GetArrayElementType.***
|
|
63
|
-
* --------------------------------------------------
|
|
64
|
-
* Gets the element type from a readonly array or tuple.
|
|
65
|
-
*
|
|
66
|
-
* ✅ Useful when working with `as const` arrays to extract the union of literal types.
|
|
67
|
-
*
|
|
68
|
-
* @template T - A readonly array or tuple type.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```ts
|
|
72
|
-
* const roles = ['admin', 'user'] as const;
|
|
73
|
-
* type Role = GetArrayElementType<typeof roles>;
|
|
74
|
-
* // ➔ "admin" | "user"
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
62
|
+
* * ***GetArrayElementType.***
|
|
63
|
+
* --------------------------------------------------
|
|
64
|
+
* Gets the element type from a readonly array or tuple.
|
|
65
|
+
*
|
|
66
|
+
* ✅ Useful when working with `as const` arrays to extract the union of literal types.
|
|
67
|
+
*
|
|
68
|
+
* @template T - A readonly array or tuple type.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const roles = ['admin', 'user'] as const;
|
|
73
|
+
* type Role = GetArrayElementType<typeof roles>;
|
|
74
|
+
* // ➔ "admin" | "user"
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
77
|
type GetArrayElementType<T extends readonly any[]>=T extends readonly(infer U)[]?U:never;
|
|
78
78
|
/** -------------------------------------------------------
|
|
79
|
-
* * ***EmptyArray.***
|
|
80
|
-
* -------------------------------------------------------
|
|
81
|
-
* A type-level utility that returns `T` if it is an ***empty array***,
|
|
82
|
-
* otherwise returns `never`.
|
|
83
|
-
*
|
|
84
|
-
* @template T - The array type to check.
|
|
85
|
-
* @example
|
|
86
|
-
* ```ts
|
|
87
|
-
* type A = EmptyArray<[]>;
|
|
88
|
-
* // ➔ []
|
|
89
|
-
* type B = EmptyArray<[1]>;
|
|
90
|
-
* // ➔ never
|
|
91
|
-
* type C = EmptyArray<string[]>;
|
|
92
|
-
* // ➔ string[]
|
|
93
|
-
* type D = EmptyArray<number[]>;
|
|
94
|
-
* // ➔ number[]
|
|
95
|
-
* type E = EmptyArray<readonly []>;
|
|
96
|
-
* // ➔ readonly []
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
79
|
+
* * ***EmptyArray.***
|
|
80
|
+
* -------------------------------------------------------
|
|
81
|
+
* A type-level utility that returns `T` if it is an ***empty array***,
|
|
82
|
+
* otherwise returns `never`.
|
|
83
|
+
*
|
|
84
|
+
* @template T - The array type to check.
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* type A = EmptyArray<[]>;
|
|
88
|
+
* // ➔ []
|
|
89
|
+
* type B = EmptyArray<[1]>;
|
|
90
|
+
* // ➔ never
|
|
91
|
+
* type C = EmptyArray<string[]>;
|
|
92
|
+
* // ➔ string[]
|
|
93
|
+
* type D = EmptyArray<number[]>;
|
|
94
|
+
* // ➔ number[]
|
|
95
|
+
* type E = EmptyArray<readonly []>;
|
|
96
|
+
* // ➔ readonly []
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
99
|
type EmptyArray<T extends readonly unknown[]>=T extends readonly [ unknown,...unknown[]]?never:T;
|
|
100
100
|
/** -------------------------------------------------------
|
|
101
|
-
* * ***NonEmptyArray.***
|
|
102
|
-
* -------------------------------------------------------
|
|
103
|
-
* A type-level utility that returns `T` if it is a ***non-empty array***,
|
|
104
|
-
* otherwise returns `never`.
|
|
105
|
-
*
|
|
106
|
-
* @template T - The array type to check.
|
|
107
|
-
* @example
|
|
108
|
-
* ```ts
|
|
109
|
-
* type A = NonEmptyArray<[]>;
|
|
110
|
-
* // ➔ never
|
|
111
|
-
* type B = NonEmptyArray<[1]>;
|
|
112
|
-
* // ➔ [1]
|
|
113
|
-
* type C = NonEmptyArray<string[]>;
|
|
114
|
-
* // ➔ never
|
|
115
|
-
* type D = NonEmptyArray<number[]>;
|
|
116
|
-
* // ➔ never
|
|
117
|
-
* type E = NonEmptyArray<readonly []>;
|
|
118
|
-
* // ➔ never
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
101
|
+
* * ***NonEmptyArray.***
|
|
102
|
+
* -------------------------------------------------------
|
|
103
|
+
* A type-level utility that returns `T` if it is a ***non-empty array***,
|
|
104
|
+
* otherwise returns `never`.
|
|
105
|
+
*
|
|
106
|
+
* @template T - The array type to check.
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* type A = NonEmptyArray<[]>;
|
|
110
|
+
* // ➔ never
|
|
111
|
+
* type B = NonEmptyArray<[1]>;
|
|
112
|
+
* // ➔ [1]
|
|
113
|
+
* type C = NonEmptyArray<string[]>;
|
|
114
|
+
* // ➔ never
|
|
115
|
+
* type D = NonEmptyArray<number[]>;
|
|
116
|
+
* // ➔ never
|
|
117
|
+
* type E = NonEmptyArray<readonly []>;
|
|
118
|
+
* // ➔ never
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
121
|
type NonEmptyArray<T extends readonly unknown[]>=If<IsNever<EmptyArray<T>>,T,never>;
|
|
122
122
|
/** -------------------------------------------------------
|
|
123
|
-
* * ***IsEmptyArray.***
|
|
124
|
-
* -------------------------------------------------------
|
|
125
|
-
* A type-level utility that evaluates to `true` if `T` is an ***empty array.***
|
|
126
|
-
* (or can be empty per this definition), otherwise `false`.
|
|
127
|
-
*
|
|
128
|
-
* @template T - The array type to check.
|
|
129
|
-
* @example
|
|
130
|
-
* ```ts
|
|
131
|
-
* type A = IsEmptyArray<[]>;
|
|
132
|
-
* // ➔ true
|
|
133
|
-
* type B = IsEmptyArray<[1]>;
|
|
134
|
-
* // ➔ false
|
|
135
|
-
* type C = IsEmptyArray<string[]>;
|
|
136
|
-
* // ➔ true
|
|
137
|
-
* type D = IsEmptyArray<number[]>;
|
|
138
|
-
* // ➔ true
|
|
139
|
-
* type E = IsEmptyArray<readonly []>;
|
|
140
|
-
* // ➔ true
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
123
|
+
* * ***IsEmptyArray.***
|
|
124
|
+
* -------------------------------------------------------
|
|
125
|
+
* A type-level utility that evaluates to `true` if `T` is an ***empty array.***
|
|
126
|
+
* (or can be empty per this definition), otherwise `false`.
|
|
127
|
+
*
|
|
128
|
+
* @template T - The array type to check.
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* type A = IsEmptyArray<[]>;
|
|
132
|
+
* // ➔ true
|
|
133
|
+
* type B = IsEmptyArray<[1]>;
|
|
134
|
+
* // ➔ false
|
|
135
|
+
* type C = IsEmptyArray<string[]>;
|
|
136
|
+
* // ➔ true
|
|
137
|
+
* type D = IsEmptyArray<number[]>;
|
|
138
|
+
* // ➔ true
|
|
139
|
+
* type E = IsEmptyArray<readonly []>;
|
|
140
|
+
* // ➔ true
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
143
|
type IsEmptyArray<T extends readonly unknown[]>=If<IsNever<EmptyArray<T>>,false,true>;
|
|
144
144
|
/** -------------------------------------------------------
|
|
145
|
-
* * ***IsNonEmptyArray.***
|
|
146
|
-
* -------------------------------------------------------
|
|
147
|
-
* A type-level utility that evaluates to `true` if `T` is a ***non-empty array.***
|
|
148
|
-
* (strictly a non-empty tuple), otherwise `false`.
|
|
149
|
-
*
|
|
150
|
-
* @template T - The array type to check.
|
|
151
|
-
* @example
|
|
152
|
-
* ```ts
|
|
153
|
-
* type A = IsNonEmptyArray<[]>;
|
|
154
|
-
* // ➔ false
|
|
155
|
-
* type B = IsNonEmptyArray<[1]>;
|
|
156
|
-
* // ➔ true
|
|
157
|
-
* type C = IsNonEmptyArray<string[]>;
|
|
158
|
-
* // ➔ false
|
|
159
|
-
* type D = IsNonEmptyArray<number[]>;
|
|
160
|
-
* // ➔ false
|
|
161
|
-
* type E = IsNonEmptyArray<readonly []>;
|
|
162
|
-
* // ➔ false
|
|
163
|
-
* ```
|
|
164
|
-
*/
|
|
145
|
+
* * ***IsNonEmptyArray.***
|
|
146
|
+
* -------------------------------------------------------
|
|
147
|
+
* A type-level utility that evaluates to `true` if `T` is a ***non-empty array.***
|
|
148
|
+
* (strictly a non-empty tuple), otherwise `false`.
|
|
149
|
+
*
|
|
150
|
+
* @template T - The array type to check.
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* type A = IsNonEmptyArray<[]>;
|
|
154
|
+
* // ➔ false
|
|
155
|
+
* type B = IsNonEmptyArray<[1]>;
|
|
156
|
+
* // ➔ true
|
|
157
|
+
* type C = IsNonEmptyArray<string[]>;
|
|
158
|
+
* // ➔ false
|
|
159
|
+
* type D = IsNonEmptyArray<number[]>;
|
|
160
|
+
* // ➔ false
|
|
161
|
+
* type E = IsNonEmptyArray<readonly []>;
|
|
162
|
+
* // ➔ false
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
165
|
type IsNonEmptyArray<T extends readonly unknown[]>=If<IsNever<EmptyArray<T>>,true,false>;
|
|
166
166
|
/** -------------------------------------------------------
|
|
167
|
-
* * ***IfEmptyArray.***
|
|
168
|
-
* -------------------------------------------------------
|
|
169
|
-
* Returns the second argument if `T` is an ***empty array*** (per this utility),
|
|
170
|
-
* otherwise returns the third argument.
|
|
171
|
-
* - Defaults: `IfTrue = true`, `IfFalse = false`.
|
|
172
|
-
*
|
|
173
|
-
* @template T - The array type to check.
|
|
174
|
-
* @template IfTrue - Returned type if `T` is empty by this definition.
|
|
175
|
-
* @template IfFalse - Returned type if `T` is not empty by this definition.
|
|
176
|
-
* @example
|
|
177
|
-
* ```ts
|
|
178
|
-
* type A = IfEmptyArray<[]>;
|
|
179
|
-
* // ➔ true
|
|
180
|
-
* type B = IfEmptyArray<[1]>;
|
|
181
|
-
* // ➔ false
|
|
182
|
-
* type C = IfEmptyArray<string[]>;
|
|
183
|
-
* // ➔ true
|
|
184
|
-
* type D = IfEmptyArray<readonly []>;
|
|
185
|
-
* // ➔ true
|
|
186
|
-
* type E = IfEmptyArray<[], "yes", "no">;
|
|
187
|
-
* // ➔ "yes"
|
|
188
|
-
* type F = IfEmptyArray<[1], "yes", "no">;
|
|
189
|
-
* // ➔ "no"
|
|
190
|
-
* type G = IfEmptyArray<string[], "yes", "no">;
|
|
191
|
-
* // ➔ "yes"
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
167
|
+
* * ***IfEmptyArray.***
|
|
168
|
+
* -------------------------------------------------------
|
|
169
|
+
* Returns the second argument if `T` is an ***empty array*** (per this utility),
|
|
170
|
+
* otherwise returns the third argument.
|
|
171
|
+
* - Defaults: `IfTrue = true`, `IfFalse = false`.
|
|
172
|
+
*
|
|
173
|
+
* @template T - The array type to check.
|
|
174
|
+
* @template IfTrue - Returned type if `T` is empty by this definition.
|
|
175
|
+
* @template IfFalse - Returned type if `T` is not empty by this definition.
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* type A = IfEmptyArray<[]>;
|
|
179
|
+
* // ➔ true
|
|
180
|
+
* type B = IfEmptyArray<[1]>;
|
|
181
|
+
* // ➔ false
|
|
182
|
+
* type C = IfEmptyArray<string[]>;
|
|
183
|
+
* // ➔ true
|
|
184
|
+
* type D = IfEmptyArray<readonly []>;
|
|
185
|
+
* // ➔ true
|
|
186
|
+
* type E = IfEmptyArray<[], "yes", "no">;
|
|
187
|
+
* // ➔ "yes"
|
|
188
|
+
* type F = IfEmptyArray<[1], "yes", "no">;
|
|
189
|
+
* // ➔ "no"
|
|
190
|
+
* type G = IfEmptyArray<string[], "yes", "no">;
|
|
191
|
+
* // ➔ "yes"
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
194
|
type IfEmptyArray<T extends readonly unknown[],IfTrue=true,IfFalse=false>=If<IsEmptyArray<T>,IfTrue,IfFalse>;
|
|
195
195
|
/** -------------------------------------------------------
|
|
196
|
-
* * ***IfNonEmptyArray.***
|
|
197
|
-
* -------------------------------------------------------
|
|
198
|
-
* Returns the second argument if `T` is a ***non-empty array*** (strict tuple),
|
|
199
|
-
* otherwise returns the third argument.
|
|
200
|
-
* - Defaults: `IfTrue = true`, `IfFalse = false`.
|
|
201
|
-
*
|
|
202
|
-
* @template T - The array type to check.
|
|
203
|
-
* @template IfTrue - Returned type if `T` is non-empty by this definition.
|
|
204
|
-
* @template IfFalse - Returned type if `T` is not non-empty by this definition.
|
|
205
|
-
* @example
|
|
206
|
-
* ```ts
|
|
207
|
-
* type A = IfNonEmptyArray<[]>;
|
|
208
|
-
* // ➔ false
|
|
209
|
-
* type B = IfNonEmptyArray<[1]>;
|
|
210
|
-
* // ➔ true
|
|
211
|
-
* type C = IfNonEmptyArray<string[]>;
|
|
212
|
-
* // ➔ false
|
|
213
|
-
* type D = IfNonEmptyArray<readonly []>;
|
|
214
|
-
* // ➔ false
|
|
215
|
-
* type E = IfNonEmptyArray<[1], "yes", "no">;
|
|
216
|
-
* // ➔ "yes"
|
|
217
|
-
* type F = IfNonEmptyArray<[], "yes", "no">;
|
|
218
|
-
* // ➔ "no"
|
|
219
|
-
* type G = IfNonEmptyArray<string[], "yes", "no">;
|
|
220
|
-
* // ➔ "no"
|
|
221
|
-
* ```
|
|
222
|
-
*/
|
|
196
|
+
* * ***IfNonEmptyArray.***
|
|
197
|
+
* -------------------------------------------------------
|
|
198
|
+
* Returns the second argument if `T` is a ***non-empty array*** (strict tuple),
|
|
199
|
+
* otherwise returns the third argument.
|
|
200
|
+
* - Defaults: `IfTrue = true`, `IfFalse = false`.
|
|
201
|
+
*
|
|
202
|
+
* @template T - The array type to check.
|
|
203
|
+
* @template IfTrue - Returned type if `T` is non-empty by this definition.
|
|
204
|
+
* @template IfFalse - Returned type if `T` is not non-empty by this definition.
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts
|
|
207
|
+
* type A = IfNonEmptyArray<[]>;
|
|
208
|
+
* // ➔ false
|
|
209
|
+
* type B = IfNonEmptyArray<[1]>;
|
|
210
|
+
* // ➔ true
|
|
211
|
+
* type C = IfNonEmptyArray<string[]>;
|
|
212
|
+
* // ➔ false
|
|
213
|
+
* type D = IfNonEmptyArray<readonly []>;
|
|
214
|
+
* // ➔ false
|
|
215
|
+
* type E = IfNonEmptyArray<[1], "yes", "no">;
|
|
216
|
+
* // ➔ "yes"
|
|
217
|
+
* type F = IfNonEmptyArray<[], "yes", "no">;
|
|
218
|
+
* // ➔ "no"
|
|
219
|
+
* type G = IfNonEmptyArray<string[], "yes", "no">;
|
|
220
|
+
* // ➔ "no"
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
223
|
type IfNonEmptyArray<T extends readonly unknown[],IfTrue=true,IfFalse=false>=If<IsNonEmptyArray<T>,IfTrue,IfFalse>;
|
|
224
224
|
/** -------------------------------------------------------
|
|
225
|
-
* * ***Not.***
|
|
226
|
-
* -------------------------------------------------------
|
|
227
|
-
* Accepts a boolean type `T` and returns its negation.
|
|
228
|
-
*
|
|
229
|
-
* @template T - Boolean type to negate.
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* ```ts
|
|
233
|
-
* type A = Not<true>; // ➔ false
|
|
234
|
-
* type B = Not<false>; // ➔ true
|
|
235
|
-
* ```
|
|
236
|
-
*/
|
|
225
|
+
* * ***Not.***
|
|
226
|
+
* -------------------------------------------------------
|
|
227
|
+
* Accepts a boolean type `T` and returns its negation.
|
|
228
|
+
*
|
|
229
|
+
* @template T - Boolean type to negate.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```ts
|
|
233
|
+
* type A = Not<true>; // ➔ false
|
|
234
|
+
* type B = Not<false>; // ➔ true
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
237
|
type Not<T extends boolean>=T extends true?false:true;
|
|
238
238
|
/** -------------------------------------------------------
|
|
239
|
-
* * ***PopOptions.***
|
|
240
|
-
* -------------------------------------------------------
|
|
241
|
-
*
|
|
242
|
-
* Configuration options for the {@link Pop} type utility.
|
|
243
|
-
*/
|
|
239
|
+
* * ***PopOptions.***
|
|
240
|
+
* -------------------------------------------------------
|
|
241
|
+
*
|
|
242
|
+
* Configuration options for the {@link Pop} type utility.
|
|
243
|
+
*/
|
|
244
244
|
type PopOptions={
|
|
245
245
|
/**
|
|
246
|
-
* If `true`, {@link Pop} will return a tuple `[Rest, Removed]`
|
|
247
|
-
* instead of just the remaining array.
|
|
248
|
-
*
|
|
249
|
-
* Default: `false`.
|
|
250
|
-
*
|
|
251
|
-
* @example
|
|
252
|
-
* ```ts
|
|
253
|
-
* type Options = { includeRemoved: true };
|
|
254
|
-
* type Result = Pop<[1, 2, 3], Options>; // ➔ [[1, 2], 3]
|
|
255
|
-
* ```
|
|
256
|
-
*/
|
|
246
|
+
* If `true`, {@link Pop} will return a tuple `[Rest, Removed]`
|
|
247
|
+
* instead of just the remaining array.
|
|
248
|
+
*
|
|
249
|
+
* Default: `false`.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* type Options = { includeRemoved: true };
|
|
254
|
+
* type Result = Pop<[1, 2, 3], Options>; // ➔ [[1, 2], 3]
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
257
|
includeRemoved:boolean;};
|
|
258
258
|
/** -------------------------------------------------------
|
|
259
|
-
* * ***Pop.***
|
|
260
|
-
* -------------------------------------------------------
|
|
261
|
-
*
|
|
262
|
-
* Removes the last element from a tuple/array type.
|
|
263
|
-
*
|
|
264
|
-
* If the `includeRemoved` option is `true`, it returns a tuple `[Rest, Removed]`
|
|
265
|
-
* where `Rest` is the array without the last element, and `Removed` is the last element.
|
|
266
|
-
*
|
|
267
|
-
* @template T - The tuple or array to pop from.
|
|
268
|
-
* @template Options - Configuration object. Default `{ includeRemoved: false }`.
|
|
269
|
-
*
|
|
270
|
-
* @example
|
|
271
|
-
* ```ts
|
|
272
|
-
* // Removes last element
|
|
273
|
-
* type Case1 = Pop<[1, 2, 3]>
|
|
274
|
-
* // ➔ [1, 2]
|
|
275
|
-
*
|
|
276
|
-
* // Removes last element and includes the removed value
|
|
277
|
-
* type Case2 = Pop<[1, 2, 3], { includeRemoved: true }>
|
|
278
|
-
* // ➔ [[1, 2], 3]
|
|
279
|
-
*
|
|
280
|
-
* // Edge case: empty array
|
|
281
|
-
* type Case3 = Pop<[]>
|
|
282
|
-
* // ➔ never
|
|
283
|
-
* ```
|
|
284
|
-
*/
|
|
259
|
+
* * ***Pop.***
|
|
260
|
+
* -------------------------------------------------------
|
|
261
|
+
*
|
|
262
|
+
* Removes the last element from a tuple/array type.
|
|
263
|
+
*
|
|
264
|
+
* If the `includeRemoved` option is `true`, it returns a tuple `[Rest, Removed]`
|
|
265
|
+
* where `Rest` is the array without the last element, and `Removed` is the last element.
|
|
266
|
+
*
|
|
267
|
+
* @template T - The tuple or array to pop from.
|
|
268
|
+
* @template Options - Configuration object. Default `{ includeRemoved: false }`.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* // Removes last element
|
|
273
|
+
* type Case1 = Pop<[1, 2, 3]>
|
|
274
|
+
* // ➔ [1, 2]
|
|
275
|
+
*
|
|
276
|
+
* // Removes last element and includes the removed value
|
|
277
|
+
* type Case2 = Pop<[1, 2, 3], { includeRemoved: true }>
|
|
278
|
+
* // ➔ [[1, 2], 3]
|
|
279
|
+
*
|
|
280
|
+
* // Edge case: empty array
|
|
281
|
+
* type Case3 = Pop<[]>
|
|
282
|
+
* // ➔ never
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
285
|
type Pop<T extends readonly unknown[],Options extends PopOptions={includeRemoved:false;}>=IsEmptyArray<T>extends true?never:T extends readonly [...infer Rest extends readonly unknown[],infer Removed]?If<Options["includeRemoved"],[Rest,Removed],Rest>:never;
|
|
286
286
|
/** -------------------------------------------------------
|
|
287
|
-
* * ***Extends.***
|
|
288
|
-
* -------------------------------------------------------
|
|
289
|
-
* Returns a boolean indicating whether the first argument ***extends*** the second argument.
|
|
290
|
-
*
|
|
291
|
-
* @template T - The type to check.
|
|
292
|
-
* @template Base - The type to compare against.
|
|
293
|
-
* @example
|
|
294
|
-
* ```ts
|
|
295
|
-
* type A = Extends<1, number>; // ➔ true
|
|
296
|
-
* type B = Extends<number, 1>; // ➔ false
|
|
297
|
-
* ```
|
|
298
|
-
*/
|
|
287
|
+
* * ***Extends.***
|
|
288
|
+
* -------------------------------------------------------
|
|
289
|
+
* Returns a boolean indicating whether the first argument ***extends*** the second argument.
|
|
290
|
+
*
|
|
291
|
+
* @template T - The type to check.
|
|
292
|
+
* @template Base - The type to compare against.
|
|
293
|
+
* @example
|
|
294
|
+
* ```ts
|
|
295
|
+
* type A = Extends<1, number>; // ➔ true
|
|
296
|
+
* type B = Extends<number, 1>; // ➔ false
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
299
|
type Extends<T,Base>=[T] extends [Base]?true:false;
|
|
300
300
|
/** -------------------------------------------------------
|
|
301
|
-
* * ***NotExtends.***
|
|
302
|
-
* -------------------------------------------------------
|
|
303
|
-
* Returns a boolean indicating whether the first argument does ***not extend*** the second argument.
|
|
304
|
-
*
|
|
305
|
-
* @template T - The type to check.
|
|
306
|
-
* @template Base - The type to compare against.
|
|
307
|
-
* @example
|
|
308
|
-
* ```ts
|
|
309
|
-
* type A = NotExtends<1, number>; // ➔ false
|
|
310
|
-
* type B = NotExtends<number, 1>; // ➔ true
|
|
311
|
-
* ```
|
|
312
|
-
*/
|
|
301
|
+
* * ***NotExtends.***
|
|
302
|
+
* -------------------------------------------------------
|
|
303
|
+
* Returns a boolean indicating whether the first argument does ***not extend*** the second argument.
|
|
304
|
+
*
|
|
305
|
+
* @template T - The type to check.
|
|
306
|
+
* @template Base - The type to compare against.
|
|
307
|
+
* @example
|
|
308
|
+
* ```ts
|
|
309
|
+
* type A = NotExtends<1, number>; // ➔ false
|
|
310
|
+
* type B = NotExtends<number, 1>; // ➔ true
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
313
|
type NotExtends<T,Base>=Not<Extends<T,Base>>;
|
|
314
314
|
/** -------------------------------------------------------
|
|
315
|
-
* * ***IfExtends.***
|
|
316
|
-
* -------------------------------------------------------
|
|
317
|
-
* Conditional: returns the third argument if the first argument ***extends*** the second argument, otherwise returns the fourth argument.
|
|
318
|
-
* - Defaults: `IfTrue = true`, `IfFalse = false`.
|
|
319
|
-
*
|
|
320
|
-
* @template T - The type to check.
|
|
321
|
-
* @template Base - The type to compare against.
|
|
322
|
-
* @template IfTrue - The branch type if condition is met. (default: `true`)
|
|
323
|
-
* @template IfFalse - The branch type if condition is not met. (default: `false`)
|
|
324
|
-
* @example
|
|
325
|
-
* ```ts
|
|
326
|
-
* type A = IfExtends<1, number, "valid">;
|
|
327
|
-
* // ➔ "valid"
|
|
328
|
-
* type B = IfExtends<1, string, "valid", "invalid">;
|
|
329
|
-
* // ➔ "invalid"
|
|
330
|
-
* ```
|
|
331
|
-
*/
|
|
315
|
+
* * ***IfExtends.***
|
|
316
|
+
* -------------------------------------------------------
|
|
317
|
+
* Conditional: returns the third argument if the first argument ***extends*** the second argument, otherwise returns the fourth argument.
|
|
318
|
+
* - Defaults: `IfTrue = true`, `IfFalse = false`.
|
|
319
|
+
*
|
|
320
|
+
* @template T - The type to check.
|
|
321
|
+
* @template Base - The type to compare against.
|
|
322
|
+
* @template IfTrue - The branch type if condition is met. (default: `true`)
|
|
323
|
+
* @template IfFalse - The branch type if condition is not met. (default: `false`)
|
|
324
|
+
* @example
|
|
325
|
+
* ```ts
|
|
326
|
+
* type A = IfExtends<1, number, "valid">;
|
|
327
|
+
* // ➔ "valid"
|
|
328
|
+
* type B = IfExtends<1, string, "valid", "invalid">;
|
|
329
|
+
* // ➔ "invalid"
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
332
|
type IfExtends<T,Base,IfTrue=true,IfFalse=false>=If<Extends<T,Base>,IfTrue,IfFalse>;
|
|
333
333
|
/** -------------------------------------------------------
|
|
334
|
-
* * ***IfNotExtends.***
|
|
335
|
-
* -------------------------------------------------------
|
|
336
|
-
* Conditional: returns the third argument if the first argument does ***not extend*** the second argument, otherwise returns the fourth argument.
|
|
337
|
-
* - Defaults: `IfTrue = true`, `IfFalse = false`.
|
|
338
|
-
*
|
|
339
|
-
* @template T - The type to check.
|
|
340
|
-
* @template Base - The type to compare against.
|
|
341
|
-
* @template IfTrue - The branch type if condition is met. (default: `true`)
|
|
342
|
-
* @template IfFalse - The branch type if condition is not met. (default: `false`)
|
|
343
|
-
* @example
|
|
344
|
-
* ```ts
|
|
345
|
-
* type A = IfNotExtends<1, string, "valid">;
|
|
346
|
-
* // ➔ "valid"
|
|
347
|
-
* type B = IfNotExtends<1, number, "valid", "invalid">;
|
|
348
|
-
* // ➔ "invalid"
|
|
349
|
-
* ```
|
|
350
|
-
*/
|
|
334
|
+
* * ***IfNotExtends.***
|
|
335
|
+
* -------------------------------------------------------
|
|
336
|
+
* Conditional: returns the third argument if the first argument does ***not extend*** the second argument, otherwise returns the fourth argument.
|
|
337
|
+
* - Defaults: `IfTrue = true`, `IfFalse = false`.
|
|
338
|
+
*
|
|
339
|
+
* @template T - The type to check.
|
|
340
|
+
* @template Base - The type to compare against.
|
|
341
|
+
* @template IfTrue - The branch type if condition is met. (default: `true`)
|
|
342
|
+
* @template IfFalse - The branch type if condition is not met. (default: `false`)
|
|
343
|
+
* @example
|
|
344
|
+
* ```ts
|
|
345
|
+
* type A = IfNotExtends<1, string, "valid">;
|
|
346
|
+
* // ➔ "valid"
|
|
347
|
+
* type B = IfNotExtends<1, number, "valid", "invalid">;
|
|
348
|
+
* // ➔ "invalid"
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
351
|
type IfNotExtends<T,Base,IfTrue=true,IfFalse=false>=If<NotExtends<T,Base>,IfTrue,IfFalse>;
|
|
352
352
|
/** -------------------------------------------------------
|
|
353
|
-
* * ***ExtendsArr.***
|
|
354
|
-
* -------------------------------------------------------
|
|
355
|
-
* Returns a boolean indicating whether every element of the first array argument ***extends*** the second argument.
|
|
356
|
-
*
|
|
357
|
-
* @template T - The array to check.
|
|
358
|
-
* @template Base - The type to compare each element against.
|
|
359
|
-
* @example
|
|
360
|
-
* ```ts
|
|
361
|
-
* type A = ExtendsArr<[1, 2, 3], number>;
|
|
362
|
-
* // ➔ true
|
|
363
|
-
* type B = ExtendsArr<[1, "2", 3], number>;
|
|
364
|
-
* // ➔ false
|
|
365
|
-
* ```
|
|
366
|
-
*/
|
|
353
|
+
* * ***ExtendsArr.***
|
|
354
|
+
* -------------------------------------------------------
|
|
355
|
+
* Returns a boolean indicating whether every element of the first array argument ***extends*** the second argument.
|
|
356
|
+
*
|
|
357
|
+
* @template T - The array to check.
|
|
358
|
+
* @template Base - The type to compare each element against.
|
|
359
|
+
* @example
|
|
360
|
+
* ```ts
|
|
361
|
+
* type A = ExtendsArr<[1, 2, 3], number>;
|
|
362
|
+
* // ➔ true
|
|
363
|
+
* type B = ExtendsArr<[1, "2", 3], number>;
|
|
364
|
+
* // ➔ false
|
|
365
|
+
* ```
|
|
366
|
+
*/
|
|
367
367
|
type ExtendsArr<T extends readonly unknown[],Base>=IsEmptyArray<T>extends true?true:Pop<T,{includeRemoved:true;}>extends readonly [infer Rest extends readonly unknown[],infer Removed]?Extends<Removed,Base>extends true?ExtendsArr<Rest,Base>:false:false;export type{Arrayable as A,Extends as E,GetArrayElementType as G,IfExtends as I,MutableArray as M,Not as N,Pop as P,NotExtends as a,IsEmptyArray as b,ExtendsArr as c,IfEmptyArray as d,EmptyArray as e,IfNonEmptyArray as f,IsNonEmptyArray as g,NonEmptyArray as h,IfNotExtends as i,PopOptions as j};
|