@rzl-zone/utils-js 3.3.0 → 3.4.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 +74 -41
- package/dist/assertions/index.d.ts +1 -1
- package/dist/conversions/index.d.ts +1 -1
- package/dist/formatters/index.d.ts +1 -1
- package/dist/generators/index.d.ts +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/{isPlainObject-DGJkcFYw.d.ts → isPlainObject-CEPWPiXh.d.ts} +1 -1
- package/dist/next/index.d.ts +1 -1
- package/dist/operations/index.d.ts +1 -1
- package/dist/predicates/index.d.ts +1 -1
- package/dist/promises/index.d.ts +1 -1
- package/dist/strings/index.d.ts +1 -1
- package/package.json +2 -7
- package/dist/NumberRangeUnion-B6bhM2s7.d.ts +0 -33
- package/dist/any-v4TsK9ES.d.ts +0 -66
- package/dist/arrays-normalize-recursive-BqmVuFlD.d.ts +0 -72
- package/dist/extends-DtdRjDyU.d.ts +0 -343
- package/dist/if-ChM35c_q.d.ts +0 -19
- package/dist/is-array-BJeHxPM3.d.ts +0 -952
- package/dist/never-D89PbPh5.d.ts +0 -66
- package/dist/nils-CO8zLHSB.d.ts +0 -151
- package/dist/or-C6qzKt2I.d.ts +0 -82
- package/dist/override-CL2olHE5.d.ts +0 -59
- package/dist/pick-BSMX6Xe2.d.ts +0 -15
- package/dist/prettify-3o8_Kw6b.d.ts +0 -564
- package/dist/promises-LU7K00H0.d.ts +0 -72
- package/dist/string-B1jlOnws.d.ts +0 -312
- package/dist/types/index.d.ts +0 -3345
package/README.md
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
🚀 <strong>Rzl Utility JS</strong> 🚀<br/>
|
|
7
|
-
A lightweight, modern TypeScript utility library for Node.js & browser (via bundlers like Webpack/Vite)
|
|
8
|
-
Provides reusable helpers to simplify your JavaScript or TypeScript projects
|
|
9
|
-
<strong>Built with ❤️ by <a href="https://github.com/rzl-app" target="_blank" rel="nofollow noreferrer noopener">@rzl-app</a>.</strong>
|
|
6
|
+
🚀 <strong><u>Rzl Utility JS</u></strong> 🚀<br/>
|
|
7
|
+
<i>A lightweight, modern TypeScript utility library for Node.js & browser (via bundlers like Webpack/Vite).</i><br/>
|
|
8
|
+
<i>Provides reusable helpers to simplify your JavaScript or TypeScript projects.</i><br/>
|
|
9
|
+
<strong><i>Built with ❤️ by <a href="https://github.com/rzl-app" target="_blank" rel="nofollow noreferrer noopener">@rzl-app</a>.</i></strong>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<div align="center">
|
|
@@ -39,13 +39,15 @@ Provides reusable helpers to simplify your JavaScript or TypeScript projects.<br
|
|
|
39
39
|
|
|
40
40
|
---
|
|
41
41
|
|
|
42
|
-
<h2 id="table-of-contents">📚 Table of Contents</h2>
|
|
42
|
+
<h2 id="table-of-contents">📚 <strong>Table of Contents</strong></h2>
|
|
43
43
|
|
|
44
44
|
- 💻 [Requirements](#requirements)
|
|
45
45
|
- ⚙️ [Installation](#installation)
|
|
46
46
|
- ✨ [Features](#features)
|
|
47
47
|
- 🧬 [NextJS Support](#nextjs-support)
|
|
48
48
|
- 💎 [Detailed Features](#detailed-features)
|
|
49
|
+
- [Full documentation](#full-documentation-rzl-utilsjs-is-currently-under-construction-%EF%B8%8F)
|
|
50
|
+
- [Hint Autocomplete](#hint-autocomplete)
|
|
49
51
|
- 🔥 [Usage](#usage)
|
|
50
52
|
- ❤️ [Sponsor](#sponsor-this-package)
|
|
51
53
|
- 📜 [Changelog](#changelog)
|
|
@@ -56,35 +58,35 @@ Provides reusable helpers to simplify your JavaScript or TypeScript projects.<br
|
|
|
56
58
|
|
|
57
59
|
---
|
|
58
60
|
|
|
59
|
-
<h2 id="requirements">💻 Requirements</h2>
|
|
61
|
+
<h2 id="requirements">💻 <strong>Requirements</strong></h2>
|
|
60
62
|
|
|
61
63
|
- **Node.js `≥16.0.0`**
|
|
62
64
|
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
65
|
- 🔗 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
|
|
66
|
+
<a href="https://nextjs.org/docs/getting-started/installation#system-requirements" target="_blank" rel="nofollow noreferrer noopener"><i>NextJS Installation Requirements.</i></a>
|
|
65
67
|
|
|
66
|
-
- Works with
|
|
68
|
+
- **Works with:**
|
|
67
69
|
- ✅ Node.js (16.0.0+) - Without NextJS
|
|
68
70
|
- ✅ Node.js (18.17.0, or higher depending on NextJS version) - With NextJS
|
|
69
71
|
- ✅ Modern browsers (via bundlers like Webpack / Vite)
|
|
70
72
|
|
|
71
73
|
---
|
|
72
74
|
|
|
73
|
-
<h2 id="installation">⚙️ Installation</h2>
|
|
75
|
+
<h2 id="installation">⚙️ <strong>Installation</strong></h2>
|
|
74
76
|
|
|
75
|
-
#### With NPM
|
|
77
|
+
#### *With NPM*
|
|
76
78
|
|
|
77
79
|
```bash
|
|
78
80
|
npm install @rzl-zone/utils-js
|
|
79
81
|
```
|
|
80
82
|
|
|
81
|
-
#### With Yarn
|
|
83
|
+
#### *With Yarn*
|
|
82
84
|
|
|
83
85
|
```bash
|
|
84
86
|
yarn add @rzl-zone/utils-js
|
|
85
87
|
```
|
|
86
88
|
|
|
87
|
-
#### With PNPM
|
|
89
|
+
#### *With PNPM*
|
|
88
90
|
|
|
89
91
|
```bash
|
|
90
92
|
pnpm add @rzl-zone/utils-js
|
|
@@ -92,20 +94,20 @@ Provides reusable helpers to simplify your JavaScript or TypeScript projects.<br
|
|
|
92
94
|
|
|
93
95
|
---
|
|
94
96
|
|
|
95
|
-
<h2 id="features">✨ Features</h2>
|
|
97
|
+
<h2 id="features">✨ <strong>Features</strong></h2>
|
|
96
98
|
|
|
97
99
|
- 🚀 Written in **TypeScript** — fully typed & safe
|
|
98
100
|
- ⚡ Small, tree-shakable & fast
|
|
99
101
|
- 📦 Works in **Node.js** & modern browsers
|
|
100
102
|
- ❤️ Simple API, easy to extend
|
|
101
103
|
- 🧬 **Next.js support**: helpers for dynamic routes, building URLs, reading env, extracting client IP
|
|
102
|
-
- 🛠 Additional TypeScript types: `OmitStrict`, `PartialOnly`, etc.
|
|
104
|
+
- 🛠 Additional including TypeScript package **`@rzl-zone/ts-types-plus`** types: `OmitStrict`, `PartialOnly`, etc.
|
|
103
105
|
|
|
104
106
|
---
|
|
105
107
|
|
|
106
|
-
<h2 id="nextjs-support">🧬 Next.js Support</h2>
|
|
108
|
+
<h2 id="nextjs-support">🧬 <strong>Next.js Support</strong></h2>
|
|
107
109
|
|
|
108
|
-
This package also provides utilities specially built for Next.js environments, neatly separated into their own entry points
|
|
110
|
+
**This package also provides utilities specially built for Next.js environments, neatly separated into their own entry points:**
|
|
109
111
|
|
|
110
112
|
- <h3 id="nextjs-support--globals">`@rzl-zone/utils-js/next`</h3>
|
|
111
113
|
Helpers for building URLs, generating dynamic routes, reading environment variables, etc.
|
|
@@ -125,9 +127,9 @@ This package also provides utilities specially built for Next.js environments, n
|
|
|
125
127
|
|
|
126
128
|
---
|
|
127
129
|
|
|
128
|
-
<h2 id="detailed-features">💎 Detailed Features</h2>
|
|
130
|
+
<h2 id="detailed-features">💎 <strong>Detailed Features</strong></h2>
|
|
129
131
|
|
|
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**
|
|
132
|
+
### **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
133
|
#### For now, explore the examples or dive into the source — all utilities are documented via **TSDoc** and typed properly.
|
|
132
134
|
|
|
133
135
|
```ts
|
|
@@ -146,9 +148,40 @@ This package also provides utilities specially built for Next.js environments, n
|
|
|
146
148
|
import { | } from "@rzl-zone/utils-js/tailwind";
|
|
147
149
|
import { | } from "@rzl-zone/utils-js/urls";
|
|
148
150
|
|
|
149
|
-
import type { | } from "@rzl-zone/
|
|
151
|
+
import type { | } from "@rzl-zone/ts-types-plus";
|
|
150
152
|
```
|
|
151
|
-
####
|
|
153
|
+
#### Place your cursor inside { } or after "@rzl-zone/utils-js/{{ | }}" then press Ctrl+Space to see all available functions/types with full TSDoc hints.
|
|
154
|
+
---
|
|
155
|
+
### **Hint: Autocomplete**
|
|
156
|
+
|
|
157
|
+
**To get the best autocomplete hints for folders and files, add the `types` field in your configuration file:**
|
|
158
|
+
|
|
159
|
+
#### # **_TypeScript_**:
|
|
160
|
+
Add this to your `tsconfig.json`:
|
|
161
|
+
```jsonc
|
|
162
|
+
// tsconfig.json
|
|
163
|
+
{
|
|
164
|
+
"compilerOptions": {
|
|
165
|
+
"types": [
|
|
166
|
+
"@rzl-zone/utils-js"
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
#### # **_JavaScript_:**
|
|
173
|
+
Add this to your `jsconfig.json`:
|
|
174
|
+
```jsonc
|
|
175
|
+
// jsconfig.json
|
|
176
|
+
{
|
|
177
|
+
"compilerOptions": {
|
|
178
|
+
"types": [
|
|
179
|
+
"@rzl-zone/utils-js"
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
>ℹ️ ***Tip:*** *For JS projects, consider adding "checkJs": true for better IntelliSense.*
|
|
152
185
|
|
|
153
186
|
<!-- - <h4 id="detailed-features--assertions">
|
|
154
187
|
Assertions -
|
|
@@ -173,11 +206,11 @@ This package also provides utilities specially built for Next.js environments, n
|
|
|
173
206
|
-->
|
|
174
207
|
---
|
|
175
208
|
|
|
176
|
-
<h2 id="usage">🔥 Usage</h2>
|
|
209
|
+
<h2 id="usage">🔥 <strong>Usage</strong></h2>
|
|
177
210
|
|
|
178
|
-
### Easy to use, just import on your code base
|
|
211
|
+
### **Easy to use, just import on your code base.**
|
|
179
212
|
|
|
180
|
-
#### Example Function Import
|
|
213
|
+
#### *Example Function Import:*
|
|
181
214
|
|
|
182
215
|
```ts
|
|
183
216
|
import { isServer } from "@rzl-zone/utils-js/predicates";
|
|
@@ -186,10 +219,10 @@ console.log(isServer());
|
|
|
186
219
|
// ➔ `true` if running on server-side, `false` if in browser.
|
|
187
220
|
```
|
|
188
221
|
|
|
189
|
-
#### Example Types Helper Import
|
|
222
|
+
#### *Example Types Helper Import:*
|
|
190
223
|
|
|
191
224
|
```ts
|
|
192
|
-
import type { OmitStrict } from "@rzl-zone/
|
|
225
|
+
import type { OmitStrict } from "@rzl-zone/ts-types-plus";
|
|
193
226
|
|
|
194
227
|
type MyType = OmitStrict<OtherType, "omittingProps">;
|
|
195
228
|
// Fully strict TS omit that requires all keys to exist in target
|
|
@@ -197,46 +230,46 @@ type MyType = OmitStrict<OtherType, "omittingProps">;
|
|
|
197
230
|
|
|
198
231
|
---
|
|
199
232
|
|
|
200
|
-
<h2 id="sponsor-this-package">❤️ Sponsor this package</h2>
|
|
233
|
+
<h2 id="sponsor-this-package">❤️ <strong>Sponsor this package</strong></h2>
|
|
201
234
|
|
|
202
|
-
Help support development
|
|
203
|
-
[👉 Become a sponsor](https://github.com/sponsors/rzl-app)
|
|
235
|
+
**Help support development:**
|
|
236
|
+
*[👉 Become a sponsor](https://github.com/sponsors/rzl-app)*
|
|
204
237
|
|
|
205
238
|
---
|
|
206
239
|
|
|
207
|
-
<h2 id="changelog">📝 Changelog</h2>
|
|
240
|
+
<h2 id="changelog">📝 <strong>Changelog</strong></h2>
|
|
208
241
|
|
|
209
|
-
See [CHANGELOG](CHANGELOG.md)
|
|
242
|
+
**See [CHANGELOG](CHANGELOG.md).**
|
|
210
243
|
|
|
211
244
|
---
|
|
212
245
|
|
|
213
|
-
<h2 id="contributing">🤝 Contributing</h2>
|
|
246
|
+
<h2 id="contributing">🤝 <strong>Contributing</strong></h2>
|
|
214
247
|
|
|
215
|
-
See [CONTRIBUTING](CONTRIBUTING.md)
|
|
248
|
+
**See [CONTRIBUTING](CONTRIBUTING.md).**
|
|
216
249
|
|
|
217
250
|
---
|
|
218
251
|
|
|
219
|
-
<h2 id="security">🔒 Security</h2>
|
|
252
|
+
<h2 id="security">🔒 <strong>Security</strong></h2>
|
|
220
253
|
|
|
221
|
-
Please report issues to [rizalvindwiky1998@gmail.com](mailto:rizalvindwiky1998@gmail.com)
|
|
254
|
+
**Please report issues to [rizalvindwiky1998@gmail.com](mailto:rizalvindwiky1998@gmail.com).**
|
|
222
255
|
|
|
223
256
|
---
|
|
224
257
|
|
|
225
|
-
<h2 id="credits">🙌 Credits</h2>
|
|
258
|
+
<h2 id="credits">🙌 <strong>Credits</strong></h2>
|
|
226
259
|
|
|
227
|
-
|
|
228
|
-
|
|
260
|
+
**- [Rzl App](https://github.com/rzl-app)**
|
|
261
|
+
**- [All Contributors](../../contributors)**
|
|
229
262
|
|
|
230
263
|
---
|
|
231
264
|
|
|
232
|
-
<h2 id="license">📜 License</h2>
|
|
265
|
+
<h2 id="license">📜 <strong>License</strong></h2>
|
|
233
266
|
|
|
234
|
-
The MIT License (MIT)
|
|
235
|
-
Please see [License File](LICENSE.md) for more information
|
|
267
|
+
**The MIT License (MIT).**
|
|
268
|
+
*Please see **[License File](LICENSE.md)** for more information.*
|
|
236
269
|
|
|
237
270
|
---
|
|
238
271
|
|
|
239
272
|
✅ **Enjoy using `@rzl-zone/utils-js`?**
|
|
240
|
-
Star this repo ⭐ and share it with other JavaScript developers
|
|
273
|
+
*Star this repo [⭐](https://github.com/rzl-zone/utils-js) and share it with other JavaScript developers!*
|
|
241
274
|
|
|
242
275
|
---
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Prettify,PickStrict}from'@rzl-zone/ts-types-plus';import{G as GetPreciseTypeOptions,I as IsNumberOptions,a as IsPlainObjectResult}from'../isPlainObject-CEPWPiXh.js';
|
|
2
2
|
/** -------------------------------------------------------
|
|
3
3
|
* * ***Shape of the object passed to custom error message functions.***
|
|
4
4
|
* -------------------------------------------------------
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Nullish,KeepNull,KeepUndef,AnyFunction,NormalizeEmptyArraysRecursive,RemoveEmptyArrayElements,FixNeverArrayRecursive,IfNotExtends,IfExtends,IsAny,NumberRangeUnion,Prettify,OrArr,Extends,AndArr,TypedArray,WebApiObjects,IntlObjects}from'@rzl-zone/ts-types-plus';type NormalizeInputToNumberArrayUnRecursive<T>=T extends string|bigint|boolean|number|Nullish?T:HasNonNumberLikeNonNullish<T>;
|
|
2
2
|
/** Detects whether `T` contains any number-like type (`string | number | bigint`).
|
|
3
3
|
*
|
|
4
4
|
* @template T Input type.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{NumberFormat,CountryCode}from'libphonenumber-js';import{
|
|
1
|
+
import{NumberFormat,CountryCode}from'libphonenumber-js';import{OverrideTypes,ExtractStrict,Prettify,OmitStrict,AnyString}from'@rzl-zone/ts-types-plus';import{FormatOptions,Locale}from'date-fns';type NegativeFormatOptionCustom={
|
|
2
2
|
/** Custom formatter function for the final formatted negative string.
|
|
3
3
|
* If provided, it ***OVERRIDES*** style & space entirely. */
|
|
4
4
|
custom:(formatted:string)=>string;style?:never;space?:never;};type NegativeFormatOptionUnCustom={custom?:never;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{NullToUndefined,FixNeverArrayRecursive,IfNonEmptyArray,Extends}from'@rzl-zone/ts-types-plus';
|
|
2
2
|
/** ---------------------------------
|
|
3
3
|
* * ***Utility: `getRandomItem`.***
|
|
4
4
|
* ---------------------------------
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{NonPlainObject}from'@rzl-zone/ts-types-plus';
|
|
2
2
|
/** ---------------------------------------------------------------------------
|
|
3
3
|
* * ***Type Options for {@link getPreciseType | `getPreciseType`}.***
|
|
4
4
|
* ---------------------------------------------------------------------------
|
package/dist/next/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{IsAny}from'@rzl-zone/ts-types-plus';
|
|
2
2
|
/** ---------------------------------------------------------
|
|
3
3
|
* * ***Extracts dynamic route parameters from a given route string.***
|
|
4
4
|
* ---------------------------------------------------------
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{NumberRangeUnion}from'@rzl-zone/ts-types-plus';
|
|
2
2
|
/** ----------------------------------------------------------------------
|
|
3
3
|
* * ***Utility: `findDuplicates`.***
|
|
4
4
|
* ----------------------------------------------------------------------
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{NumberRangeUnion,Prettify,IsPositive,ParseNumber,Extends,IsStringLiteral,CharAt,AnyString,AnyFunction,IsEmptyString,Trim,IsAny,IsUnknown,IsNever,IsReadonlyArray,IsArray,AnObjectNonArray,OrArr,TypedArray}from'@rzl-zone/ts-types-plus';import{a as IsPlainObjectResult}from'../isPlainObject-CEPWPiXh.js';export{G as GetPreciseTypeOptions,I as IsNumberOptions,g as getPreciseType,i as isNumber,b as isPlainObject}from'../isPlainObject-CEPWPiXh.js';
|
|
2
2
|
/** ----------------------------------------------------------
|
|
3
3
|
* * ***Predicate: `areArraysEqual`.***
|
|
4
4
|
* ----------------------------------------------------------
|
package/dist/promises/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{CustomPromiseType}from'@rzl-zone/ts-types-plus';
|
|
2
2
|
/** -------------------------------------------------------------
|
|
3
3
|
* * ***Utility Class: `CustomPromise`.***
|
|
4
4
|
* -------------------------------------------------------------
|
package/dist/strings/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Nilable,Extends}from'@rzl-zone/ts-types-plus';type CapitalizeFirstOptions={
|
|
2
2
|
/** If true **(default)**, the rest of the string will be converted to lowercase after capitalizing the first letter.
|
|
3
3
|
*
|
|
4
4
|
* @default true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rzl-zone/utils-js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"engineStrict": true,
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"url": "https://github.com/rzl-zone/utils-js/issues"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"@rzl-zone/ts-types-plus": "latest",
|
|
21
22
|
"date-fns": "^4.1.0",
|
|
22
23
|
"libphonenumber-js": "^1.12.17",
|
|
23
24
|
"server-only": "^0.0.1",
|
|
@@ -201,9 +202,6 @@
|
|
|
201
202
|
"types": "./dist/urls/index.d.ts",
|
|
202
203
|
"default": "./dist/urls/index.cjs"
|
|
203
204
|
}
|
|
204
|
-
},
|
|
205
|
-
"./types": {
|
|
206
|
-
"types": "./dist/types/index.d.ts"
|
|
207
205
|
}
|
|
208
206
|
},
|
|
209
207
|
"typesVersions": {
|
|
@@ -252,9 +250,6 @@
|
|
|
252
250
|
],
|
|
253
251
|
"urls": [
|
|
254
252
|
"dist/urls/index.d.ts"
|
|
255
|
-
],
|
|
256
|
-
"types": [
|
|
257
|
-
"dist/types/index.d.ts"
|
|
258
253
|
]
|
|
259
254
|
}
|
|
260
255
|
},
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/** --------------------------------------------------
|
|
2
|
-
* * ***Internal Utility Type for: {@link NumberRangeUnion | `NumberRangeUnion`}.***
|
|
3
|
-
* --------------------------------------------------
|
|
4
|
-
* @template N - Starting/Ending number of the range (inclusive).
|
|
5
|
-
* @template Acc - Internal accumulator for recursion (do not set manually).
|
|
6
|
-
*/
|
|
7
|
-
type Enumerate<N extends number,Acc extends number[]=[]>=Acc["length"] extends N?Acc[number]:Enumerate<N,[...Acc,Acc["length"]]>;
|
|
8
|
-
/** --------------------------------------------------
|
|
9
|
-
* * ***Utility Type: `NumberRangeUnion`.***
|
|
10
|
-
* --------------------------------------------------
|
|
11
|
-
* **Generate a union type of numbers from `From` to `To` using enumeration.**
|
|
12
|
-
* @description
|
|
13
|
-
* Produces a **numeric union type** from `From` to `To` (inclusive),
|
|
14
|
-
* using a simpler approach based on `Enumerate<N>` helper type.
|
|
15
|
-
* - ✅ Straightforward & easy to reason about.
|
|
16
|
-
* - ⚠️ Still limited by TypeScript recursion depth (safe up to `999`).
|
|
17
|
-
* - ⚙️ Best used for **smaller ranges** (`≤ 100`) or when readability matters.
|
|
18
|
-
* - ℹ️ For **larger ranges** (`≥ 101`) use {@link NumberRangeLimit | `NumberRangeLimit`} instead.
|
|
19
|
-
* @template From - Starting number of the range (inclusive).
|
|
20
|
-
* @template To - Ending number of the range (inclusive).
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* type RangeA = NumberRangeUnion<3, 6>;
|
|
24
|
-
* // ➔ 3 | 4 | 5 | 6
|
|
25
|
-
* type RangeB = NumberRangeUnion<0, 2>;
|
|
26
|
-
* // ➔ 0 | 1 | 2
|
|
27
|
-
* type RangeC = NumberRangeUnion<8, 8>;
|
|
28
|
-
* // ➔ 8
|
|
29
|
-
* type RangeD = NumberRangeUnion<20, 10>;
|
|
30
|
-
* // ➔ 10
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
type NumberRangeUnion<From extends number,To extends number>=From extends To?From:Exclude<Enumerate<To>,Enumerate<From>>extends never?To:Exclude<Enumerate<To>,Enumerate<From>>|To;export type{NumberRangeUnion as N};
|
package/dist/any-v4TsK9ES.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import{I as If}from'./if-ChM35c_q.js';
|
|
2
|
-
/** -------------------------------------------------------
|
|
3
|
-
* * ***Utility Type: `IsAny`.***
|
|
4
|
-
* -------------------------------------------------------
|
|
5
|
-
* **A type-level utility that checks whether a type is ***`any`***.**
|
|
6
|
-
* - **Behavior:**
|
|
7
|
-
* - Returns `true` if `T` is `any`.
|
|
8
|
-
* - Returns `false` for otherwise.
|
|
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
|
-
type IsAny<T>=0 extends 1 & T?true:false;
|
|
19
|
-
/** -------------------------------------------------------
|
|
20
|
-
* * ***Utility Type: `IfAny`.***
|
|
21
|
-
* -------------------------------------------------------
|
|
22
|
-
* **A type-level conditional utility that returns one type if ***`T` is `any`***,
|
|
23
|
-
* and another type otherwise.**
|
|
24
|
-
* - **Behavior:**
|
|
25
|
-
* - Defaults to `true` when `T` is `any`.
|
|
26
|
-
* - Defaults to `false` for otherwise.
|
|
27
|
-
* @template T - The type to check.
|
|
28
|
-
* @template IfTrue - The type to return if `T` is `any`, *(default: `true`)*.
|
|
29
|
-
* @template IfFalse - The type to return if `T` is not `any`, *(default: `false`)*.
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* type A = IfAny<any, string, number>;
|
|
33
|
-
* // ➔ string
|
|
34
|
-
* type B = IfAny<string, string, number>;
|
|
35
|
-
* // ➔ number
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
type IfAny<T,IfTrue=true,IfFalse=false>=If<IsAny<T>,IfTrue,IfFalse>;
|
|
39
|
-
/** * ***Configuration options for a type-level utility for
|
|
40
|
-
* {@link AnifyProperties | `AnifyProperties`}.***
|
|
41
|
-
*/
|
|
42
|
-
type AnifyPropertiesOptions={
|
|
43
|
-
/** If `makeOptional: true`, all properties become optional, otherwise, all properties are required and typed as `any`, defaultValue: `false`.
|
|
44
|
-
*
|
|
45
|
-
* @default false
|
|
46
|
-
*/
|
|
47
|
-
makeOptional:boolean;};
|
|
48
|
-
/** -------------------------------------------------------
|
|
49
|
-
* * ***Utility Type: `AnifyProperties`.***
|
|
50
|
-
* -------------------------------------------------------
|
|
51
|
-
* **A type-level utility that transforms all properties of an object
|
|
52
|
-
* into ***`any`***.**
|
|
53
|
-
* - **Behavior:**
|
|
54
|
-
* - If `makeOptional: true`, all properties become optional.
|
|
55
|
-
* - Otherwise, all properties are required and typed as `any`.
|
|
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
|
-
* type B = AnifyProperties<{a: string; b: number}, { makeOptional: true }>;
|
|
63
|
-
* // ➔ { a?: any; b?: any }
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
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 +0,0 @@
|
|
|
1
|
-
/** -------------------------------------------------------
|
|
2
|
-
* * ***Utility Type: `FixNeverArrayRecursive`.***
|
|
3
|
-
* -------------------------------------------------------
|
|
4
|
-
* **A type-level utility that **recursively transforms arrays of type `never[]` into empty arrays**.**
|
|
5
|
-
* - **Behavior:**
|
|
6
|
-
* - Preserves `readonly` modifiers.
|
|
7
|
-
* - Applies recursively for nested arrays.
|
|
8
|
-
* - Leaves other types unchanged.
|
|
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
|
-
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
|
-
/** -------------------------------------------------------
|
|
26
|
-
* * ***Utility Type: `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
|
-
* - **Behavior:**
|
|
30
|
-
* - Preserves `readonly` modifiers.
|
|
31
|
-
* - Recurses into nested arrays.
|
|
32
|
-
* - Leaves other array types unchanged.
|
|
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
|
-
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
|
-
/** -------------------------------------------------------
|
|
50
|
-
* * ***Utility Type: `RemoveEmptyArrayElements`.***
|
|
51
|
-
* -------------------------------------------------------
|
|
52
|
-
* **A type-level utility that **recursively removes empty array elements (`[]`) from a tuple type**.**
|
|
53
|
-
* - **Behavior:**
|
|
54
|
-
* - If `T` is a tuple, checks the first element:
|
|
55
|
-
* - If `Head` is an empty array type (`[]`), it is removed.
|
|
56
|
-
* - Otherwise, `Head` is preserved.
|
|
57
|
-
* - Repeats recursively on the rest of the tuple.
|
|
58
|
-
* - Leaves non-tuple types unchanged.
|
|
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
|
-
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};
|