@rzl-zone/utils-js 3.1.0-beta.2 → 3.1.2-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/README.md +2 -2
- 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/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 +3 -15
- 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
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
package/README.md
CHANGED
|
@@ -113,12 +113,12 @@ This package also provides utilities specially built for Next.js environments, n
|
|
|
113
113
|
#### For now, explore the examples or dive into the source — all utilities are documented via **JSDoc** and typed properly.
|
|
114
114
|
|
|
115
115
|
```ts
|
|
116
|
-
import { | } from "@rzl-zone/utils-js";
|
|
116
|
+
import { | } from "@rzl-zone/utils-js/ | ";
|
|
117
117
|
import { | } from "@rzl-zone/utils-js\types";
|
|
118
118
|
import { | } from "@rzl-zone/utils-js\next";
|
|
119
119
|
import { | } from "@rzl-zone/utils-js\next\server";
|
|
120
120
|
|
|
121
|
-
// Just place your cursor right inside { } like the pipe ("|") above then
|
|
121
|
+
// Just place your cursor right inside { } and from after `@rzl-zone/utils-js/` like the pipe ("|") above then
|
|
122
122
|
// ctrl + space, there are many functions or types and then hover to each
|
|
123
123
|
// function is complete with how to use it because I have added jsDoc.
|
|
124
124
|
```
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
type Enumerate<N extends number,Acc extends number[]=[]>=Acc["length"] extends N?Acc[number]:Enumerate<N,[...Acc,Acc["length"]]>;
|
|
2
2
|
/** --------------------------------------------------
|
|
3
|
-
* * ***Generate a union type of numbers from `From` to `To` using enumeration.***
|
|
4
|
-
* --------------------------------------------------
|
|
5
|
-
*
|
|
6
|
-
* @template From - Starting number of the range (inclusive).
|
|
7
|
-
* @template To - Ending number of the range (inclusive).
|
|
8
|
-
*
|
|
9
|
-
* @description
|
|
10
|
-
* Produces a **numeric union type** from `From` to `To` (inclusive),
|
|
11
|
-
* using a simpler approach based on `Enumerate<N>` helper type.
|
|
12
|
-
*
|
|
13
|
-
* - ✅ Straightforward & easy to reason about.
|
|
14
|
-
* - ⚠️ Still limited by TypeScript recursion depth (safe up to `999`).
|
|
15
|
-
* - ⚙️ Best used for **smaller ranges** or when readability matters.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* type RangeX = NumberRangeUnion<3, 6>;
|
|
20
|
-
* // ^? 3 | 4 | 5 | 6
|
|
21
|
-
*
|
|
22
|
-
* type RangeY = NumberRangeUnion<0, 2>;
|
|
23
|
-
* // ^? 0 | 1 | 2
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
3
|
+
* * ***Generate a union type of numbers from `From` to `To` using enumeration.***
|
|
4
|
+
* --------------------------------------------------
|
|
5
|
+
*
|
|
6
|
+
* @template From - Starting number of the range (inclusive).
|
|
7
|
+
* @template To - Ending number of the range (inclusive).
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* Produces a **numeric union type** from `From` to `To` (inclusive),
|
|
11
|
+
* using a simpler approach based on `Enumerate<N>` helper type.
|
|
12
|
+
*
|
|
13
|
+
* - ✅ Straightforward & easy to reason about.
|
|
14
|
+
* - ⚠️ Still limited by TypeScript recursion depth (safe up to `999`).
|
|
15
|
+
* - ⚙️ Best used for **smaller ranges** or when readability matters.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* type RangeX = NumberRangeUnion<3, 6>;
|
|
20
|
+
* // ^? 3 | 4 | 5 | 6
|
|
21
|
+
*
|
|
22
|
+
* type RangeY = NumberRangeUnion<0, 2>;
|
|
23
|
+
* // ^? 0 | 1 | 2
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
26
|
type NumberRangeUnion<From extends number,To extends number>=From extends To?From:Exclude<Enumerate<To>,Enumerate<From>>extends never?never:Exclude<Enumerate<To>,Enumerate<From>>|To;export type{NumberRangeUnion as N};
|
package/dist/any-BmdI8UbK.d.ts
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
import{I as If}from'./if-CvT4R7Kh.js';
|
|
2
2
|
/** -------------------------------------------------------
|
|
3
|
-
* * ***IsAny.***
|
|
4
|
-
* -------------------------------------------------------
|
|
5
|
-
* A type-level utility that checks whether a type is ***`any`***.
|
|
6
|
-
* - Returns `true` if `T` is `any`.
|
|
7
|
-
* - Returns `false` otherwise.
|
|
8
|
-
*
|
|
9
|
-
* @template T - The type to evaluate.
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* type A = IsAny<any>; // ➔ true
|
|
13
|
-
* type B = IsAny<string>; // ➔ false
|
|
14
|
-
* type C = IsAny<unknown>; // ➔ false
|
|
15
|
-
* type D = IsAny<never>; // ➔ false
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
3
|
+
* * ***IsAny.***
|
|
4
|
+
* -------------------------------------------------------
|
|
5
|
+
* A type-level utility that checks whether a type is ***`any`***.
|
|
6
|
+
* - Returns `true` if `T` is `any`.
|
|
7
|
+
* - Returns `false` otherwise.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type to evaluate.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* type A = IsAny<any>; // ➔ true
|
|
13
|
+
* type B = IsAny<string>; // ➔ false
|
|
14
|
+
* type C = IsAny<unknown>; // ➔ false
|
|
15
|
+
* type D = IsAny<never>; // ➔ false
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
18
|
type IsAny<T>=0 extends 1 & T?true:false;
|
|
19
19
|
/** -------------------------------------------------------
|
|
20
|
-
* * ***IfAny.***
|
|
21
|
-
* -------------------------------------------------------
|
|
22
|
-
*
|
|
23
|
-
* A type-level conditional utility that returns one type if ***`T` is `any`***,
|
|
24
|
-
* and another type otherwise.
|
|
25
|
-
* - Defaults to `true` when `T` is `any`.
|
|
26
|
-
* - Defaults to `false` otherwise.
|
|
27
|
-
*
|
|
28
|
-
* @template T - The type to check.
|
|
29
|
-
* @template IfTrue - The type to return if `T` is `any`. *(default: `true`)*
|
|
30
|
-
* @template IfFalse - The type to return if `T` is not `any`. *(default: `false`)*
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```ts
|
|
34
|
-
* type A = IfAny<any, string, number>;
|
|
35
|
-
* // ➔ string
|
|
36
|
-
* type B = IfAny<string, string, number>;
|
|
37
|
-
* // ➔ number
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
20
|
+
* * ***IfAny.***
|
|
21
|
+
* -------------------------------------------------------
|
|
22
|
+
*
|
|
23
|
+
* A type-level conditional utility that returns one type if ***`T` is `any`***,
|
|
24
|
+
* and another type otherwise.
|
|
25
|
+
* - Defaults to `true` when `T` is `any`.
|
|
26
|
+
* - Defaults to `false` otherwise.
|
|
27
|
+
*
|
|
28
|
+
* @template T - The type to check.
|
|
29
|
+
* @template IfTrue - The type to return if `T` is `any`. *(default: `true`)*
|
|
30
|
+
* @template IfFalse - The type to return if `T` is not `any`. *(default: `false`)*
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* type A = IfAny<any, string, number>;
|
|
35
|
+
* // ➔ string
|
|
36
|
+
* type B = IfAny<string, string, number>;
|
|
37
|
+
* // ➔ number
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
40
|
type IfAny<T,IfTrue=true,IfFalse=false>=If<IsAny<T>,IfTrue,IfFalse>;
|
|
41
41
|
/** Configuration options for a type-level utility `AnifyProperties`. */
|
|
42
42
|
type AnifyPropertiesOptions={
|
|
43
43
|
/** If `makeOptional: true`, all properties become optional, otherwise, all properties are required and typed as `any`, defaultValue: `false`.
|
|
44
|
-
*
|
|
45
|
-
* @default false
|
|
46
|
-
*/
|
|
44
|
+
*
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
47
|
makeOptional:boolean;};
|
|
48
48
|
/** -------------------------------------------------------
|
|
49
|
-
* * ***AnifyProperties.***
|
|
50
|
-
* -------------------------------------------------------
|
|
51
|
-
*
|
|
52
|
-
* A type-level utility that transforms all properties of an object into ***`any`***.
|
|
53
|
-
* - If `makeOptional: true`, all properties become optional.
|
|
54
|
-
* - Otherwise, all properties are required and typed as `any`.
|
|
55
|
-
*
|
|
56
|
-
* @template T - The object type to transform.
|
|
57
|
-
* @template Options - Configuration options. Defaults to `{ makeOptional: false }`.
|
|
58
|
-
* @example
|
|
59
|
-
* ```ts
|
|
60
|
-
* type A = AnifyProperties<{a: string; b: number}>;
|
|
61
|
-
* // ➔ { a: any; b: any }
|
|
62
|
-
*
|
|
63
|
-
* type B = AnifyProperties<{a: string; b: number}, { makeOptional: true }>;
|
|
64
|
-
* // ➔ { a?: any; b?: any }
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
49
|
+
* * ***AnifyProperties.***
|
|
50
|
+
* -------------------------------------------------------
|
|
51
|
+
*
|
|
52
|
+
* A type-level utility that transforms all properties of an object into ***`any`***.
|
|
53
|
+
* - If `makeOptional: true`, all properties become optional.
|
|
54
|
+
* - Otherwise, all properties are required and typed as `any`.
|
|
55
|
+
*
|
|
56
|
+
* @template T - The object type to transform.
|
|
57
|
+
* @template Options - Configuration options. Defaults to `{ makeOptional: false }`.
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* type A = AnifyProperties<{a: string; b: number}>;
|
|
61
|
+
* // ➔ { a: any; b: any }
|
|
62
|
+
*
|
|
63
|
+
* type B = AnifyProperties<{a: string; b: number}, { makeOptional: true }>;
|
|
64
|
+
* // ➔ { a?: any; b?: any }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
67
|
type AnifyProperties<T extends object,Options extends AnifyPropertiesOptions={makeOptional:false;}>={[K in keyof T]:any;}extends infer Result?If<Options["makeOptional"],Partial<Result>,Result>:never;export type{AnifyProperties as A,IsAny as I,AnifyPropertiesOptions as a,IfAny as b};
|
|
@@ -1,72 +1,72 @@
|
|
|
1
1
|
/** -------------------------------------------------------
|
|
2
|
-
* * ***FixNeverArrayRecursive.***
|
|
3
|
-
* -------------------------------------------------------
|
|
4
|
-
* A type-level utility that **recursively transforms arrays of type `never[]` into empty arrays**.
|
|
5
|
-
* - Preserves `readonly` modifiers.
|
|
6
|
-
* - Applies recursively for nested arrays.
|
|
7
|
-
* - Leaves other types unchanged.
|
|
8
|
-
*
|
|
9
|
-
* @template T - The input type to recursively fix.
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* type A = FixNeverArrayRecursive<never[]>;
|
|
13
|
-
* // ➔ []
|
|
14
|
-
* type B = FixNeverArrayRecursive<readonly never[]>;
|
|
15
|
-
* // ➔ readonly []
|
|
16
|
-
* type C = FixNeverArrayRecursive<string[]>;
|
|
17
|
-
* // ➔ string[]
|
|
18
|
-
* type D = FixNeverArrayRecursive<(never | string)[]>;
|
|
19
|
-
* // ➔ (never | string)[]
|
|
20
|
-
* type E = FixNeverArrayRecursive<(never[])[]>;
|
|
21
|
-
* // ➔ [][]
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
2
|
+
* * ***FixNeverArrayRecursive.***
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* A type-level utility that **recursively transforms arrays of type `never[]` into empty arrays**.
|
|
5
|
+
* - Preserves `readonly` modifiers.
|
|
6
|
+
* - Applies recursively for nested arrays.
|
|
7
|
+
* - Leaves other types unchanged.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The input type to recursively fix.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* type A = FixNeverArrayRecursive<never[]>;
|
|
13
|
+
* // ➔ []
|
|
14
|
+
* type B = FixNeverArrayRecursive<readonly never[]>;
|
|
15
|
+
* // ➔ readonly []
|
|
16
|
+
* type C = FixNeverArrayRecursive<string[]>;
|
|
17
|
+
* // ➔ string[]
|
|
18
|
+
* type D = FixNeverArrayRecursive<(never | string)[]>;
|
|
19
|
+
* // ➔ (never | string)[]
|
|
20
|
+
* type E = FixNeverArrayRecursive<(never[])[]>;
|
|
21
|
+
* // ➔ [][]
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
24
|
type FixNeverArrayRecursive<T>=T extends readonly never[]?T extends never[]?[]:readonly []:T extends(infer U)[]?FixNeverArrayRecursive<U>[]:T extends readonly(infer U)[]?readonly FixNeverArrayRecursive<U>[]:T;
|
|
25
25
|
/** -------------------------------------------------------
|
|
26
|
-
* * ***NormalizeEmptyArraysRecursive.***
|
|
27
|
-
* -------------------------------------------------------
|
|
28
|
-
* A type-level utility that **recursively normalizes empty array types** by converting arrays whose element type is `never`, `null`, or `undefined` into empty tuple types (`[]`).
|
|
29
|
-
* - Preserves `readonly` modifiers.
|
|
30
|
-
* - Recurses into nested arrays.
|
|
31
|
-
* - Leaves other array types unchanged.
|
|
32
|
-
*
|
|
33
|
-
* @template T - The input type to normalize.
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* type A = NormalizeEmptyArraysRecursive<never[]>;
|
|
37
|
-
* // ➔ []
|
|
38
|
-
* type B = NormalizeEmptyArraysRecursive<readonly never[]>;
|
|
39
|
-
* // ➔ readonly []
|
|
40
|
-
* type C = NormalizeEmptyArraysRecursive<null[]>;
|
|
41
|
-
* // ➔ []
|
|
42
|
-
* type D = NormalizeEmptyArraysRecursive<(null[] | string[])[]>;
|
|
43
|
-
* // ➔ ([] | string[])[]
|
|
44
|
-
* type E = NormalizeEmptyArraysRecursive<string[]>;
|
|
45
|
-
* // ➔ string[]
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
26
|
+
* * ***NormalizeEmptyArraysRecursive.***
|
|
27
|
+
* -------------------------------------------------------
|
|
28
|
+
* A type-level utility that **recursively normalizes empty array types** by converting arrays whose element type is `never`, `null`, or `undefined` into empty tuple types (`[]`).
|
|
29
|
+
* - Preserves `readonly` modifiers.
|
|
30
|
+
* - Recurses into nested arrays.
|
|
31
|
+
* - Leaves other array types unchanged.
|
|
32
|
+
*
|
|
33
|
+
* @template T - The input type to normalize.
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* type A = NormalizeEmptyArraysRecursive<never[]>;
|
|
37
|
+
* // ➔ []
|
|
38
|
+
* type B = NormalizeEmptyArraysRecursive<readonly never[]>;
|
|
39
|
+
* // ➔ readonly []
|
|
40
|
+
* type C = NormalizeEmptyArraysRecursive<null[]>;
|
|
41
|
+
* // ➔ []
|
|
42
|
+
* type D = NormalizeEmptyArraysRecursive<(null[] | string[])[]>;
|
|
43
|
+
* // ➔ ([] | string[])[]
|
|
44
|
+
* type E = NormalizeEmptyArraysRecursive<string[]>;
|
|
45
|
+
* // ➔ string[]
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
48
|
type NormalizeEmptyArraysRecursive<T>=T extends readonly(infer U)[]?U extends never|null|undefined?T extends readonly unknown[]?T extends(infer E)[]?[]:readonly []:never:T extends(infer E)[]?NormalizeEmptyArraysRecursive<U>[]:readonly NormalizeEmptyArraysRecursive<U>[]:T;
|
|
49
49
|
/** -------------------------------------------------------
|
|
50
|
-
* * ***RemoveEmptyArrayElements.***
|
|
51
|
-
* -------------------------------------------------------
|
|
52
|
-
* A type-level utility that **recursively removes empty array elements (`[]`) from a tuple type**.
|
|
53
|
-
* - If `T` is a tuple, checks the first element:
|
|
54
|
-
* - If `Head` is an empty array type (`[]`), it is removed.
|
|
55
|
-
* - Otherwise, `Head` is preserved.
|
|
56
|
-
* - Repeats recursively on the rest of the tuple.
|
|
57
|
-
* - Leaves non-tuple types unchanged.
|
|
58
|
-
*
|
|
59
|
-
* @template T - The tuple type to process.
|
|
60
|
-
* @example
|
|
61
|
-
* ```ts
|
|
62
|
-
* type A = RemoveEmptyArrayElements<[[], 1, [], 2]>;
|
|
63
|
-
* // ➔ [1, 2]
|
|
64
|
-
* type B = RemoveEmptyArrayElements<[]>;
|
|
65
|
-
* // ➔ []
|
|
66
|
-
* type C = RemoveEmptyArrayElements<[[], [], []]>;
|
|
67
|
-
* // ➔ []
|
|
68
|
-
* type D = RemoveEmptyArrayElements<[1, 2, 3]>;
|
|
69
|
-
* // ➔ [1, 2, 3]
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
50
|
+
* * ***RemoveEmptyArrayElements.***
|
|
51
|
+
* -------------------------------------------------------
|
|
52
|
+
* A type-level utility that **recursively removes empty array elements (`[]`) from a tuple type**.
|
|
53
|
+
* - If `T` is a tuple, checks the first element:
|
|
54
|
+
* - If `Head` is an empty array type (`[]`), it is removed.
|
|
55
|
+
* - Otherwise, `Head` is preserved.
|
|
56
|
+
* - Repeats recursively on the rest of the tuple.
|
|
57
|
+
* - Leaves non-tuple types unchanged.
|
|
58
|
+
*
|
|
59
|
+
* @template T - The tuple type to process.
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* type A = RemoveEmptyArrayElements<[[], 1, [], 2]>;
|
|
63
|
+
* // ➔ [1, 2]
|
|
64
|
+
* type B = RemoveEmptyArrayElements<[]>;
|
|
65
|
+
* // ➔ []
|
|
66
|
+
* type C = RemoveEmptyArrayElements<[[], [], []]>;
|
|
67
|
+
* // ➔ []
|
|
68
|
+
* type D = RemoveEmptyArrayElements<[1, 2, 3]>;
|
|
69
|
+
* // ➔ [1, 2, 3]
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
72
|
type RemoveEmptyArrayElements<T>=T extends [infer Head,...infer Tail]?Head extends []?RemoveEmptyArrayElements<Tail>:[Head,...RemoveEmptyArrayElements<Tail>]:T extends []?[]:T;export type{FixNeverArrayRecursive as F,NormalizeEmptyArraysRecursive as N,RemoveEmptyArrayElements as R};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkIY5OZAB3_cjs=require('../chunk-IY5OZAB3.cjs'),chunkUQDJF5RR_cjs=require('../chunk-UQDJF5RR.cjs'),chunkBEZPD44N_cjs=require('../chunk-BEZPD44N.cjs');require('../chunk-7YWAQOA4.cjs');var chunkCII6WWLO_cjs=require('../chunk-CII6WWLO.cjs');Object.defineProperty(exports,"assertIsBigInt",{enumerable:true,get:function(){return chunkIY5OZAB3_cjs.a}});Object.defineProperty(exports,"assertIsNumber",{enumerable:true,get:function(){return chunkIY5OZAB3_cjs.b}});Object.defineProperty(exports,"assertIsArray",{enumerable:true,get:function(){return chunkUQDJF5RR_cjs.a}});Object.defineProperty(exports,"assertIsString",{enumerable:true,get:function(){return chunkBEZPD44N_cjs.a}});Object.defineProperty(exports,"assertIsBoolean",{enumerable:true,get:function(){return chunkCII6WWLO_cjs.G}});Object.defineProperty(exports,"assertIsPlainObject",{enumerable:true,get:function(){return chunkCII6WWLO_cjs.j}});
|