@rzl-zone/utils-js 3.7.1 → 3.9.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 +28 -1
- package/dist/assertions/index.cjs +11 -11
- package/dist/assertions/index.d.ts +169 -58
- package/dist/assertions/index.js +5 -5
- package/dist/{chunk-EK7FSI7F.cjs → chunk-2XGQQZ6A.cjs} +3 -3
- package/dist/{chunk-YS27V6LS.js → chunk-3LE6NX57.js} +5 -176
- package/dist/{chunk-PZQC3FZY.js → chunk-44X74C26.js} +4 -4
- package/dist/{chunk-4ACKNPL5.js → chunk-5KDVIEVO.js} +2 -2
- package/dist/{chunk-JY4HLZ4W.js → chunk-5O66AUEC.js} +2 -2
- package/dist/chunk-5Y6JL47L.js +302 -0
- package/dist/{chunk-KIYALQQF.cjs → chunk-62FS7WMB.cjs} +35 -35
- package/dist/{chunk-VJVCXEH7.cjs → chunk-6AMDHVS2.cjs} +9 -181
- package/dist/{chunk-6PKW4WCT.js → chunk-6WVOUVWD.js} +27 -15
- package/dist/{chunk-BYUT376O.cjs → chunk-76ATVDCR.cjs} +3 -3
- package/dist/{chunk-F3WBQKRI.cjs → chunk-7C7TQC5J.cjs} +29 -7
- package/dist/{chunk-QUITZ3GP.js → chunk-7EIFPHV3.js} +32 -16
- package/dist/{chunk-6RFNZ2ZZ.cjs → chunk-7NXFGJJE.cjs} +14 -14
- package/dist/{chunk-TFDXRT6D.cjs → chunk-ALRISPTL.cjs} +3 -3
- package/dist/chunk-BAV5T2E3.cjs +1 -1
- package/dist/{chunk-4ZOXSUXB.js → chunk-C7GC2PFX.js} +3 -3
- package/dist/chunk-DVMHRLKP.cjs +1 -1
- package/dist/{chunk-XFTUHS4Y.js → chunk-DXPM4NOU.js} +10 -8
- package/dist/{chunk-DPLL67OT.js → chunk-EJV5AF4L.js} +2 -2
- package/dist/{chunk-NREACG6M.cjs → chunk-FWWPEL7J.cjs} +3 -3
- package/dist/{chunk-LEX4TQW2.js → chunk-GHU356XQ.js} +4 -6
- package/dist/chunk-GKDSBOYE.js +209 -0
- package/dist/{chunk-YC7AK3KX.cjs → chunk-H44QVAZL.cjs} +31 -31
- package/dist/{chunk-AKKM6MOX.cjs → chunk-I33PB44Q.cjs} +15 -15
- package/dist/{chunk-LIU4S3JA.cjs → chunk-IX6PF5ZP.cjs} +4 -4
- package/dist/{chunk-3KTD3QDI.js → chunk-J4TT33ZX.js} +29 -7
- package/dist/{chunk-SZJ7OI4S.js → chunk-J6VLFVIL.js} +3 -3
- package/dist/{chunk-KTQLDIIT.cjs → chunk-JI57K7D4.cjs} +173 -163
- package/dist/{chunk-OFBFGFVH.js → chunk-JYOCB6OV.js} +2 -2
- package/dist/chunk-KHO2SBNA.cjs +1 -1
- package/dist/{chunk-66WLOZOD.cjs → chunk-KUVRZ2JW.cjs} +53 -51
- package/dist/chunk-L5RDAVVH.js +1 -1
- package/dist/{chunk-VCVND6CH.js → chunk-M5QB2GM5.js} +2 -2
- package/dist/{chunk-3LEWQV3R.js → chunk-MBFVTGYS.js} +8 -8
- package/dist/{chunk-UKAUXY2U.cjs → chunk-MMRHKYT6.cjs} +12 -12
- package/dist/{chunk-U5VR4TJN.js → chunk-MS2KSKD7.js} +9 -9
- package/dist/{chunk-7ZNEUWYP.js → chunk-MZ3T6L7Z.js} +2 -2
- package/dist/{chunk-ATLFMKAF.cjs → chunk-NAOVH4OH.cjs} +7 -7
- package/dist/chunk-NJ24M6ZH.cjs +308 -0
- package/dist/chunk-OCTHWEZK.cjs +249 -0
- package/dist/chunk-ONZFBJVW.js +1 -1
- package/dist/{chunk-FI76UZRF.js → chunk-OSSFLQDD.js} +3 -4
- package/dist/{chunk-7WBMA2VE.cjs → chunk-OYFUBKEG.cjs} +4 -5
- package/dist/{chunk-B4SDEBN7.cjs → chunk-PWKOFPAH.cjs} +3 -3
- package/dist/{chunk-2CQI36UD.cjs → chunk-QGTFQ7RO.cjs} +8 -6
- package/dist/chunk-QNKGP5DY.js +1 -1
- package/dist/chunk-QXTJVDWE.js +676 -0
- package/dist/{chunk-B6UIKBHR.cjs → chunk-QZI5PVCI.cjs} +4 -4
- package/dist/{chunk-WNO3EPYT.js → chunk-R2DR7SPJ.js} +102 -26
- package/dist/{chunk-TDYGYHSH.js → chunk-SN5HAK3Y.js} +4 -4
- package/dist/{chunk-D53CE4BT.js → chunk-SRWL4YCP.js} +11 -8
- package/dist/{chunk-7QQV66RX.cjs → chunk-TJ5OY6MC.cjs} +10 -10
- package/dist/{chunk-6WMB5AJR.js → chunk-TXOVQZPU.js} +3 -4
- package/dist/chunk-UDA26MCU.cjs +1 -1
- package/dist/{chunk-R3PBF6F7.cjs → chunk-UFYMRRJH.cjs} +73 -61
- package/dist/{chunk-5NN4ZDE2.cjs → chunk-UV5BKAYW.cjs} +6 -8
- package/dist/{chunk-GAJBF6DR.js → chunk-UXT4XSUK.js} +2 -2
- package/dist/{chunk-TDPYR5JY.js → chunk-VBSLIIDB.js} +24 -14
- package/dist/chunk-VCYXNIZ2.cjs +678 -0
- package/dist/chunk-VJDDGRIK.cjs +1 -1
- package/dist/{chunk-VNADVWSJ.js → chunk-WB3FT62A.js} +6 -4
- package/dist/{chunk-K63WO3XA.cjs → chunk-WKM6UVMG.cjs} +4 -5
- package/dist/{chunk-OS5OT5JA.cjs → chunk-WLEZ2KSG.cjs} +142 -126
- package/dist/{chunk-ZN53RM3R.js → chunk-WRGN6UBK.js} +2 -2
- package/dist/chunk-WVSPXFTY.js +1 -1
- package/dist/{chunk-2VO2CBTU.js → chunk-X6ULJZ3X.js} +2 -2
- package/dist/{chunk-CKUEZF4R.cjs → chunk-XYWC4EQ3.cjs} +71 -71
- package/dist/{chunk-A3YI6Y2P.js → chunk-YHFRCVTN.js} +3 -3
- package/dist/{chunk-RMJC3B5P.cjs → chunk-YQHJB7KR.cjs} +30 -27
- package/dist/{chunk-YGB2BQPB.cjs → chunk-YVRUY4EW.cjs} +8 -8
- package/dist/chunk-YWHHVDT4.js +1 -1
- package/dist/chunk-ZTHJQJ5F.cjs +211 -0
- package/dist/conversions/index.cjs +34 -34
- package/dist/conversions/index.d.ts +10 -12
- package/dist/conversions/index.js +15 -15
- package/dist/events/index.cjs +8 -8
- package/dist/events/index.d.ts +9 -9
- package/dist/events/index.js +4 -4
- package/dist/formatters/index.cjs +19 -19
- package/dist/formatters/index.d.ts +19 -24
- package/dist/formatters/index.js +9 -9
- package/dist/generators/index.cjs +12 -8
- package/dist/generators/index.d.ts +155 -26
- package/dist/generators/index.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/{isPlainObject-FWmcJF6k.d.ts → isPlainObject-BTPjv6zB.d.ts} +2 -2
- package/dist/next/index.cjs +39 -36
- package/dist/next/index.d.ts +11 -11
- package/dist/next/index.js +12 -9
- package/dist/next/server/index.cjs +4 -4
- package/dist/next/server/index.d.ts +4 -4
- package/dist/next/server/index.js +2 -2
- package/dist/operations/index.cjs +11 -11
- package/dist/operations/index.d.ts +8 -9
- package/dist/operations/index.js +8 -8
- package/dist/parsers/index.cjs +6 -4
- package/dist/parsers/index.d.ts +224 -32
- package/dist/parsers/index.js +5 -3
- package/dist/predicates/index.cjs +77 -76
- package/dist/predicates/index.d.ts +15 -28
- package/dist/predicates/index.js +14 -13
- package/dist/promises/index.cjs +6 -6
- package/dist/promises/index.d.ts +5 -7
- 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 +18 -18
- package/dist/tailwind/index.js +5 -5
- package/dist/urls/index.cjs +23 -21
- package/dist/urls/index.d.ts +188 -121
- package/dist/urls/index.js +16 -14
- package/package.json +1 -1
- package/dist/chunk-ABA2ZSBQ.js +0 -152
- package/dist/chunk-BG3AS5BU.cjs +0 -173
- package/dist/chunk-K3SONK25.cjs +0 -157
- package/dist/chunk-KPCDDYTZ.js +0 -417
- package/dist/chunk-QAPYHLHC.cjs +0 -419
|
@@ -2,61 +2,61 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.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
|
-
require('../chunk-
|
|
14
|
-
require('../chunk-
|
|
15
|
-
require('../chunk-
|
|
12
|
+
var chunkWLEZ2KSG_cjs = require('../chunk-WLEZ2KSG.cjs');
|
|
13
|
+
require('../chunk-QZI5PVCI.cjs');
|
|
14
|
+
require('../chunk-2XGQQZ6A.cjs');
|
|
15
|
+
require('../chunk-PWKOFPAH.cjs');
|
|
16
16
|
require('../chunk-DVMHRLKP.cjs');
|
|
17
|
-
require('../chunk-
|
|
18
|
-
require('../chunk-
|
|
19
|
-
require('../chunk-
|
|
17
|
+
require('../chunk-FWWPEL7J.cjs');
|
|
18
|
+
require('../chunk-WKM6UVMG.cjs');
|
|
19
|
+
require('../chunk-H44QVAZL.cjs');
|
|
20
20
|
require('../chunk-UDA26MCU.cjs');
|
|
21
|
-
require('../chunk-
|
|
21
|
+
require('../chunk-7C7TQC5J.cjs');
|
|
22
22
|
|
|
23
23
|
Object.defineProperty(exports, "censorEmail", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkWLEZ2KSG_cjs.censorEmail; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "chunkString", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkWLEZ2KSG_cjs.chunkString; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "formatCurrency", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkWLEZ2KSG_cjs.formatCurrency; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "formatDateFns", {
|
|
36
36
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkWLEZ2KSG_cjs.formatDateFns; }
|
|
38
38
|
});
|
|
39
39
|
Object.defineProperty(exports, "formatDateIntl", {
|
|
40
40
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkWLEZ2KSG_cjs.formatDateIntl; }
|
|
42
42
|
});
|
|
43
43
|
Object.defineProperty(exports, "formatDateTime", {
|
|
44
44
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkWLEZ2KSG_cjs.formatDateTime; }
|
|
46
46
|
});
|
|
47
47
|
Object.defineProperty(exports, "formatNumber", {
|
|
48
48
|
enumerable: true,
|
|
49
|
-
get: function () { return
|
|
49
|
+
get: function () { return chunkWLEZ2KSG_cjs.formatNumber; }
|
|
50
50
|
});
|
|
51
51
|
Object.defineProperty(exports, "formatPhoneNumber", {
|
|
52
52
|
enumerable: true,
|
|
53
|
-
get: function () { return
|
|
53
|
+
get: function () { return chunkWLEZ2KSG_cjs.formatPhoneNumber; }
|
|
54
54
|
});
|
|
55
55
|
Object.defineProperty(exports, "getGMTOffset", {
|
|
56
56
|
enumerable: true,
|
|
57
|
-
get: function () { return
|
|
57
|
+
get: function () { return chunkWLEZ2KSG_cjs.getGMTOffset; }
|
|
58
58
|
});
|
|
59
59
|
Object.defineProperty(exports, "truncateString", {
|
|
60
60
|
enumerable: true,
|
|
61
|
-
get: function () { return
|
|
61
|
+
get: function () { return chunkWLEZ2KSG_cjs.truncateString; }
|
|
62
62
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
@@ -148,7 +148,7 @@ indianFormat?:boolean;};
|
|
|
148
148
|
* - `"CHF 12'345.60"` ***(Swiss)***.
|
|
149
149
|
* - `"1,23,456.78"` ***(Indian)***.
|
|
150
150
|
* - Auto extracts numeric value with smart multi-locale parsing
|
|
151
|
-
* via
|
|
151
|
+
* via ***`parseCurrencyString` utility function***.
|
|
152
152
|
* - Strong type checks & clear errors for misconfigured options.
|
|
153
153
|
* - **Handles:**
|
|
154
154
|
* - Thousands separators: `.`, `,`, `'`, ` `.
|
|
@@ -228,8 +228,7 @@ indianFormat?:boolean;};
|
|
|
228
228
|
* - `"Rp 15.000,10.-"`.
|
|
229
229
|
* - `"15'000.10 USD"`.
|
|
230
230
|
* - `"12,34,567.89"`.
|
|
231
|
-
* @throws {TypeError}
|
|
232
|
-
* ***Will throw TypeError If:***
|
|
231
|
+
* @throws **{@link TypeError | `TypeError`}** ***If:***
|
|
233
232
|
* - The `value` is not string or number.
|
|
234
233
|
* - Cannot parse to valid number.
|
|
235
234
|
* - Options have invalid types.
|
|
@@ -379,8 +378,7 @@ declare const formatCurrency:(value:string|number,options?:FormatCurrencyOptions
|
|
|
379
378
|
* @param {string} [separator=","] - The thousands separator to use, examples: `","` ***(default)***, `"."`, `" "`, etc.
|
|
380
379
|
* @returns {string} The formatted string with thousands separators and
|
|
381
380
|
* appropriate decimal separator.
|
|
382
|
-
* @throws {TypeError}
|
|
383
|
-
* or `separator` is not a string.
|
|
381
|
+
* @throws **{@link TypeError | `TypeError`}** if `value` is not a string or number, or `separator` is not a string.
|
|
384
382
|
* @example
|
|
385
383
|
* formatNumber(1000000);
|
|
386
384
|
* // ➔ "1,000,000"
|
|
@@ -1118,8 +1116,8 @@ takeNumberOnly:true;}>;
|
|
|
1118
1116
|
* - **E.164 compliance:**
|
|
1119
1117
|
* - Optional leading `+` is recommended but **not required**.
|
|
1120
1118
|
* - If Without leading `+`, you must passing `defaultCountry`.
|
|
1121
|
-
* @throws {TypeError}
|
|
1122
|
-
* @throws {TypeError}
|
|
1119
|
+
* @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.
|
|
1120
|
+
* @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.
|
|
1123
1121
|
* @param {ValueFormatPhoneNumber} value
|
|
1124
1122
|
* ***Phone number to format, accepts:***
|
|
1125
1123
|
* - `string` (recommended to preserve leading zeros).
|
|
@@ -1243,8 +1241,8 @@ declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatP
|
|
|
1243
1241
|
* - **E.164 compliance:**
|
|
1244
1242
|
* - Optional leading `+` is recommended but **not required**.
|
|
1245
1243
|
* - If Without leading `+`, you must passing `defaultCountry`.
|
|
1246
|
-
* @throws {TypeError}
|
|
1247
|
-
* @throws {TypeError}
|
|
1244
|
+
* @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.
|
|
1245
|
+
* @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.
|
|
1248
1246
|
* @param {ValueFormatPhoneNumber} value
|
|
1249
1247
|
* Phone number to format. Accepts:
|
|
1250
1248
|
* - `string` (recommended to preserve leading zeros)
|
|
@@ -1299,8 +1297,8 @@ declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatP
|
|
|
1299
1297
|
* - **E.164 compliance:**
|
|
1300
1298
|
* - Optional leading `+` is recommended but **not required**.
|
|
1301
1299
|
* - If Without leading `+`, you must passing `defaultCountry`.
|
|
1302
|
-
* @throws {TypeError}
|
|
1303
|
-
* @throws {TypeError}
|
|
1300
|
+
* @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.
|
|
1301
|
+
* @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.
|
|
1304
1302
|
* @param {ValueFormatPhoneNumber} value
|
|
1305
1303
|
* Phone number to format. Accepts:
|
|
1306
1304
|
* - `string` (recommended to preserve leading zeros).
|
|
@@ -1359,8 +1357,8 @@ declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatP
|
|
|
1359
1357
|
* - **E.164 compliance:**
|
|
1360
1358
|
* - Optional leading `+` is recommended but **not required**.
|
|
1361
1359
|
* - If Without leading `+`, you must passing `defaultCountry`.
|
|
1362
|
-
* @throws {TypeError}
|
|
1363
|
-
* @throws {TypeError}
|
|
1360
|
+
* @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.
|
|
1361
|
+
* @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.
|
|
1364
1362
|
* @param {ValueFormatPhoneNumber} value
|
|
1365
1363
|
* Phone number to format. Accepts:
|
|
1366
1364
|
* - `string` (recommended to preserve leading zeros).
|
|
@@ -1475,8 +1473,8 @@ declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatP
|
|
|
1475
1473
|
* - **E.164 compliance:**
|
|
1476
1474
|
* - Optional leading `+` is recommended but **not required**.
|
|
1477
1475
|
* - If Without leading `+`, you must passing `defaultCountry`.
|
|
1478
|
-
* @throws {TypeError}
|
|
1479
|
-
* @throws {TypeError}
|
|
1476
|
+
* @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.
|
|
1477
|
+
* @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.
|
|
1480
1478
|
* @param {ValueFormatPhoneNumber} value
|
|
1481
1479
|
* Phone number to format. Accepts:
|
|
1482
1480
|
* - `string` (recommended to preserve leading zeros)
|
|
@@ -1554,8 +1552,8 @@ declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatP
|
|
|
1554
1552
|
* - **E.164 compliance:**
|
|
1555
1553
|
* - Optional leading `+` is recommended but **not required**.
|
|
1556
1554
|
* - If Without leading `+`, you must passing `defaultCountry`.
|
|
1557
|
-
* @throws {TypeError}
|
|
1558
|
-
* @throws {TypeError}
|
|
1555
|
+
* @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.
|
|
1556
|
+
* @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.
|
|
1559
1557
|
* @param {ValueFormatPhoneNumber} value
|
|
1560
1558
|
* Phone number to format. Accepts:
|
|
1561
1559
|
* - `string` (recommended to preserve leading zeros).
|
|
@@ -1699,7 +1697,7 @@ mode?:"random"|"fixed";};
|
|
|
1699
1697
|
* @param {string | null | undefined} email - The email address to censor.
|
|
1700
1698
|
* @param {CensorEmailOptions} [options={}] - Options object for mode.
|
|
1701
1699
|
* @returns {string} The censored email, or an empty string if input is invalid.
|
|
1702
|
-
* @throws {TypeError}
|
|
1700
|
+
* @throws **{@link TypeError | `TypeError`}** if `options` is not a plain object or `mode` is invalid.
|
|
1703
1701
|
* @example
|
|
1704
1702
|
* // Fixed mode (default, deterministic)
|
|
1705
1703
|
* censorEmail("john.doe@gmail.com");
|
|
@@ -1821,11 +1819,8 @@ trim?:boolean;};
|
|
|
1821
1819
|
* - `length` (number, default 10): Maximum length of the truncated string.
|
|
1822
1820
|
* - `ending` (string, default `"..."`): String to append if truncation occurs.
|
|
1823
1821
|
* - `trim` (boolean, default `true`): Whether to trim the input before truncation.
|
|
1824
|
-
* @returns {string} The truncated string with optional trimming and ending.
|
|
1825
|
-
*
|
|
1826
|
-
* @throws {TypeError} If `options.length` is not a finite number,
|
|
1827
|
-
* or if `options.ending` is not a string,
|
|
1828
|
-
* or if `options.trim` is not a boolean.
|
|
1822
|
+
* @returns {string} The truncated string with optional trimming and ending, returns `""` if input is empty or length < 1.
|
|
1823
|
+
* @throws **{@link TypeError | `TypeError`}** if `options.length` is not a finite number, or if `options.ending` is not a string, or if `options.trim` is not a boolean.
|
|
1829
1824
|
* @example
|
|
1830
1825
|
* truncateString("hello world", { length: 5 });
|
|
1831
1826
|
* // ➔ "hello..."
|
package/dist/formatters/index.js
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
export { censorEmail, chunkString, formatCurrency, formatDateFns, formatDateIntl, formatDateTime, formatNumber, formatPhoneNumber, getGMTOffset, truncateString } from '../chunk-
|
|
11
|
-
import '../chunk-
|
|
12
|
-
import '../chunk-
|
|
13
|
-
import '../chunk-
|
|
10
|
+
export { censorEmail, chunkString, formatCurrency, formatDateFns, formatDateIntl, formatDateTime, formatNumber, formatPhoneNumber, getGMTOffset, truncateString } from '../chunk-7EIFPHV3.js';
|
|
11
|
+
import '../chunk-JYOCB6OV.js';
|
|
12
|
+
import '../chunk-EJV5AF4L.js';
|
|
13
|
+
import '../chunk-MZ3T6L7Z.js';
|
|
14
14
|
import '../chunk-WVSPXFTY.js';
|
|
15
|
-
import '../chunk-
|
|
16
|
-
import '../chunk-
|
|
17
|
-
import '../chunk-
|
|
15
|
+
import '../chunk-5O66AUEC.js';
|
|
16
|
+
import '../chunk-OSSFLQDD.js';
|
|
17
|
+
import '../chunk-X6ULJZ3X.js';
|
|
18
18
|
import '../chunk-QNKGP5DY.js';
|
|
19
|
-
import '../chunk-
|
|
19
|
+
import '../chunk-J4TT33ZX.js';
|
|
@@ -2,35 +2,39 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.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
|
|
12
|
+
var chunkNJ24M6ZH_cjs = require('../chunk-NJ24M6ZH.cjs');
|
|
13
13
|
require('../chunk-DVMHRLKP.cjs');
|
|
14
14
|
var chunkBAV5T2E3_cjs = require('../chunk-BAV5T2E3.cjs');
|
|
15
|
-
require('../chunk-
|
|
15
|
+
require('../chunk-H44QVAZL.cjs');
|
|
16
16
|
require('../chunk-UDA26MCU.cjs');
|
|
17
|
-
require('../chunk-
|
|
17
|
+
require('../chunk-7C7TQC5J.cjs');
|
|
18
18
|
|
|
19
19
|
Object.defineProperty(exports, "getRandomItem", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkNJ24M6ZH_cjs.getRandomItem; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "randomInt", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkNJ24M6ZH_cjs.randomInt; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "randomIntByLength", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkNJ24M6ZH_cjs.randomIntByLength; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "randomStr", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkNJ24M6ZH_cjs.randomStr; }
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "randomUUID", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () { return chunkNJ24M6ZH_cjs.randomUUID; }
|
|
34
38
|
});
|
|
35
39
|
Object.defineProperty(exports, "noop", {
|
|
36
40
|
enumerable: true,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
@@ -39,7 +39,7 @@ import{NullToUndefined,FixNeverArrayRecursive,IfNonEmptyArray,Extends}from'@rzl-
|
|
|
39
39
|
* const tuple = [1, "two", true] as const;
|
|
40
40
|
* getRandomItem(tuple); // 1 | "two" | true
|
|
41
41
|
*/
|
|
42
|
-
declare function getRandomItem(array:undefined):undefined;declare function getRandomItem(array:
|
|
42
|
+
declare function getRandomItem(array:undefined):undefined;declare function getRandomItem(array:[]):undefined;declare function getRandomItem<T extends readonly unknown[]>(array:T):T extends never[][]?undefined:number extends T["length"]?NullToUndefined<FixNeverArrayRecursive<T[number]>>:IfNonEmptyArray<T,NullToUndefined<FixNeverArrayRecursive<T[number]>>,undefined>;declare function getRandomItem<T extends readonly unknown[]|undefined|null>(array:T):T extends readonly unknown[]?NullToUndefined<FixNeverArrayRecursive<T[number]>>|undefined:undefined;declare function getRandomItem<T>(array:T):unknown extends T?unknown:Extends<any[]|readonly any[],T>extends true?Extract<T,unknown[]|readonly unknown[]>[number]|undefined:Extends<any[],T>extends true?Extract<T,unknown[]|readonly unknown[]>[number]|undefined:Extends<readonly any[],T>extends true?Extract<T,unknown[]|readonly unknown[]>[number]|undefined:undefined;
|
|
43
43
|
/** -----------------------------------------------------------------------
|
|
44
44
|
* * ***Utility: `randomInt`.***
|
|
45
45
|
* ------------------------------------------------------------------------
|
|
@@ -50,14 +50,14 @@ declare function getRandomItem(array:undefined):undefined;declare function getRa
|
|
|
50
50
|
* @param {number} min - The minimum value (inclusive), must be an integer.
|
|
51
51
|
* @param {number} max - The maximum value (inclusive), must be an integer.
|
|
52
52
|
* @returns {number} A random integer N where `min ≤ N ≤ max`.
|
|
53
|
-
* @throws {TypeError}
|
|
54
|
-
* - `min` or `max` is not an integer
|
|
53
|
+
* @throws **{@link TypeError | `TypeError`}** if:
|
|
54
|
+
* - `min` or `max` is not an integer, or value is `Number.MIN_VALUE`.
|
|
55
55
|
* - `min` is greater than `max`.
|
|
56
56
|
* @example
|
|
57
|
-
* randomInt(1, 10); // ➔ returns 1 to 10
|
|
58
|
-
* randomInt(50, 100); // ➔ returns 50 to 100
|
|
59
|
-
* randomInt(5, 5); // ➔ always returns 5
|
|
60
|
-
* randomInt(-5, 3); // ➔ always returns ≥ 1, since min is adjusted
|
|
57
|
+
* randomInt(1, 10); // ➔ returns 1 up-to 10 (random)
|
|
58
|
+
* randomInt(50, 100); // ➔ returns 50 up-to 100 (random)
|
|
59
|
+
* randomInt(5, 5); // ➔ always returns 5 (exact)
|
|
60
|
+
* randomInt(-5, 3); // ➔ always returns ≥ 1, since min is adjusted (exact)
|
|
61
61
|
* randomInt(1, Number.MAX_SAFE_INTEGER + 10000);
|
|
62
62
|
* // ➔ still safely capped at MAX_SAFE_INTEGER
|
|
63
63
|
* randomInt(Number.MIN_VALUE, 3);
|
|
@@ -96,14 +96,14 @@ avoidZero?:boolean;};
|
|
|
96
96
|
* @param {OptionsRandomIntByLength["maxLength"]} [options.maxLength=16] - Maximum number of digits (must be ≤ `16`).
|
|
97
97
|
* @param {OptionsRandomIntByLength["avoidZero"]} [options.avoidZero=false] - If true, will ensure the result is never zero.
|
|
98
98
|
* @returns {number} A randomly generated integer within the specified constraints.
|
|
99
|
-
* @throws {TypeError}
|
|
99
|
+
* @throws **{@link TypeError | `TypeError`}** if parameters are invalid, such as:
|
|
100
100
|
* - `minLength` < `1`
|
|
101
101
|
* - `maxLength` > `16`
|
|
102
102
|
* - `minLength` > `maxLength`
|
|
103
103
|
* - non-integer values for `minLength` or `maxLength`
|
|
104
104
|
* @example
|
|
105
105
|
* randomIntByLength({ minLength: 3, maxLength: 5 });
|
|
106
|
-
* // ➔
|
|
106
|
+
* // ➔ `4829` (random), `192` (random) or `71492` (random).
|
|
107
107
|
* randomIntByLength({ minLength: 4, maxLength: 4 });
|
|
108
108
|
* // ➔ `5930` (exact 4 digits)
|
|
109
109
|
* randomIntByLength({ avoidZero: true });
|
|
@@ -155,7 +155,7 @@ type?:"string"|"number";};
|
|
|
155
155
|
* @param {OptionsRandomStr["replaceGenInt"]} [options.replaceGenInt] - A custom character set to use when `type` is `"number"`.
|
|
156
156
|
* @param {OptionsRandomStr["addChar"]} [options.addChar] - Additional characters to always include in the character set.
|
|
157
157
|
* @returns {string} The randomly generated string or numeric string of the desired length.
|
|
158
|
-
* @throws {TypeError}
|
|
158
|
+
* @throws **{@link TypeError | `TypeError`}** if provided options are invalid (such as minLength > maxLength, invalid type, or empty character set).
|
|
159
159
|
* @example
|
|
160
160
|
* randomStr();
|
|
161
161
|
* // ➔ Generates a 40-character random alphanumeric string
|
|
@@ -169,25 +169,154 @@ type?:"string"|"number";};
|
|
|
169
169
|
* // ➔ Guaranteed to include !@# in the set
|
|
170
170
|
*/
|
|
171
171
|
declare const randomStr:(options?:OptionsRandomStr)=>string;
|
|
172
|
-
/**
|
|
172
|
+
/**
|
|
173
|
+
* Configuration options for `randomUUID()`.
|
|
174
|
+
*/
|
|
175
|
+
type OptionsRandomUUID={
|
|
176
|
+
/**
|
|
177
|
+
* Specifies which UUID version to generate.
|
|
178
|
+
*
|
|
179
|
+
* - `"v4"` — Fully random UUID (RFC 4122). No timestamp, no ordering guarantees.
|
|
180
|
+
* - `"v7"` — Time-ordered UUID (RFC 9562). Uses Unix timestamp + randomness.
|
|
181
|
+
*
|
|
182
|
+
* @default "v4"
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* // Random v4 UUID
|
|
186
|
+
* randomUUID({ version: "v4" }); // ➔ "3ec0de5a-b8a9-4ffb-a62a-fcc76851e9c2"
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* // Time-ordered v7 UUID
|
|
190
|
+
* randomUUID({ version: "v7" }); // ➔ "0199f3f6-3c5e-744b-affa-46b2cfd496f8"
|
|
191
|
+
*/
|
|
192
|
+
version?:"v4"|"v7";
|
|
193
|
+
/**
|
|
194
|
+
* Enables monotonic sequencing for UUID v7.
|
|
195
|
+
*
|
|
196
|
+
* - Guarantees that multiple UUIDs generated within the same millisecond
|
|
197
|
+
* are strictly non-decreasing (lexicographically and timestamp-wise).
|
|
198
|
+
* - Only valid when `version === "v7"`. Using with `v4` will throw a `TypeError`.
|
|
199
|
+
* - Useful for database inserts, logs, or any system where order matters.
|
|
200
|
+
*
|
|
201
|
+
* @default false
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* // Monotonic v7 UUIDs
|
|
205
|
+
* const a = randomUUID({ version: "v7", monotonic: true });
|
|
206
|
+
* const b = randomUUID({ version: "v7", monotonic: true });
|
|
207
|
+
* console.log(a < b); // true, guaranteed
|
|
208
|
+
*/
|
|
209
|
+
monotonic?:boolean;};
|
|
210
|
+
/** -----------------------------------------------------------------------
|
|
211
|
+
* * ***Utility: `randomUUID`.***
|
|
212
|
+
* ------------------------------------------------------------------------
|
|
213
|
+
* **Generates a UUID string according to the specified version and options.**
|
|
214
|
+
*
|
|
215
|
+
* - **Supported versions**:
|
|
216
|
+
* - **`"v4"` (default)** ➔ Fully random UUID, RFC 4122 compliant.
|
|
217
|
+
* - Uses `crypto.randomUUID()` if available.
|
|
218
|
+
* - Falls back to `crypto.getRandomValues()` or `Math.random()`
|
|
219
|
+
* if needed.
|
|
220
|
+
* - **`"v7"`** ➔ Time-ordered UUID, RFC 9562 compliant.
|
|
221
|
+
* - Timestamp (Unix ms, 48 bits) + 80 bits randomness.
|
|
222
|
+
* - Good for database indexing / sorting.
|
|
223
|
+
* - **`"v7"` + `monotonic: true`** ➔ Ensures strictly non-decreasing UUIDs
|
|
224
|
+
* for multiple calls in the same millisecond (per-process).
|
|
225
|
+
*
|
|
226
|
+
* - **Behavior / Safety Notes**:
|
|
227
|
+
* - **v4**: Fully random; probability of duplicates is astronomically low.
|
|
228
|
+
* - **v7**: Time-ordered; collisions extremely unlikely unless same ms + random repeat.
|
|
229
|
+
* - **Monotonic v7**: Guaranteed ordering per-process if multiple UUIDs are generated
|
|
230
|
+
* in the same millisecond.
|
|
231
|
+
* - **All versions**: Fallback safely if `crypto` APIs are unavailable.
|
|
232
|
+
*
|
|
233
|
+
* @param {object} [options] - Optional settings object.
|
|
234
|
+
* @param {"v4" | "v7"} [options.version="v4"] - UUID version to generate.
|
|
235
|
+
* @param {boolean} [options.monotonic=false] - For v7 only: generate monotonic UUIDs
|
|
236
|
+
* to maintain strict lexicographic order
|
|
237
|
+
* when generating multiple UUIDs within the same ms.
|
|
238
|
+
*
|
|
239
|
+
* @returns {string} A 36-character UUID string compliant with the selected version.
|
|
240
|
+
*
|
|
241
|
+
* @throws **{@link TypeError | `TypeError`}** if:
|
|
242
|
+
* - `options` is not a plain object.
|
|
243
|
+
* - `options.version` is provided but not a string.
|
|
244
|
+
* - `options.monotonic` is provided but not a boolean.
|
|
245
|
+
* - `monotonic: true` is used with `version` other than `"v7"`.
|
|
246
|
+
* @throws **{@link RangeError | `RangeError`}** if `options.version` is provided but not `"v4"` or `"v7"`.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* // Default (v4)
|
|
250
|
+
* const id = randomUUID();
|
|
251
|
+
* // ➔ "3b12f1df-5232-4804-897e-917bf397618a"
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* // Explicit v4
|
|
255
|
+
* const id4 = randomUUID({ version: "v4" });
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* // Time-ordered v7
|
|
259
|
+
* const id7 = randomUUID({ version: "v7" });
|
|
260
|
+
* // ➔ "018f48d2-84c1-7ccd-b5a3-2f9463b3a889"
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* // Monotonic v7
|
|
264
|
+
* const a = randomUUID({ version: "v7", monotonic: true });
|
|
265
|
+
* const b = randomUUID({ version: "v7", monotonic: true });
|
|
266
|
+
* // a < b lexicographically (guaranteed)
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* // Throws TypeError
|
|
270
|
+
* randomUUID("v4" as any); // options must be object
|
|
271
|
+
* randomUUID({ version: 123 as any }); // version must be string
|
|
272
|
+
* randomUUID({ version: "v4", monotonic: true } as any); // monotonic only for v7
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* // Throws RangeError
|
|
276
|
+
* randomUUID({ version: "v1" as any }); // unsupported version
|
|
277
|
+
*/
|
|
278
|
+
declare function randomUUID(options?:OptionsRandomUUID):string;
|
|
279
|
+
/**
|
|
280
|
+
* --------------------------------------------------
|
|
173
281
|
* * ***Utility: `noop`.***
|
|
174
282
|
* --------------------------------------------------
|
|
175
|
-
* **A no-operation function that
|
|
176
|
-
*
|
|
177
|
-
* @
|
|
283
|
+
* **A no-operation function that performs no action.**
|
|
284
|
+
*
|
|
285
|
+
* @description
|
|
286
|
+
* Commonly used as a **placeholder**, **default callback**, or **stub function**.
|
|
287
|
+
*
|
|
288
|
+
* - **Behavior**:
|
|
289
|
+
* - Does not return any meaningful value (`void`).
|
|
290
|
+
* - Safely callable in any context without side effects.
|
|
291
|
+
*
|
|
292
|
+
* @remarks
|
|
293
|
+
* Although this function returns `void`, it implicitly results in `undefined`,
|
|
294
|
+
* but the return value should never be relied upon.
|
|
295
|
+
*
|
|
178
296
|
* @example
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
297
|
+
* **1. Basic usage** — does nothing and returns undefined implicitly:
|
|
298
|
+
* ```
|
|
299
|
+
* import { noop } from "@rzl-zone/utils-js/generators";
|
|
182
300
|
*
|
|
183
|
-
* //
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
301
|
+
* noop(); // ➔ no effect (void)
|
|
302
|
+
* ```
|
|
303
|
+
* @example
|
|
304
|
+
* **2. Using with type-checking helpers:**
|
|
305
|
+
* ```ts
|
|
306
|
+
* import { noop } from "@rzl-zone/utils-js/generators";
|
|
307
|
+
* import { isFunction, isUndefined } from "@rzl-zone/utils-js/predicates";
|
|
308
|
+
*
|
|
309
|
+
* isFunction(noop); // ➔ true — `noop` is a function
|
|
310
|
+
* isUndefined(noop()); // ➔ true — calling `noop()` returns `undefined`
|
|
311
|
+
* isFunction(noop()); // ➔ false — the return value is `undefined`, not a function
|
|
312
|
+
* ```
|
|
313
|
+
* @example
|
|
314
|
+
* **3. As a default callback:**
|
|
315
|
+
* ```ts
|
|
316
|
+
* import { noop } from "@rzl-zone/utils-js/generators";
|
|
187
317
|
*
|
|
188
|
-
* // Often used as a default function
|
|
189
318
|
* const callback = noop;
|
|
190
|
-
* callback();
|
|
191
|
-
*
|
|
319
|
+
* callback(); // ➔ no effect (void)
|
|
320
|
+
* ```
|
|
192
321
|
*/
|
|
193
|
-
declare const noop:()=>void;export{getRandomItem,noop,randomInt,randomIntByLength,randomStr};
|
|
322
|
+
declare const noop:()=>void;export{getRandomItem,noop,randomInt,randomIntByLength,randomStr,randomUUID};
|
package/dist/generators/index.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
export { getRandomItem, randomInt, randomIntByLength, randomStr } from '../chunk-
|
|
10
|
+
export { getRandomItem, randomInt, randomIntByLength, randomStr, randomUUID } from '../chunk-5Y6JL47L.js';
|
|
11
11
|
import '../chunk-WVSPXFTY.js';
|
|
12
12
|
export { noop } from '../chunk-YWHHVDT4.js';
|
|
13
|
-
import '../chunk-
|
|
13
|
+
import '../chunk-X6ULJZ3X.js';
|
|
14
14
|
import '../chunk-QNKGP5DY.js';
|
|
15
|
-
import '../chunk-
|
|
15
|
+
import '../chunk-J4TT33ZX.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
@@ -119,7 +119,7 @@ declare const isNumber:(value:unknown,options?:IsNumberOptions)=>value is number
|
|
|
119
119
|
* - If `T` is `unknown`, the resulting type is `Record<PropertyKey, unknown> & T`.
|
|
120
120
|
* - If `T` is an object:
|
|
121
121
|
* - If it is a non-plain object (class instance, built-in object, etc.), the result is `never`.
|
|
122
|
-
* - If it has no keys (`IsHasKeysObject<T>` checked by **{@link IsHasKeysObject}** is false), the result is `Record<PropertyKey, unknown> & T`.
|
|
122
|
+
* - If it has no keys (`IsHasKeysObject<T>` checked by **{@link IsHasKeysObject|`IsHasKeysObject`}** is false), the result is `Record<PropertyKey, unknown> & T`.
|
|
123
123
|
* - Otherwise, the result is `T` itself.
|
|
124
124
|
* - For any other types, the result is `never`.
|
|
125
125
|
* @template T - The input type to be asserted as a plain object.
|