@rzl-zone/utils-js 3.0.2-beta.2 → 3.1.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 +56 -27
- 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 +398 -418
- package/dist/assertions/index.js +1 -1
- package/dist/chunk-26XIKDJI.cjs +1 -0
- package/dist/chunk-2NWHDDM5.js +1 -0
- package/dist/chunk-2UIRWYE3.js +1 -0
- package/dist/chunk-3KBHD3BS.cjs +1 -0
- package/dist/chunk-4HD2O5A4.js +1 -0
- package/dist/chunk-5C2SMIGX.cjs +1 -0
- package/dist/chunk-5I2B5DOG.js +1 -0
- package/dist/chunk-6HQDHIOD.js +1 -0
- package/dist/chunk-735HJXBT.cjs +1 -0
- package/dist/chunk-7BXIZM57.cjs +1 -0
- package/dist/chunk-7KJBDGEP.js +1 -0
- package/dist/chunk-7U44T63D.cjs +1 -0
- package/dist/chunk-AJ65QFV2.js +1 -0
- package/dist/chunk-APHDUCVQ.js +1 -0
- package/dist/chunk-BSVZRN7C.js +1 -0
- package/dist/chunk-C6JFHUR2.cjs +1 -0
- package/dist/chunk-CPLBRGST.js +1 -0
- package/dist/chunk-CTBRLEOG.js +1 -0
- package/dist/chunk-DUK2K4FB.js +1 -0
- package/dist/chunk-DVMHRLKP.cjs +1 -0
- package/dist/chunk-E63WVPZE.cjs +1 -0
- package/dist/chunk-EBMHQW7X.cjs +1 -0
- package/dist/chunk-EGNZCW4K.js +1 -0
- package/dist/chunk-FEKDB32T.js +1 -0
- package/dist/chunk-FIAAX3UE.js +1 -0
- package/dist/chunk-FUS3DVLB.cjs +1 -0
- package/dist/chunk-GGRMHIFJ.cjs +1 -0
- package/dist/chunk-HQ5GQTEE.js +1 -0
- package/dist/chunk-I5X5IN4H.js +1 -0
- package/dist/chunk-I7YGXQPI.cjs +1 -0
- package/dist/chunk-INUFZJLX.cjs +1 -0
- package/dist/chunk-IREHUBF7.js +1 -0
- package/dist/chunk-J2RGTPGK.cjs +1 -0
- package/dist/chunk-KHO2SBNA.cjs +1 -0
- package/dist/chunk-KXIXXSWX.cjs +1 -0
- package/dist/chunk-LBMEEJWA.js +1 -0
- package/dist/chunk-MC3LXMCQ.js +1 -0
- package/dist/chunk-MMSYCIJ2.cjs +1 -1
- package/dist/chunk-NU3N4WHD.cjs +1 -0
- package/dist/chunk-ODZQXH7E.cjs +1 -0
- package/dist/chunk-ONZFBJVW.js +1 -0
- package/dist/chunk-PXDRHFIE.js +1 -0
- package/dist/chunk-Q6NHYWVX.js +1 -0
- package/dist/chunk-QNKGP5DY.js +1 -0
- package/dist/chunk-S6Z6I2EG.cjs +1 -0
- package/dist/chunk-SMADKXZE.js +1 -0
- package/dist/chunk-TSLYDPBJ.js +1 -0
- package/dist/chunk-TVXADXCC.cjs +1 -0
- package/dist/chunk-UDA26MCU.cjs +1 -0
- package/dist/chunk-UET567YM.cjs +1 -0
- package/dist/chunk-VEYMQ3UA.js +1 -0
- package/dist/chunk-W2W3L2M5.js +1 -0
- package/dist/chunk-WBWTXKMC.cjs +1 -0
- package/dist/chunk-WVSPXFTY.js +1 -0
- package/dist/chunk-XC2PYCT4.cjs +1 -0
- package/dist/chunk-XIXA5KDF.cjs +1 -0
- package/dist/chunk-Y4O5KZF6.cjs +1 -0
- package/dist/chunk-YRM7IJLX.js +1 -0
- package/dist/chunk-YT3MSZKK.cjs +1 -0
- package/dist/chunk-YXHCULSO.cjs +1 -0
- package/dist/chunk-YZR5OGJA.cjs +1 -0
- package/dist/chunk-Z4DXK7A6.cjs +1 -0
- package/dist/chunk-ZXIWDFEQ.js +1 -0
- package/dist/conversions/index.cjs +1 -1
- package/dist/conversions/index.d.ts +1368 -1515
- package/dist/conversions/index.js +1 -1
- package/dist/env/index.cjs +1 -1
- package/dist/env/index.d.ts +14 -17
- package/dist/env/index.js +1 -1
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.d.ts +111 -108
- package/dist/events/index.js +1 -1
- package/dist/extends-Bk_SBGdT.d.ts +367 -0
- package/dist/formatting/index.cjs +1 -1
- package/dist/formatting/index.d.ts +878 -840
- package/dist/formatting/index.js +1 -1
- package/dist/generator/index.cjs +1 -1
- package/dist/generator/index.d.ts +173 -150
- package/dist/generator/index.js +1 -1
- package/dist/if-CvT4R7Kh.d.ts +16 -16
- package/dist/is-array-Cymwrsmm.d.ts +1119 -0
- package/dist/isPlainObject-BVhBAPHX.d.ts +169 -0
- package/dist/never-BfayMBF9.d.ts +64 -64
- package/dist/next/index.cjs +1 -8
- package/dist/next/index.d.ts +196 -176
- package/dist/next/index.js +1 -8
- package/dist/next/server/index.cjs +1 -2
- package/dist/next/server/index.d.ts +26 -40
- package/dist/next/server/index.js +1 -2
- 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 +121 -176
- package/dist/operations/index.js +1 -1
- package/dist/or-DyZCRvaU.d.ts +89 -0
- package/dist/parsers/index.cjs +1 -1
- package/dist/parsers/index.d.ts +35 -36
- package/dist/parsers/index.js +1 -1
- package/dist/predicates/index.cjs +1 -1
- package/dist/predicates/index.d.ts +1797 -1677
- 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 -38
- package/dist/promise/index.js +1 -1
- package/dist/rzl-utils.global.js +1 -4
- package/dist/string-XA-til3C.d.ts +351 -0
- package/dist/strings/index.cjs +1 -1
- package/dist/strings/index.d.ts +712 -787
- package/dist/strings/index.js +1 -1
- package/dist/tailwind/index.cjs +1 -0
- package/dist/tailwind/index.d.ts +565 -0
- package/dist/tailwind/index.js +1 -0
- package/dist/type-data-DDs-u2kq.d.ts +241 -241
- package/dist/types/index.d.ts +3266 -3266
- package/dist/urls/index.cjs +1 -1
- package/dist/urls/index.d.ts +384 -409
- package/dist/urls/index.js +1 -1
- package/package.json +61 -18
- package/dist/array-CIZRbqTF.d.ts +0 -223
- package/dist/chunk-2TRAPBZ7.cjs +0 -1
- package/dist/chunk-3D74QO5D.cjs +0 -1
- package/dist/chunk-4DK3RCC4.js +0 -2
- package/dist/chunk-4JOQ45HL.js +0 -1
- package/dist/chunk-55CZALRS.js +0 -1
- package/dist/chunk-56QBKKRE.js +0 -1
- package/dist/chunk-5JFV3GDE.cjs +0 -4
- package/dist/chunk-5SZUSNGZ.js +0 -1
- package/dist/chunk-62HX5Z45.cjs +0 -1
- package/dist/chunk-7NA6DUHR.cjs +0 -2
- package/dist/chunk-7YWAQOA4.cjs +0 -1
- package/dist/chunk-BVPMMWDL.cjs +0 -1
- package/dist/chunk-BYZAD3XN.cjs +0 -1
- package/dist/chunk-CEFYHEM4.cjs +0 -1
- package/dist/chunk-CN53M4QZ.cjs +0 -1
- package/dist/chunk-D47MHBSD.cjs +0 -1
- package/dist/chunk-DGH75GJD.js +0 -1
- package/dist/chunk-E5NUI7PN.js +0 -1
- package/dist/chunk-ELDDNERR.js +0 -1
- package/dist/chunk-EXZ47NOW.js +0 -1
- package/dist/chunk-FDITZ5C6.cjs +0 -1
- package/dist/chunk-FF76ISQ2.js +0 -1
- package/dist/chunk-FIEZKTAZ.cjs +0 -1
- package/dist/chunk-FSSV24W7.cjs +0 -1
- package/dist/chunk-GCGU2WB7.js +0 -1
- package/dist/chunk-GECI2YBP.js +0 -1
- package/dist/chunk-GQE4OVHC.cjs +0 -1
- package/dist/chunk-GRVZXQXL.cjs +0 -1
- package/dist/chunk-I4AVNHPA.cjs +0 -1
- package/dist/chunk-JFRL7NKU.js +0 -4
- package/dist/chunk-JWHM3WZQ.cjs +0 -1
- package/dist/chunk-KCQDDZJE.cjs +0 -1
- package/dist/chunk-L54ZPSYJ.js +0 -1
- package/dist/chunk-LVKAYEZ4.js +0 -1
- package/dist/chunk-MBDWTK54.cjs +0 -1
- package/dist/chunk-MNGGDB2G.js +0 -1
- package/dist/chunk-MY7BA4GI.cjs +0 -1
- package/dist/chunk-N2IJPIND.cjs +0 -1
- package/dist/chunk-NIMNTEGV.js +0 -1
- package/dist/chunk-NNM7QCNB.js +0 -1
- package/dist/chunk-PUQXRLZH.cjs +0 -1
- package/dist/chunk-PVJF2JHM.js +0 -1
- package/dist/chunk-QCFXEUKL.js +0 -1
- package/dist/chunk-QFCGBBSY.js +0 -1
- package/dist/chunk-QQYAUPSK.cjs +0 -1
- package/dist/chunk-RN3TP3S3.js +0 -1
- package/dist/chunk-RV2VULM7.cjs +0 -1
- package/dist/chunk-SW6HYEW7.cjs +0 -1
- package/dist/chunk-SYJC7UAW.js +0 -1
- package/dist/chunk-TC4VBE4Y.cjs +0 -1
- package/dist/chunk-TUXDINHF.cjs +0 -1
- package/dist/chunk-U5Y2FXMN.cjs +0 -1
- package/dist/chunk-UUPQI6ND.cjs +0 -1
- package/dist/chunk-VYCGZ2S6.js +0 -1
- package/dist/chunk-W5EDKJK3.js +0 -1
- package/dist/chunk-WHAVUFEU.js +0 -1
- package/dist/chunk-XCFIOTCV.js +0 -1
- package/dist/chunk-XE27XPJR.js +0 -1
- package/dist/chunk-XH6MCRLP.js +0 -1
- package/dist/chunk-XVB3ZZEB.js +0 -1
- package/dist/chunk-ZBSIGJFO.cjs +0 -1
- package/dist/chunk-ZYAML74V.js +0 -1
- package/dist/extends-Mp81Hq9-.d.ts +0 -145
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/is-array-Ckm_47hw.d.ts +0 -1557
- package/dist/isPlainObject-BKYaI6a8.d.ts +0 -182
- package/dist/stylings/index.cjs +0 -1
- package/dist/stylings/index.d.ts +0 -49
- package/dist/stylings/index.js +0 -1
package/README.md
CHANGED
|
@@ -6,18 +6,34 @@
|
|
|
6
6
|
🚀 <strong>Rzl Utility JavaScript</strong> 🚀<br/>
|
|
7
7
|
A lightweight, modern TypeScript utility library for Node.js & browser (via bundlers like Webpack/Vite).<br/>
|
|
8
8
|
Provides reusable helpers to simplify your JavaScript / TypeScript projects.<br/>
|
|
9
|
-
<strong>Built with ❤️ by <a href="https://github.com/rzl-app">@rzl-app</a>.</strong>
|
|
9
|
+
<strong>Built with ❤️ by <a href="https://github.com/rzl-app" target="_blank" rel="nofollow noreferrer noopener">@rzl-app</a>.</strong>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<div align="center">
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
<p>
|
|
15
|
+
<a href="https://npmjs.com/package/@rzl-zone/utils-js" target="_blank" rel="nofollow noreferrer noopener">
|
|
16
|
+
<img src="https://img.shields.io/npm/v/@rzl-zone/utils-js?color=blue&style=flat-rounded" alt="Latest Version on NPM" data-canonical-src="https://img.shields.io/npm/v/@rzl-zone/utils-js?color=blue&style=flat-rounded">
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://npmjs.com/package/@rzl-zone/utils-js" target="_blank" rel="nofollow noreferrer noopener">
|
|
19
|
+
<img src="https://img.shields.io/npm/dt/@rzl-zone/utils-js?style=flat-rounded" alt="Downloads">
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://nodejs.org/en/" target="_blank" rel="nofollow noreferrer noopener">
|
|
22
|
+
<img src="https://img.shields.io/badge/node-≥16.0.0%20%7C%20≥18.17.0-blue.svg?logo=node.js&style=flat-rounded" alt="Node.js">
|
|
23
|
+
</a>
|
|
24
|
+
<a href="https://github.com/rzl-zone/utils-js/blob/main/CONTRIBUTING.md" target="_blank" rel="nofollow noreferrer noopener">
|
|
25
|
+
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs Welcome">
|
|
26
|
+
</a>
|
|
27
|
+
<a href="https://github.com/rzl-zone/utils-js/blob/main/LICENSE.md" target="_blank" rel="nofollow noreferrer noopener">
|
|
28
|
+
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="GitHub license">
|
|
29
|
+
</a>
|
|
30
|
+
<a href="https://github.com/rzl-zone/utils-js" target="_blank" rel="nofollow noreferrer noopener">
|
|
31
|
+
<img src="https://img.shields.io/badge/GitHub-rzl--zone%2Futils--js-181717?logo=github" alt="GitHub">
|
|
32
|
+
</a>
|
|
33
|
+
<a href="https://github.com/rzl-app" target="_blank" rel="nofollow noreferrer noopener">
|
|
34
|
+
<img src="https://img.shields.io/badge/Repo-on%20GitHub-181717?logo=github&style=flat-rounded" alt="Repo on GitHub">
|
|
35
|
+
</a>
|
|
36
|
+
</p>
|
|
21
37
|
|
|
22
38
|
</div>
|
|
23
39
|
|
|
@@ -34,7 +50,7 @@ Provides reusable helpers to simplify your JavaScript / TypeScript projects.<br/
|
|
|
34
50
|
- ❤️ [Sponsor](#sponsor-this-package)
|
|
35
51
|
- 📜 [Changelog](#changelog)
|
|
36
52
|
- 🤝 [Contributing](#contributing)
|
|
37
|
-
-
|
|
53
|
+
- 🔒 [Security](#security)
|
|
38
54
|
- 🙌 [Credits](#credits)
|
|
39
55
|
- 📄 [License](#license)
|
|
40
56
|
|
|
@@ -42,12 +58,14 @@ Provides reusable helpers to simplify your JavaScript / TypeScript projects.<br/
|
|
|
42
58
|
|
|
43
59
|
<h2 id="requirements">💻 Requirements</h2>
|
|
44
60
|
|
|
45
|
-
- **Node.js
|
|
46
|
-
This package leverages modern JavaScript & TypeScript features that require Node.js version 16.0.0 if not using
|
|
61
|
+
- **Node.js `≥16.0.0` or `≥18.17.0`**
|
|
62
|
+
This package leverages modern JavaScript & TypeScript features that require Node.js version 16.0.0 if not using Next.js, and for Next.js it must follow the official minimum Node.js version requirement depending on the version you use.
|
|
63
|
+
- 🔗 See official Next.js documentation:
|
|
64
|
+
<a href="https://nextjs.org/docs/getting-started/installation#system-requirements" target="_blank" rel="nofollow noreferrer noopener">NextJS Installation Requirements</a>
|
|
47
65
|
|
|
48
66
|
- Works with:
|
|
49
67
|
- ✅ Node.js (16.0.0+) - Without NextJS
|
|
50
|
-
- ✅ Node.js (18.17.0
|
|
68
|
+
- ✅ Node.js (18.17.0, or higher depending on NextJS version) - With NextJS
|
|
51
69
|
- ✅ Modern browsers (via bundlers like Webpack / Vite)
|
|
52
70
|
|
|
53
71
|
---
|
|
@@ -109,19 +127,30 @@ This package also provides utilities specially built for Next.js environments, n
|
|
|
109
127
|
|
|
110
128
|
<h2 id="detailed-features">💎 Detailed Features</h2>
|
|
111
129
|
|
|
112
|
-
### Full documentation
|
|
113
|
-
#### For now, explore the examples or dive into the source — all utilities are documented via **
|
|
130
|
+
### Full documentation <a href="https://docs-rzl-utils-js.vercel.app" target="_blank" rel="nofollow noreferrer noopener">Rzl UtilsJS</a> is **currently under construction** 🏗️.
|
|
131
|
+
#### For now, explore the examples or dive into the source — all utilities are documented via **TSDoc** and typed properly.
|
|
114
132
|
|
|
115
133
|
```ts
|
|
116
|
-
import { | } from "@rzl-zone/utils-js";
|
|
117
|
-
import { | } from "@rzl-zone/utils-js
|
|
118
|
-
import { | } from "@rzl-zone/utils-js
|
|
119
|
-
import { | } from "@rzl-zone/utils-js
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
134
|
+
import { | } from "@rzl-zone/utils-js/assertions";
|
|
135
|
+
import { | } from "@rzl-zone/utils-js/conversions";
|
|
136
|
+
import { | } from "@rzl-zone/utils-js/env";
|
|
137
|
+
import { | } from "@rzl-zone/utils-js/events";
|
|
138
|
+
import { | } from "@rzl-zone/utils-js/formatting";
|
|
139
|
+
import { | } from "@rzl-zone/utils-js/generator";
|
|
140
|
+
import { | } from "@rzl-zone/utils-js/generator";
|
|
141
|
+
import { | } from "@rzl-zone/utils-js/next";
|
|
142
|
+
import { | } from "@rzl-zone/utils-js/next/server";
|
|
143
|
+
import { | } from "@rzl-zone/utils-js/operations";
|
|
144
|
+
import { | } from "@rzl-zone/utils-js/parsers";
|
|
145
|
+
import { | } from "@rzl-zone/utils-js/predicates";
|
|
146
|
+
import { | } from "@rzl-zone/utils-js/promise";
|
|
147
|
+
import { | } from "@rzl-zone/utils-js/strings";
|
|
148
|
+
import { | } from "@rzl-zone/utils-js/stylings";
|
|
149
|
+
import { | } from "@rzl-zone/utils-js/urls";
|
|
150
|
+
|
|
151
|
+
import type { | } from "@rzl-zone/utils-js/types";
|
|
124
152
|
```
|
|
153
|
+
#### Just place your cursor right inside `{ }` or from after import from `"@rzl-zone/utils-js/"` like the pipe ("|") above then ctrl + space, there are many functions or types and then hover to each function is complete with how to use it because I have added tsDoc.
|
|
125
154
|
|
|
126
155
|
<!-- - <h4 id="detailed-features--assertions">
|
|
127
156
|
Assertions -
|
|
@@ -148,18 +177,18 @@ This package also provides utilities specially built for Next.js environments, n
|
|
|
148
177
|
|
|
149
178
|
<h2 id="usage">🔥 Usage</h2>
|
|
150
179
|
|
|
151
|
-
|
|
180
|
+
### Easy to use, just import on your code base.
|
|
152
181
|
|
|
153
|
-
|
|
182
|
+
#### Example Function Import:
|
|
154
183
|
|
|
155
184
|
```ts
|
|
156
|
-
import { isServer } from "@rzl-zone/utils-js";
|
|
185
|
+
import { isServer } from "@rzl-zone/utils-js/env";
|
|
157
186
|
|
|
158
187
|
console.log(isServer());
|
|
159
188
|
// true if running on Node.js, false if browser
|
|
160
189
|
```
|
|
161
190
|
|
|
162
|
-
|
|
191
|
+
#### Example Types Helper Import:
|
|
163
192
|
|
|
164
193
|
```ts
|
|
165
194
|
import type { OmitStrict } from "@rzl-zone/utils-js/types";
|
|
@@ -189,7 +218,7 @@ See [CONTRIBUTING](CONTRIBUTING.md).
|
|
|
189
218
|
|
|
190
219
|
---
|
|
191
220
|
|
|
192
|
-
<h2 id="security"
|
|
221
|
+
<h2 id="security">🔒 Security</h2>
|
|
193
222
|
|
|
194
223
|
Please report issues to [rizalvindwiky1998@gmail.com](mailto:rizalvindwiky1998@gmail.com).
|
|
195
224
|
|
|
@@ -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
|
-
|
|
1
|
+
"use strict";var e=require("../chunk-UET567YM.cjs"),r=require("../chunk-YT3MSZKK.cjs"),t=require("../chunk-Y4O5KZF6.cjs");require("../chunk-UDA26MCU.cjs");var s=require("../chunk-INUFZJLX.cjs");Object.defineProperty(exports,"assertIsBigInt",{enumerable:!0,get:function(){return e.assertIsBigInt}}),Object.defineProperty(exports,"assertIsNumber",{enumerable:!0,get:function(){return e.assertIsNumber}}),Object.defineProperty(exports,"assertIsArray",{enumerable:!0,get:function(){return r.assertIsArray}}),Object.defineProperty(exports,"assertIsString",{enumerable:!0,get:function(){return t.assertIsString}}),Object.defineProperty(exports,"assertIsBoolean",{enumerable:!0,get:function(){return s.assertIsBoolean}}),Object.defineProperty(exports,"assertIsPlainObject",{enumerable:!0,get:function(){return s.assertIsPlainObject}});
|