@rzl-zone/utils-js 3.11.0 → 3.12.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 +96 -112
- package/dist/assertions/index.cjs +11 -11
- package/dist/assertions/index.d.ts +5 -5
- package/dist/assertions/index.js +5 -5
- package/dist/{chunk-TER22LO4.cjs → chunk-2AFQ33D3.cjs} +8 -8
- package/dist/{chunk-SZUNAEMR.js → chunk-2CYDJVGM.js} +6 -6
- package/dist/{chunk-6EDFZJZ5.cjs → chunk-2MW4JDQ2.cjs} +126 -126
- package/dist/{chunk-M7ELWZXM.cjs → chunk-2VTDXC3N.cjs} +9 -9
- package/dist/{chunk-6YGBRENU.js → chunk-44XX2P34.js} +3 -3
- package/dist/{chunk-WLOQQFDS.cjs → chunk-4YLBKLGS.cjs} +3 -3
- package/dist/{chunk-Q4GEQS7X.cjs → chunk-566CXQW7.cjs} +163 -167
- package/dist/{chunk-MV3TSQSH.cjs → chunk-57EPKYID.cjs} +71 -71
- package/dist/{chunk-2XSZ2ANI.js → chunk-5MGEC3YG.js} +2 -2
- package/dist/{chunk-HYN6FC5A.cjs → chunk-6EF52423.cjs} +34 -34
- package/dist/{chunk-LJHPTLWB.js → chunk-6SCOKU3S.js} +7 -7
- package/dist/{chunk-AXDYWO67.js → chunk-6VUXD3CF.js} +2 -2
- package/dist/{chunk-C2PV3VWC.cjs → chunk-7B76BSNK.cjs} +6 -6
- package/dist/{chunk-ZPDMWDGZ.cjs → chunk-7Y6I2DSU.cjs} +14 -14
- package/dist/{chunk-KXJ7X325.cjs → chunk-A7S7E2EE.cjs} +37 -37
- package/dist/{chunk-BPYW5YL7.js → chunk-AJZ6PMMZ.js} +2 -2
- package/dist/{chunk-PGNL7JXO.cjs → chunk-AXGBL2IO.cjs} +40 -40
- package/dist/{chunk-NLZLXWAU.cjs → chunk-B4TC6FBV.cjs} +9 -9
- package/dist/chunk-BAV5T2E3.cjs +1 -1
- package/dist/{chunk-3T6VSWYX.js → chunk-BKIJBNIE.js} +2 -2
- package/dist/{chunk-RBWZII5I.js → chunk-BNIMTFK5.js} +3 -3
- package/dist/{chunk-5WIEDF2J.js → chunk-BXW7YXB7.js} +4 -4
- package/dist/{chunk-22V4WP3H.js → chunk-CFYZC4S6.js} +4 -4
- package/dist/{chunk-MSUW5VHZ.js → chunk-CSG4SCL3.js} +10 -13
- package/dist/{chunk-JIE447J5.js → chunk-CWQW7AKK.js} +3 -3
- package/dist/chunk-DVMHRLKP.cjs +1 -1
- package/dist/{chunk-U7HHN47R.js → chunk-EN7LVZBZ.js} +12 -16
- package/dist/{chunk-EBYFYZW4.cjs → chunk-EV4Y7HCY.cjs} +4 -4
- package/dist/{chunk-NVRZPF5M.cjs → chunk-F66VDYIZ.cjs} +3 -3
- package/dist/{chunk-BMZZXZJ2.cjs → chunk-FLJX37EL.cjs} +4 -4
- package/dist/{chunk-SYHPSOUU.cjs → chunk-GKC3UDMC.cjs} +10 -13
- package/dist/{chunk-GIKL4PUF.cjs → chunk-H65I3GRZ.cjs} +10 -10
- package/dist/{chunk-HNBRGN4R.js → chunk-HHYWB7VZ.js} +2 -2
- package/dist/{chunk-MUHRPRR7.cjs → chunk-HNGGISFL.cjs} +3 -3
- package/dist/{chunk-B6PMNZ4M.cjs → chunk-HNSQAVSZ.cjs} +6 -6
- package/dist/{chunk-RZOGBYIS.js → chunk-HSP6IWZK.js} +3 -7
- package/dist/{chunk-IZGVBYFN.js → chunk-IDZS7J6T.js} +13 -13
- package/dist/{chunk-ENMRZ4BE.js → chunk-JS6R55VL.js} +3 -3
- package/dist/{chunk-WETQI6HM.js → chunk-JZVT5FK7.js} +9 -9
- package/dist/chunk-KHO2SBNA.cjs +1 -1
- package/dist/{chunk-TJHGRQ4P.js → chunk-KIDJCMNJ.js} +2 -2
- package/dist/{chunk-7FGNVDEV.cjs → chunk-KOLEURVT.cjs} +7 -7
- package/dist/{chunk-K5536YHG.cjs → chunk-L4V53MQK.cjs} +50 -50
- package/dist/chunk-L5RDAVVH.js +1 -1
- package/dist/{chunk-CCJ2MSN7.js → chunk-NODTV4F3.js} +2 -2
- package/dist/{chunk-QYI2VJLS.cjs → chunk-NYK5K3V2.cjs} +9 -9
- package/dist/{chunk-XPVTIGU2.cjs → chunk-ODUO3RTL.cjs} +26 -26
- package/dist/chunk-ONZFBJVW.js +1 -1
- package/dist/{chunk-ZVWZEGQP.js → chunk-PFXCTE37.js} +2 -2
- package/dist/{chunk-FJ4BQFVO.js → chunk-PPST7QAQ.js} +8 -8
- package/dist/{chunk-RMP7VMPB.cjs → chunk-Q5IMYDFL.cjs} +12 -12
- package/dist/{chunk-UIAWUZ4H.js → chunk-QFFBIOJ4.js} +4 -4
- package/dist/chunk-QNKGP5DY.js +1 -1
- package/dist/{chunk-DLS3G6WQ.cjs → chunk-RRQHMOPE.cjs} +4 -8
- package/dist/{chunk-BLF7SD66.js → chunk-RU5OSRBU.js} +3 -3
- package/dist/{chunk-GOFINGT6.js → chunk-SDMPEJ4F.js} +2 -2
- package/dist/{chunk-K47GZDBH.js → chunk-SYNL5IKP.js} +3 -3
- package/dist/{chunk-ULQPCIA2.js → chunk-TCDOWZQE.js} +2 -2
- package/dist/{chunk-DAPAK2W3.cjs → chunk-TQPGXGKB.cjs} +31 -31
- package/dist/{chunk-DNMCR5JH.js → chunk-TULOI4GL.js} +9 -9
- package/dist/{chunk-SU3UELUB.cjs → chunk-UBHCP4N5.cjs} +3 -3
- package/dist/{chunk-U23I7JPB.cjs → chunk-UCHF3M34.cjs} +15 -15
- package/dist/chunk-UDA26MCU.cjs +1 -1
- package/dist/{chunk-XX6RUGTM.cjs → chunk-V3C4FYZL.cjs} +3 -3
- package/dist/{chunk-6LXWT2I5.js → chunk-VAAHZFBF.js} +2 -2
- package/dist/chunk-VJDDGRIK.cjs +1 -1
- package/dist/chunk-WVSPXFTY.js +1 -1
- package/dist/{chunk-GXKQ3LHF.js → chunk-WYP76WXB.js} +3 -3
- package/dist/{chunk-JXEIJM5M.cjs → chunk-YDE4ZBB7.cjs} +61 -61
- package/dist/{chunk-WXFTVXBF.cjs → chunk-YKQEOO7C.cjs} +4 -4
- package/dist/{chunk-BOYP3ARU.js → chunk-YSZC56SZ.js} +4 -4
- package/dist/chunk-YWHHVDT4.js +1 -1
- package/dist/conversions/index.cjs +34 -34
- package/dist/conversions/index.d.ts +1 -1
- package/dist/conversions/index.js +15 -15
- package/dist/events/index.cjs +8 -8
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +4 -4
- package/dist/formatters/index.cjs +19 -19
- package/dist/formatters/index.d.ts +1 -1
- package/dist/formatters/index.js +9 -9
- package/dist/generators/index.cjs +9 -9
- package/dist/generators/index.d.ts +1 -1
- package/dist/generators/index.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/{isPlainObject-0p3VveWr.d.ts → isPlainObject-DTJVV2Kf.d.ts} +5 -3
- package/dist/next/index.cjs +41 -39
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.js +13 -11
- package/dist/next/server/index.cjs +4 -4
- package/dist/next/server/index.d.ts +1 -1
- package/dist/next/server/index.js +2 -2
- package/dist/operations/index.cjs +11 -11
- package/dist/operations/index.d.ts +1 -1
- package/dist/operations/index.js +8 -8
- package/dist/parsers/index.cjs +6 -6
- package/dist/parsers/index.d.ts +1 -1
- package/dist/parsers/index.js +5 -5
- package/dist/predicates/index.cjs +77 -77
- package/dist/predicates/index.d.ts +6 -6
- package/dist/predicates/index.js +14 -14
- package/dist/promises/index.cjs +6 -6
- package/dist/promises/index.d.ts +1 -1
- package/dist/promises/index.js +4 -4
- package/dist/rzl-utils.global.js +2 -2
- package/dist/strings/index.cjs +23 -23
- package/dist/strings/index.d.ts +1 -1
- package/dist/strings/index.js +7 -7
- package/dist/tailwind/index.cjs +13 -13
- package/dist/tailwind/index.d.ts +1 -1
- package/dist/tailwind/index.js +5 -5
- package/dist/urls/index.cjs +23 -23
- package/dist/urls/index.d.ts +1 -1
- package/dist/urls/index.js +16 -16
- package/package.json +22 -20
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<div align="center" style="display: flex; flex-direction: column; align-items: center;gap: 0rem">
|
|
2
2
|
<a target="_blank" rel="noopener noreferrer" href="https://raw.githubusercontent.com/rzl-zone/utils-js/main/logo-circle.png">
|
|
3
|
-
<img src="https://raw.githubusercontent.com/rzl-zone/utils-js/main/logo-circle.png" align="middle" alt="RzlZone Logo" width="110" style="max-width: 100%;"
|
|
3
|
+
<img src="https://raw.githubusercontent.com/rzl-zone/utils-js/main/logo-circle.png" align="middle" alt="RzlZone Logo" width="110" style="max-width: 100%;" />
|
|
4
4
|
</a>
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
7
|
<h1 align="center"><strong>UtilsJS</strong></h1>
|
|
8
8
|
|
|
9
|
-
<p align="center">
|
|
9
|
+
<p align="center">
|
|
10
10
|
<i>
|
|
11
11
|
A lightweight, modern TypeScript utility library for Node.js & browser (via bundlers like <a href="https://webpack.js.org"><code>Webpack</code></a>, <a href="https://vercel.com/blog/turbopack"><code>Turbopack</code></a>, or <a href="https://vite.dev/"><code>Vite</code></a>).
|
|
12
12
|
</i><br/>
|
|
@@ -15,38 +15,36 @@
|
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
17
|
<div align="center">
|
|
18
|
-
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
</
|
|
44
|
-
</p>
|
|
45
|
-
|
|
18
|
+
<p>
|
|
19
|
+
<a href="https://npmjs.com/package/@rzl-zone/utils-js" target="_blank" rel="nofollow noreferrer noopener">
|
|
20
|
+
<img src="https://img.shields.io/npm/v/@rzl-zone/utils-js?logo=npm&label=Latest%20Version&color=4CAF50&logoColor=CB3837&style=flat-rounded" alt="Latest Version on NPM" />
|
|
21
|
+
</a>
|
|
22
|
+
<a href="https://npmjs.com/package/@rzl-zone/utils-js" target="_blank" rel="nofollow noreferrer noopener">
|
|
23
|
+
<img src="https://img.shields.io/npm/dt/@rzl-zone/utils-js?logo=npm&label=Total%20Downloads&color=007EC6&logoColor=CB3837&style=flat-rounded" alt="NPM Total Downloads" />
|
|
24
|
+
</a>
|
|
25
|
+
<a href="https://npmjs.com/package/@rzl-zone/utils-js" target="_blank" rel="nofollow noreferrer noopener">
|
|
26
|
+
<img src="https://img.shields.io/npm/dw/@rzl-zone/utils-js?logo=npm&label=Weekly%20Downloads&color=CB3837&logoColor=CB3837&style=flat-rounded" alt="NPM Weekly Downloads" />
|
|
27
|
+
</a>
|
|
28
|
+
<a href="https://nodejs.org/en/" target="_blank" rel="nofollow noreferrer noopener">
|
|
29
|
+
<img src="https://img.shields.io/badge/Node.js-18.18.0%2B-green.svg?logo=node.js&color=339933&style=flat-rounded" alt="Node.js" />
|
|
30
|
+
</a>
|
|
31
|
+
<a href="https://github.com/rzl-zone/utils-js/blob/main/CONTRIBUTING.md" target="_blank" rel="nofollow noreferrer noopener">
|
|
32
|
+
<img src="https://img.shields.io/badge/PRs-Welcome-brightgreen.svg?color=28A745" alt="PRs Welcome" />
|
|
33
|
+
</a>
|
|
34
|
+
<a href="https://github.com/rzl-zone/utils-js/blob/main/LICENSE.md" target="_blank" rel="nofollow noreferrer noopener">
|
|
35
|
+
<img src="https://img.shields.io/badge/License-MIT-blue.svg?color=3DA639" alt="GitHub license" />
|
|
36
|
+
</a>
|
|
37
|
+
<a href="https://github.com/rzl-zone/utils-js" target="_blank" rel="nofollow noreferrer noopener">
|
|
38
|
+
<img src="https://img.shields.io/badge/Repo-on%20GitHub-181717?logo=github" alt="GitHub" />
|
|
39
|
+
</a>
|
|
40
|
+
<a href="https://github.com/orgs/rzl-zone/repositories" target="_blank" rel="nofollow noreferrer noopener">
|
|
41
|
+
<img src="https://img.shields.io/badge/Org-rzl--zone-24292e?logo=github&style=flat-rounded" alt="Repo on GitHub" />
|
|
42
|
+
</a>
|
|
43
|
+
</p>
|
|
46
44
|
</div>
|
|
47
45
|
|
|
48
46
|
---
|
|
49
|
-
|
|
47
|
+
|
|
50
48
|
<h2 id="table-of-contents">📚 <strong>Table of Contents</strong></h2>
|
|
51
49
|
|
|
52
50
|
- 💻 [Requirements](#requirements)
|
|
@@ -80,9 +78,9 @@
|
|
|
80
78
|
- ✅ Modern browsers (via bundlers like [`Webpack`](https://webpack.js.org), [`Turbopack`](https://vercel.com/blog/turbopack), or [`Vite`](https://vite.dev)).
|
|
81
79
|
|
|
82
80
|
- **TypeScript Build Info:**
|
|
83
|
-
- Target: `ES2022
|
|
84
|
-
- Module: `ES2022
|
|
85
|
-
- Module Resolution: `bundler
|
|
81
|
+
- Target: `ES2022`.
|
|
82
|
+
- Module: `ES2022`.
|
|
83
|
+
- Module Resolution: `bundler`.
|
|
86
84
|
|
|
87
85
|
<br/>
|
|
88
86
|
|
|
@@ -115,11 +113,12 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
115
113
|
|
|
116
114
|
<h2 id="features">✨ <strong>Features</strong></h2>
|
|
117
115
|
|
|
118
|
-
- 🚀 Written in **TypeScript** — fully typed & safe
|
|
119
|
-
- ⚡ Small, tree-shakable & fast
|
|
120
|
-
- 📦 Works in **Node.js** & modern browsers
|
|
121
|
-
- ❤️ Simple API, easy to extend
|
|
122
|
-
- 🧬 **Next.js support**: helpers for dynamic routes, building URLs, reading env, extracting client IP
|
|
116
|
+
- 🚀 Written in **TypeScript** — fully typed & safe.
|
|
117
|
+
- ⚡ Small, tree-shakable & fast.
|
|
118
|
+
- 📦 Works in **Node.js** & modern browsers.
|
|
119
|
+
- ❤️ Simple API, easy to extend.
|
|
120
|
+
- 🧬 **Next.js support**: helpers for dynamic routes, building URLs, reading env, extracting client IP.
|
|
121
|
+
|
|
123
122
|
---
|
|
124
123
|
|
|
125
124
|
<h2 id="nextjs-support">🧬 <strong>Next.js Support</strong></h2>
|
|
@@ -127,13 +126,13 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
127
126
|
**This package also provides utilities specially built for Next.js environments, neatly separated into their own entry points:**
|
|
128
127
|
|
|
129
128
|
- <h4 id="nextjs-support--globals"><strong><code>@rzl-zone/utils-js/next</code></strong></h4>
|
|
130
|
-
Helpers for building URLs, generating dynamic routes, reading environment variables, etc.
|
|
129
|
+
Helpers for building URLs, generating dynamic routes, reading environment variables, etc.
|
|
131
130
|
|
|
132
131
|
✅ Safe to use in both Next.js pages & API routes.
|
|
133
132
|
|
|
134
133
|
[**Read More Docs**](/docs/next-js/global.md#docs-sub-main--title)
|
|
135
134
|
|
|
136
|
-
|
|
135
|
+
---
|
|
137
136
|
|
|
138
137
|
- <h4 id="nextjs-support--server-only"><strong><code>@rzl-zone/utils-js/next/server</code></strong></h4>
|
|
139
138
|
Utilities meant to run in Next.js server-only contexts (like middleware or server actions) for tasks such as extracting real client IPs.
|
|
@@ -146,32 +145,33 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
146
145
|
|
|
147
146
|
<h2 id="detailed-features">💎 <strong>Detailed Features</strong></h2>
|
|
148
147
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
148
|
+
<h3 id="detailed-features--full-documentation">
|
|
149
|
+
<strong>
|
|
150
|
+
The full <a href="https://rzlzone.vercel.app/docs/utils-js" target="_blank" rel="nofollow noreferrer noopener">UtilsJS</a> documentation is
|
|
151
|
+
<strong>currently under construction 🏗️</strong>.
|
|
152
|
+
</strong>
|
|
153
|
+
</h3>
|
|
155
154
|
|
|
156
|
-
|
|
155
|
+
#### For now, explore the examples or dive into the source — all utilities are documented via **TSDoc** and typed properly.
|
|
157
156
|
|
|
158
157
|
```ts
|
|
159
|
-
import {
|
|
160
|
-
import {
|
|
161
|
-
import {
|
|
162
|
-
import {
|
|
163
|
-
import {
|
|
164
|
-
import {
|
|
165
|
-
import {
|
|
166
|
-
import {
|
|
167
|
-
import {
|
|
168
|
-
import {
|
|
169
|
-
import {
|
|
170
|
-
import {
|
|
171
|
-
import {
|
|
172
|
-
import {
|
|
158
|
+
import { /* … */ } from "@rzl-zone/utils-js/assertions";
|
|
159
|
+
import { /* … */ } from "@rzl-zone/utils-js/conversions";
|
|
160
|
+
import { /* … */ } from "@rzl-zone/utils-js/events";
|
|
161
|
+
import { /* … */ } from "@rzl-zone/utils-js/formatters";
|
|
162
|
+
import { /* … */ } from "@rzl-zone/utils-js/generators";
|
|
163
|
+
import { /* … */ } from "@rzl-zone/utils-js/next";
|
|
164
|
+
import { /* … */ } from "@rzl-zone/utils-js/next/server";
|
|
165
|
+
import { /* … */ } from "@rzl-zone/utils-js/operations";
|
|
166
|
+
import { /* … */ } from "@rzl-zone/utils-js/parsers";
|
|
167
|
+
import { /* … */ } from "@rzl-zone/utils-js/predicates";
|
|
168
|
+
import { /* … */ } from "@rzl-zone/utils-js/promises";
|
|
169
|
+
import { /* … */ } from "@rzl-zone/utils-js/strings";
|
|
170
|
+
import { /* … */ } from "@rzl-zone/utils-js/tailwind";
|
|
171
|
+
import { /* … */ } from "@rzl-zone/utils-js/urls";
|
|
173
172
|
```
|
|
174
|
-
|
|
173
|
+
|
|
174
|
+
#### Place your cursor inside `{ }` or right after the package path `@rzl-zone/utils-js/<put-cursor-here>`, then press Ctrl+Space (Windows/Linux) or Cmd+Space (macOS), or use your editor’s autocomplete shortcut, to see all available functions and types with full TSDoc hints.
|
|
175
175
|
|
|
176
176
|
> ***⚠️ Note:*** Starting from version `3.4.0+`, the extra TypeScript types (e.g., `OmitStrict`, `PartialOnly`, etc), have been removed from the package, to use them, you now need to install **[`@rzl-zone/ts-types-plus`](https://www.npmjs.com/package/@rzl-zone/ts-types-plus)** separately.
|
|
177
177
|
|
|
@@ -183,7 +183,8 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
183
183
|
</strong>
|
|
184
184
|
</h3>
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
#### **Including via CDN:**
|
|
187
|
+
|
|
187
188
|
```xml
|
|
188
189
|
<!-- jsDelivr -->
|
|
189
190
|
<script src="https://cdn.jsdelivr.net/npm/@rzl-zone/utils-js@latest"></script>
|
|
@@ -194,6 +195,7 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
194
195
|
|
|
195
196
|
> ⚠️ **Note:**
|
|
196
197
|
> When using the library via CDN in the browser:
|
|
198
|
+
>
|
|
197
199
|
> - Always include first the \<script\> tag before your own scripts when using the CDN version.
|
|
198
200
|
> - Some Node.js-specific utilities may **not** be available, e.g.:
|
|
199
201
|
> - Category utils of `tailwind`, `next`, `next/server`.
|
|
@@ -201,18 +203,19 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
201
203
|
> - The global object provided is `RzlUtilsJs`.
|
|
202
204
|
> - The CDN bundle is **~350KB minified**, for production, consider using bundlers or npm packages for smaller size and tree-shaking.
|
|
203
205
|
|
|
204
|
-
|
|
205
|
-
<h3 id="detailed-features--hint-autocomplete-setup">
|
|
206
|
-
<strong>
|
|
207
|
-
Hint: Autocomplete Setup (Step by Step).
|
|
208
|
-
</strong>
|
|
209
|
-
</h3>
|
|
206
|
+
---
|
|
210
207
|
|
|
211
|
-
|
|
208
|
+
<h3 id="detailed-features--hint-autocomplete-setup">
|
|
209
|
+
<strong>
|
|
210
|
+
Hint: Autocomplete Setup (Step by Step).
|
|
211
|
+
</strong>
|
|
212
|
+
</h3>
|
|
212
213
|
|
|
213
|
-
|
|
214
|
+
#### Make TypeScript & VSCode automatically provide autocomplete for `@rzl-zone/utils-js` without needing triple-slash references in every file:
|
|
214
215
|
|
|
215
|
-
|
|
216
|
+
- 1️⃣ **Install @rzl-zone/utils-js.**
|
|
217
|
+
|
|
218
|
+
- Make sure the package is installed:
|
|
216
219
|
|
|
217
220
|
```bash
|
|
218
221
|
npm install @rzl-zone/utils-js@latest
|
|
@@ -222,9 +225,9 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
222
225
|
pnpm add @rzl-zone/utils-js@latest
|
|
223
226
|
```
|
|
224
227
|
|
|
225
|
-
|
|
228
|
+
- 2️⃣ **Create a types folder.**
|
|
226
229
|
|
|
227
|
-
|
|
230
|
+
- Inside your project root, make a folder called `types`:
|
|
228
231
|
|
|
229
232
|
```pgsql
|
|
230
233
|
project-root/
|
|
@@ -235,16 +238,16 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
235
238
|
└─ jsconfig.json
|
|
236
239
|
```
|
|
237
240
|
|
|
238
|
-
|
|
241
|
+
- 3️⃣ **Add the global reference file.**
|
|
239
242
|
|
|
240
|
-
|
|
243
|
+
- Create `types/index.d.ts` with this content:
|
|
241
244
|
|
|
242
245
|
```ts
|
|
243
246
|
/// <reference types="@rzl-zone/utils-js" />
|
|
244
247
|
```
|
|
245
248
|
|
|
246
|
-
|
|
247
|
-
|
|
249
|
+
- This tells TypeScript to include the types from `@rzl-zone/utils-js` globally.
|
|
250
|
+
- You can add more references here if needed, for example:
|
|
248
251
|
|
|
249
252
|
```ts
|
|
250
253
|
/// <reference types="@rzl-zone/utils-js" />
|
|
@@ -252,11 +255,11 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
252
255
|
// eg more references (if needed):
|
|
253
256
|
/// <reference types="node" />
|
|
254
257
|
/// <reference types="react" />
|
|
255
|
-
```
|
|
258
|
+
```
|
|
256
259
|
|
|
257
|
-
|
|
260
|
+
- 4️⃣ **Update tsconfig.json.**
|
|
258
261
|
|
|
259
|
-
|
|
262
|
+
- Make sure not to override "types" (or leave it empty) so TypeScript automatically picks up your types folder:
|
|
260
263
|
|
|
261
264
|
```jsonc
|
|
262
265
|
// tsconfig.json
|
|
@@ -276,12 +279,13 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
276
279
|
// other your config...
|
|
277
280
|
}
|
|
278
281
|
```
|
|
279
|
-
- `typeRoots` tells TS where to look for global type definitions.
|
|
280
|
-
- The `types` folder comes first, so your references override or add to the default `@types` packages
|
|
281
282
|
|
|
282
|
-
|
|
283
|
+
- `typeRoots` tells TS where to look for global type definitions.
|
|
284
|
+
- The `types` folder comes first, so your references override or add to the default `@types` packages.
|
|
283
285
|
|
|
284
|
-
|
|
286
|
+
- 5️⃣ **Update jsconfig.json (for JavaScript projects).**
|
|
287
|
+
|
|
288
|
+
- If you also work with JS, do the same:
|
|
285
289
|
|
|
286
290
|
```jsonc
|
|
287
291
|
// jsconfig.json
|
|
@@ -301,31 +305,11 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
301
305
|
// other your config...
|
|
302
306
|
}
|
|
303
307
|
```
|
|
308
|
+
|
|
304
309
|
>ℹ️ ***Tip:*** *For JS projects, consider adding "checkJs": true for better IntelliSense.*
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
<!-- - <h4 id="detailed-features--assertions">
|
|
309
|
-
Assertions -
|
|
310
|
-
<a href="/docs/detailed-features/assertions.md#docs-sub-main--title">
|
|
311
|
-
Read More Docs.
|
|
312
|
-
</a>
|
|
313
|
-
</h4>
|
|
314
|
-
|
|
315
|
-
- <h4 id="detailed-features--checkers">
|
|
316
|
-
Checkers -
|
|
317
|
-
<a href="/docs/detailed-features/checkers.md#docs-sub-main--title">
|
|
318
|
-
Read More Docs.
|
|
319
|
-
</a>
|
|
320
|
-
</h4>
|
|
321
|
-
|
|
322
|
-
- <h4 id="detailed-features--conversions">
|
|
323
|
-
Conversions -
|
|
324
|
-
<a href="/docs/detailed-features/conversions/index.md#conversions-lists">
|
|
325
|
-
Read More Docs.
|
|
326
|
-
</a>
|
|
327
|
-
</h4>
|
|
328
|
-
-->
|
|
310
|
+
|
|
311
|
+
#### **Now, all types from `@rzl-zone/utils-js` are globally available, and you don’t need `"types": ["@rzl-zone/utils-js"]` in tsconfig.json.**
|
|
312
|
+
|
|
329
313
|
---
|
|
330
314
|
|
|
331
315
|
<h2 id="usage">🔥 <strong>Usage</strong></h2>
|
|
@@ -345,7 +329,7 @@ console.log(isServer());
|
|
|
345
329
|
|
|
346
330
|
<h2 id="sponsor-this-package">❤️ <strong>Sponsor this package</strong></h2>
|
|
347
331
|
|
|
348
|
-
**Help support development:**
|
|
332
|
+
**Help support development:**
|
|
349
333
|
*[👉 **Become a sponsor**](https://github.com/sponsors/rzl-app).*
|
|
350
334
|
|
|
351
335
|
---
|
|
@@ -377,7 +361,7 @@ console.log(isServer());
|
|
|
377
361
|
|
|
378
362
|
<h2 id="license">📜 <strong>License</strong></h2>
|
|
379
363
|
|
|
380
|
-
**The MIT License (MIT).**
|
|
364
|
+
**The MIT License (MIT).**
|
|
381
365
|
*Please see **[License File](LICENSE.md)** for more information.*
|
|
382
366
|
|
|
383
367
|
---
|
|
@@ -2,40 +2,40 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.12.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
12
|
+
var chunkHNSQAVSZ_cjs = require('../chunk-HNSQAVSZ.cjs');
|
|
13
|
+
var chunkYKQEOO7C_cjs = require('../chunk-YKQEOO7C.cjs');
|
|
14
|
+
var chunkRRQHMOPE_cjs = require('../chunk-RRQHMOPE.cjs');
|
|
15
15
|
require('../chunk-UDA26MCU.cjs');
|
|
16
|
-
var
|
|
16
|
+
var chunkGKC3UDMC_cjs = require('../chunk-GKC3UDMC.cjs');
|
|
17
17
|
|
|
18
18
|
Object.defineProperty(exports, "assertIsBigInt", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function () { return
|
|
20
|
+
get: function () { return chunkHNSQAVSZ_cjs.assertIsBigInt; }
|
|
21
21
|
});
|
|
22
22
|
Object.defineProperty(exports, "assertIsNumber", {
|
|
23
23
|
enumerable: true,
|
|
24
|
-
get: function () { return
|
|
24
|
+
get: function () { return chunkHNSQAVSZ_cjs.assertIsNumber; }
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(exports, "assertIsString", {
|
|
27
27
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunkYKQEOO7C_cjs.assertIsString; }
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "assertIsArray", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunkRRQHMOPE_cjs.assertIsArray; }
|
|
33
33
|
});
|
|
34
34
|
Object.defineProperty(exports, "assertIsBoolean", {
|
|
35
35
|
enumerable: true,
|
|
36
|
-
get: function () { return
|
|
36
|
+
get: function () { return chunkGKC3UDMC_cjs.assertIsBoolean; }
|
|
37
37
|
});
|
|
38
38
|
Object.defineProperty(exports, "assertIsPlainObject", {
|
|
39
39
|
enumerable: true,
|
|
40
|
-
get: function () { return
|
|
40
|
+
get: function () { return chunkGKC3UDMC_cjs.assertIsPlainObject; }
|
|
41
41
|
});
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.12.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
10
|
import { Prettify, PickStrict } from '@rzl-zone/ts-types-plus';
|
|
11
|
-
import { G as GetPreciseTypeOptions, I as IsNumberOptions, a as IsPlainObjectResult } from '../isPlainObject-
|
|
11
|
+
import { G as GetPreciseTypeOptions, I as IsNumberOptions, c as ArrayFallback, a as IsPlainObjectResult } from '../isPlainObject-DTJVV2Kf.js';
|
|
12
12
|
|
|
13
13
|
/** -------------------------------------------------------
|
|
14
14
|
* * ***Shape of the object passed to custom error message functions.***
|
|
@@ -50,7 +50,7 @@ type OptionsMessageFunctionAssertIs = {
|
|
|
50
50
|
* - A static string message.
|
|
51
51
|
* - A function receiving `{ currentType, validType }` and returning a string.
|
|
52
52
|
*/
|
|
53
|
-
type OptionsMessageAssertIs =
|
|
53
|
+
type OptionsMessageAssertIs = (({ currentType, validType }: OptionsMessageFunctionAssertIs) => string) | string;
|
|
54
54
|
/** ---------------------------------------------------------------------------
|
|
55
55
|
* * ***Base options for `assertIs*` functions.***
|
|
56
56
|
* ---------------------------------------------------------------------------
|
|
@@ -576,8 +576,8 @@ declare const assertIsNumber: (value: unknown, options?: OptionsAssertIsNumber)
|
|
|
576
576
|
* console.log(result.push(1, 2, 3)); // ➔ Safe to use array methods
|
|
577
577
|
* ```
|
|
578
578
|
*/
|
|
579
|
-
declare function assertIsArray
|
|
580
|
-
declare function assertIsArray<T
|
|
579
|
+
declare function assertIsArray(value: [], options?: OptionsAssertIs): asserts value is [];
|
|
580
|
+
declare function assertIsArray<T>(value: T, options?: OptionsAssertIs): asserts value is ArrayFallback<T>;
|
|
581
581
|
declare function assertIsArray(value: unknown, options?: OptionsAssertIs): asserts value is unknown[];
|
|
582
582
|
|
|
583
583
|
/** -------------------------------------------------------
|
package/dist/assertions/index.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.12.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
export { assertIsBigInt, assertIsNumber } from '../chunk-
|
|
11
|
-
export { assertIsString } from '../chunk-
|
|
12
|
-
export { assertIsArray } from '../chunk-
|
|
10
|
+
export { assertIsBigInt, assertIsNumber } from '../chunk-VAAHZFBF.js';
|
|
11
|
+
export { assertIsString } from '../chunk-BKIJBNIE.js';
|
|
12
|
+
export { assertIsArray } from '../chunk-HSP6IWZK.js';
|
|
13
13
|
import '../chunk-QNKGP5DY.js';
|
|
14
|
-
export { assertIsBoolean, assertIsPlainObject } from '../chunk-
|
|
14
|
+
export { assertIsBoolean, assertIsPlainObject } from '../chunk-CSG4SCL3.js';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.12.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
12
|
var chunkVJDDGRIK_cjs = require('./chunk-VJDDGRIK.cjs');
|
|
13
|
-
var
|
|
14
|
-
var
|
|
13
|
+
var chunkYKQEOO7C_cjs = require('./chunk-YKQEOO7C.cjs');
|
|
14
|
+
var chunkGKC3UDMC_cjs = require('./chunk-GKC3UDMC.cjs');
|
|
15
15
|
|
|
16
16
|
var disableUserInteraction = (className = "on_processing") => {
|
|
17
17
|
if (chunkVJDDGRIK_cjs.isServer()) return;
|
|
18
|
-
|
|
18
|
+
chunkYKQEOO7C_cjs.assertIsString(className, {
|
|
19
19
|
message({ validType, currentType }) {
|
|
20
20
|
return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
21
21
|
}
|
|
@@ -28,7 +28,7 @@ var disableUserInteraction = (className = "on_processing") => {
|
|
|
28
28
|
|
|
29
29
|
var enableUserInteraction = (className = "on_processing") => {
|
|
30
30
|
if (chunkVJDDGRIK_cjs.isServer()) return;
|
|
31
|
-
|
|
31
|
+
chunkYKQEOO7C_cjs.assertIsString(className, {
|
|
32
32
|
message({ validType, currentType }) {
|
|
33
33
|
return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
34
34
|
}
|
|
@@ -49,11 +49,11 @@ var removeElementFocus = () => {
|
|
|
49
49
|
|
|
50
50
|
var scrollToTop = (options) => {
|
|
51
51
|
if (chunkVJDDGRIK_cjs.isServer()) return;
|
|
52
|
-
if (!
|
|
52
|
+
if (!chunkGKC3UDMC_cjs.isPlainObject(options)) {
|
|
53
53
|
options = {};
|
|
54
54
|
}
|
|
55
|
-
const behavior =
|
|
56
|
-
let timeout =
|
|
55
|
+
const behavior = chunkGKC3UDMC_cjs.hasOwnProp(options, "behavior") && chunkGKC3UDMC_cjs.isNonEmptyString(options.behavior) && ["auto", "instant", "smooth"].includes(options.behavior) ? options.behavior : "smooth";
|
|
56
|
+
let timeout = chunkGKC3UDMC_cjs.hasOwnProp(options, "timeout") && chunkGKC3UDMC_cjs.isNumber(options.timeout) && options.timeout >= 1 ? options.timeout : 1;
|
|
57
57
|
timeout = timeout > 2147483647 ? 2147483647 : timeout;
|
|
58
58
|
setTimeout(() => window.scrollTo({ top: 0, left: 0, behavior }), timeout);
|
|
59
59
|
};
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.12.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
import { isValidDomain } from './chunk-
|
|
11
|
-
import { removeSpaces } from './chunk-
|
|
12
|
-
import { isEmptyString } from './chunk-
|
|
13
|
-
import { safeStableStringify } from './chunk-
|
|
14
|
-
import { assertIsPlainObject, isNonEmptyString, getPreciseType, assertIsBoolean, isUndefined, isSet, isArray, isNil, isString, isNull, isError, hasOwnProp, isBoolean, isFunction } from './chunk-
|
|
10
|
+
import { isValidDomain } from './chunk-BXW7YXB7.js';
|
|
11
|
+
import { removeSpaces } from './chunk-HHYWB7VZ.js';
|
|
12
|
+
import { isEmptyString } from './chunk-TCDOWZQE.js';
|
|
13
|
+
import { safeStableStringify } from './chunk-6VUXD3CF.js';
|
|
14
|
+
import { assertIsPlainObject, isNonEmptyString, getPreciseType, assertIsBoolean, isUndefined, isSet, isArray, isNil, isString, isNull, isError, hasOwnProp, isBoolean, isFunction } from './chunk-CSG4SCL3.js';
|
|
15
15
|
|
|
16
16
|
var NormalizePathnameError = class _NormalizePathnameError extends Error {
|
|
17
17
|
/** * ***The original error that triggered this normalization failure.***
|