@rzl-zone/utils-js 3.13.1-beta.0 → 3.14.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/dist/.references/index.d.cts +2 -1
- package/dist/.references/index.d.ts +2 -1
- package/dist/AbortError-DK6kpzbu.cjs +26 -0
- package/dist/AbortError-DK6kpzbu.cjs.map +1 -0
- package/dist/AbortError-DVT8lAKn.js +20 -0
- package/dist/AbortError-DVT8lAKn.js.map +1 -0
- package/dist/{assertIsArray-DrLORH0Y.js → assertIsArray-CG7L7vlt.js} +3 -3
- package/dist/assertIsArray-CG7L7vlt.js.map +1 -0
- package/dist/{assertIsArray-CqIFmlgj.cjs → assertIsArray-CtCRD-_G.cjs} +5 -5
- package/dist/assertIsArray-CtCRD-_G.cjs.map +1 -0
- package/dist/assertIsPlainObject-DPZLj-Ho.cjs +26 -0
- package/dist/assertIsPlainObject-DPZLj-Ho.cjs.map +1 -0
- package/dist/assertIsPlainObject-j9bDqNLo.js +20 -0
- package/dist/assertIsPlainObject-j9bDqNLo.js.map +1 -0
- package/dist/{assertIsString-1iLqxrN0.js → assertIsString-CHIwE12y.js} +4 -4
- package/dist/assertIsString-CHIwE12y.js.map +1 -0
- package/dist/{assertIsString-DGDLC-XD.cjs → assertIsString-CjE9kbQ_.cjs} +6 -6
- package/dist/assertIsString-CjE9kbQ_.cjs.map +1 -0
- package/dist/assertions/index.cjs +14 -12
- package/dist/assertions/index.cjs.map +1 -1
- package/dist/assertions/index.d.cts +2 -2
- package/dist/assertions/index.d.ts +2 -2
- package/dist/assertions/index.js +10 -8
- package/dist/assertions/index.js.map +1 -1
- package/dist/conversions/index.cjs +6 -6
- package/dist/conversions/index.d.cts +2 -2
- package/dist/conversions/index.d.ts +2 -2
- package/dist/conversions/index.js +6 -6
- package/dist/conversions-BFz6MKaV.cjs +449 -0
- package/dist/conversions-BFz6MKaV.cjs.map +1 -0
- package/dist/{conversions-CA_3PTAH.js → conversions-Ben5p5Ts.js} +43 -40
- package/dist/conversions-Ben5p5Ts.js.map +1 -0
- package/dist/errors/index.cjs +13 -0
- package/dist/errors/index.d.cts +180 -0
- package/dist/errors/index.d.ts +180 -0
- package/dist/errors/index.js +11 -0
- package/dist/events/index.cjs +10 -9
- package/dist/events/index.cjs.map +1 -1
- package/dist/events/index.d.cts +185 -100
- package/dist/events/index.d.ts +185 -100
- package/dist/events/index.js +9 -8
- package/dist/events/index.js.map +1 -1
- package/dist/formatter-ekJQF_bA-BepnCBkQ.cjs +67 -0
- package/dist/formatter-ekJQF_bA-BepnCBkQ.cjs.map +1 -0
- package/dist/formatter-ekJQF_bA-xLD9mGk4.js +55 -0
- package/dist/formatter-ekJQF_bA-xLD9mGk4.js.map +1 -0
- package/dist/formatters/index.cjs +2 -2
- package/dist/formatters/index.d.cts +2 -2
- package/dist/formatters/index.d.ts +2 -2
- package/dist/formatters/index.js +2 -2
- package/dist/{formatters-Bm3a_akj.js → formatters-BAbGsnYA.js} +78 -71
- package/dist/formatters-BAbGsnYA.js.map +1 -0
- package/dist/formatters-zd0Gs4Cs.cjs +436 -0
- package/dist/formatters-zd0Gs4Cs.cjs.map +1 -0
- package/dist/generators/index.cjs +37 -31
- package/dist/generators/index.cjs.map +1 -1
- package/dist/generators/index.d.cts +2 -2
- package/dist/generators/index.d.ts +2 -2
- package/dist/generators/index.js +29 -23
- package/dist/generators/index.js.map +1 -1
- package/dist/hasOwnProp-CVIhlD1i.js +47 -0
- package/dist/hasOwnProp-CVIhlD1i.js.map +1 -0
- package/dist/hasOwnProp-D9Tpgokd.cjs +53 -0
- package/dist/hasOwnProp-D9Tpgokd.cjs.map +1 -0
- package/dist/{index-CakviK5E.d.cts → index-9JsU_wMu.d.ts} +1375 -937
- package/dist/{index-BqkYm8qT.d.ts → index-BP3sUrAx.d.ts} +242 -133
- package/dist/{index-CJx0EFQ4.d.cts → index-BVovC-yK.d.cts} +229 -200
- package/dist/index-C1X6ha9s.d.cts +1041 -0
- package/dist/index-CcPQZ41G.d.cts +1103 -0
- package/dist/index-CjpbuJF4.d.ts +2424 -0
- package/dist/index-CssrQyHh.d.cts +2424 -0
- package/dist/index-DZHiYYR7.d.cts +2179 -0
- package/dist/index-DZHiYYR7.d.ts +2179 -0
- package/dist/index-DlyDmXUo.d.ts +1103 -0
- package/dist/index-Dm4a___O.d.ts +1041 -0
- package/dist/{index-D5nTp1kV.d.ts → index-Dwduk7ez.d.cts} +1375 -937
- package/dist/{index-uaHl0X-r.d.cts → index-I5V6RbZM.d.cts} +1592 -790
- package/dist/{index-Bm5odgLW.d.ts → index-hOqBIL7F.d.ts} +1592 -790
- package/dist/{index-hOCUw-B9.d.ts → index-jyuOZMX7.d.ts} +229 -200
- package/dist/{index-BqkYm8qT.d.cts → index-lI0b7iUz.d.cts} +242 -133
- package/dist/{isBigInt-f6yY2fAV.js → isBigInt-Cez32M69.js} +2 -2
- package/dist/isBigInt-Cez32M69.js.map +1 -0
- package/dist/{isBigInt-CqZNWVtI.cjs → isBigInt-YgpNKTbA.cjs} +2 -2
- package/dist/isBigInt-YgpNKTbA.cjs.map +1 -0
- package/dist/{isEmptyString-Ga77_3Q1.js → isEmptyString-C9QLWjx2.js} +4 -4
- package/dist/isEmptyString-C9QLWjx2.js.map +1 -0
- package/dist/{isEmptyString-DNMPmS-H.cjs → isEmptyString-O4TFe1Ao.cjs} +5 -5
- package/dist/isEmptyString-O4TFe1Ao.cjs.map +1 -0
- package/dist/isEmptyValue-CFExALXZ.cjs +54 -0
- package/dist/isEmptyValue-CFExALXZ.cjs.map +1 -0
- package/dist/isEmptyValue-kCjnLjbN.js +36 -0
- package/dist/isEmptyValue-kCjnLjbN.js.map +1 -0
- package/dist/{isFinite-Crw95XV8.cjs → isFinite-B_hHbDpa.cjs} +6 -6
- package/dist/isFinite-B_hHbDpa.cjs.map +1 -0
- package/dist/{isFinite-BJO7Dt6B.js → isFinite-ZvNhyHlF.js} +5 -5
- package/dist/isFinite-ZvNhyHlF.js.map +1 -0
- package/dist/{isInteger-B75voxys.js → isInteger-aZgzTTZG.js} +4 -4
- package/dist/isInteger-aZgzTTZG.js.map +1 -0
- package/dist/{isInteger-CSMNm--9.cjs → isInteger-dnc6W63Z.cjs} +4 -4
- package/dist/isInteger-dnc6W63Z.cjs.map +1 -0
- package/dist/isNumber-BCWD4dW0.js +20 -0
- package/dist/isNumber-BCWD4dW0.js.map +1 -0
- package/dist/isNumber-BkzwAe50.cjs +26 -0
- package/dist/isNumber-BkzwAe50.cjs.map +1 -0
- package/dist/isPlainObject-CAe_ElKO.d.cts +331 -0
- package/dist/isPlainObject-CJvRG4Je.d.ts +331 -0
- package/dist/{isServer-BHOSvBhV.js → isServer-CQzrX5e0.js} +2 -2
- package/dist/isServer-CQzrX5e0.js.map +1 -0
- package/dist/{isServer-HA13Dzo2.cjs → isServer-DhFaedeT.cjs} +2 -2
- package/dist/isServer-DhFaedeT.cjs.map +1 -0
- package/dist/{isEqual-D8W3Wizi.cjs → isTypedArray-DjADSu8q.cjs} +45 -13
- package/dist/isTypedArray-DjADSu8q.cjs.map +1 -0
- package/dist/{isEqual-ekId-j5b.js → isTypedArray-DxsPKrLh.js} +29 -9
- package/dist/isTypedArray-DxsPKrLh.js.map +1 -0
- package/dist/{isValidDomain-BqyLVi7S.js → isValidDomain-CDtNOhMc.js} +13 -54
- package/dist/isValidDomain-CDtNOhMc.js.map +1 -0
- package/dist/{isValidDomain-ByrOfQsh.cjs → isValidDomain-D_x7uNIu.cjs} +16 -69
- package/dist/isValidDomain-D_x7uNIu.cjs.map +1 -0
- package/dist/{assertIsBoolean-DDhQ2D-k.js → logger-CLWnKRKE.js} +657 -587
- package/dist/logger-CLWnKRKE.js.map +1 -0
- package/dist/{assertIsBoolean-CEx4KbHg.cjs → logger-CUacYy3D.cjs} +658 -612
- package/dist/logger-CUacYy3D.cjs.map +1 -0
- package/dist/{noop-CkwxErJ2.cjs → noop-CjEbNsJL.cjs} +2 -2
- package/dist/noop-CjEbNsJL.cjs.map +1 -0
- package/dist/{noop-D_Ots__Z.js → noop-qxrcogt5.js} +2 -2
- package/dist/noop-qxrcogt5.js.map +1 -0
- package/dist/{normalizeSpaces-88yaixiu.cjs → normalizeSpaces-D0_Z4qnO.cjs} +6 -9
- package/dist/normalizeSpaces-D0_Z4qnO.cjs.map +1 -0
- package/dist/{normalizeSpaces-Cat8CHtt.js → normalizeSpaces-DAsxzBEQ.js} +4 -7
- package/dist/normalizeSpaces-DAsxzBEQ.js.map +1 -0
- package/dist/operations/index.cjs +152 -22
- package/dist/operations/index.cjs.map +1 -1
- package/dist/operations/index.d.cts +257 -35
- package/dist/operations/index.d.ts +257 -35
- package/dist/operations/index.js +142 -13
- package/dist/operations/index.js.map +1 -1
- package/dist/parsers/index.cjs +2 -2
- package/dist/parsers/index.d.cts +238 -180
- package/dist/parsers/index.d.ts +238 -180
- package/dist/parsers/index.js +2 -2
- package/dist/{parsers-BLHzVoh-.js → parsers-BBAE_xVM.js} +9 -8
- package/dist/parsers-BBAE_xVM.js.map +1 -0
- package/dist/{parsers-xAQmKCgS.cjs → parsers-i8WEeMJl.cjs} +10 -9
- package/dist/parsers-i8WEeMJl.cjs.map +1 -0
- package/dist/{parsing-BYo6U0EG.js → parsing-D9tbKQ0v.js} +3 -3
- package/dist/parsing-D9tbKQ0v.js.map +1 -0
- package/dist/{parsing-CuezVd0e.cjs → parsing-DGjB8cwr.cjs} +4 -4
- package/dist/parsing-DGjB8cwr.cjs.map +1 -0
- package/dist/predicates/index.cjs +43 -43
- package/dist/predicates/index.d.cts +3 -3
- package/dist/predicates/index.d.ts +3 -3
- package/dist/predicates/index.js +14 -14
- package/dist/{predicates-BMTIIYx8.js → predicates-C0dova7l.js} +45 -40
- package/dist/predicates-C0dova7l.js.map +1 -0
- package/dist/{predicates-ZmZpelMh.cjs → predicates-Dd7To7B4.cjs} +89 -84
- package/dist/predicates-Dd7To7B4.cjs.map +1 -0
- package/dist/promises/index.cjs +27 -26
- package/dist/promises/index.cjs.map +1 -1
- package/dist/promises/index.d.cts +227 -75
- package/dist/promises/index.d.ts +227 -75
- package/dist/promises/index.js +27 -26
- package/dist/promises/index.js.map +1 -1
- package/dist/{punyCode-WZ6-GaTM.cjs → punyCode-DHTLhGdD.cjs} +12 -12
- package/dist/punyCode-DHTLhGdD.cjs.map +1 -0
- package/dist/{punyCode-COTqgXMJ.js → punyCode-Deb1Mrkc.js} +12 -12
- package/dist/punyCode-Deb1Mrkc.js.map +1 -0
- package/dist/{removeSpaces-CQJvw1yU.js → removeSpaces-BPnsdRN0.js} +4 -4
- package/dist/removeSpaces-BPnsdRN0.js.map +1 -0
- package/dist/{removeSpaces-BeGkktUl.cjs → removeSpaces-CN3pxBz_.cjs} +7 -7
- package/dist/removeSpaces-CN3pxBz_.cjs.map +1 -0
- package/dist/rzl-utils.global.js +13 -13
- package/dist/safeJsonParse-D1FLVTEM.cjs +209 -0
- package/dist/safeJsonParse-D1FLVTEM.cjs.map +1 -0
- package/dist/{safeJsonParse-D8H3wCv7.js → safeJsonParse-DEVKNDSn.js} +29 -28
- package/dist/safeJsonParse-DEVKNDSn.js.map +1 -0
- package/dist/safeStableStringify-C5HHKUdn.cjs +125 -0
- package/dist/safeStableStringify-C5HHKUdn.cjs.map +1 -0
- package/dist/{safeStableStringify-BLwA1VC-.js → safeStableStringify-DfwxmiWn.js} +20 -13
- package/dist/safeStableStringify-DfwxmiWn.js.map +1 -0
- package/dist/strings/index.cjs +26 -30
- package/dist/strings/index.cjs.map +1 -1
- package/dist/strings/index.d.cts +2 -2
- package/dist/strings/index.d.ts +2 -2
- package/dist/strings/index.js +13 -17
- package/dist/strings/index.js.map +1 -1
- package/dist/tailwind/index.cjs +3 -3
- package/dist/tailwind/index.d.cts +3 -3
- package/dist/tailwind/index.d.ts +3 -3
- package/dist/tailwind/index.js +3 -3
- package/dist/{tailwind-CjxdO7aL.cjs → tailwind-BG7B0cDs.cjs} +59 -53
- package/dist/tailwind-BG7B0cDs.cjs.map +1 -0
- package/dist/{tailwind-RSE3obLb.js → tailwind-tJNnFPsF.js} +38 -32
- package/dist/tailwind-tJNnFPsF.js.map +1 -0
- package/dist/{toStringArrayUnRecursive-NreW1dyV.js → toStringArrayUnRecursive-D0WbLIRz.js} +9 -9
- package/dist/toStringArrayUnRecursive-D0WbLIRz.js.map +1 -0
- package/dist/toStringArrayUnRecursive-QLoaNX_-.cjs +51 -0
- package/dist/toStringArrayUnRecursive-QLoaNX_-.cjs.map +1 -0
- package/dist/urls/index.cjs +3 -3
- package/dist/urls/index.d.cts +635 -443
- package/dist/urls/index.d.ts +635 -443
- package/dist/urls/index.js +3 -3
- package/dist/{urls-CLVfEB7O.js → urls-EoWslGgg.js} +50 -41
- package/dist/urls-EoWslGgg.js.map +1 -0
- package/dist/urls-NCzPepe2.cjs +308 -0
- package/dist/urls-NCzPepe2.cjs.map +1 -0
- package/package.json +6 -6
- package/dist/assertIsArray-CqIFmlgj.cjs.map +0 -1
- package/dist/assertIsArray-DrLORH0Y.js.map +0 -1
- package/dist/assertIsBoolean-CEx4KbHg.cjs.map +0 -1
- package/dist/assertIsBoolean-DDhQ2D-k.js.map +0 -1
- package/dist/assertIsString-1iLqxrN0.js.map +0 -1
- package/dist/assertIsString-DGDLC-XD.cjs.map +0 -1
- package/dist/conversions-Bxa01uIl.cjs +0 -446
- package/dist/conversions-Bxa01uIl.cjs.map +0 -1
- package/dist/conversions-CA_3PTAH.js.map +0 -1
- package/dist/formatters-Bm3a_akj.js.map +0 -1
- package/dist/formatters-Bt6QuhxK.cjs +0 -429
- package/dist/formatters-Bt6QuhxK.cjs.map +0 -1
- package/dist/index--h04HuBE.d.cts +0 -765
- package/dist/index--h04HuBE.d.ts +0 -765
- package/dist/index-Ap8U-8Qx.d.cts +0 -947
- package/dist/index-BAeeggeh.d.cts +0 -1716
- package/dist/index-BAeeggeh.d.ts +0 -1716
- package/dist/index-CMglhpFG.d.ts +0 -947
- package/dist/isBigInt-CqZNWVtI.cjs.map +0 -1
- package/dist/isBigInt-f6yY2fAV.js.map +0 -1
- package/dist/isEmptyObject-BYNnSKzw.js +0 -25
- package/dist/isEmptyObject-BYNnSKzw.js.map +0 -1
- package/dist/isEmptyObject-C2lQyFZS.cjs +0 -37
- package/dist/isEmptyObject-C2lQyFZS.cjs.map +0 -1
- package/dist/isEmptyString-DNMPmS-H.cjs.map +0 -1
- package/dist/isEmptyString-Ga77_3Q1.js.map +0 -1
- package/dist/isEmptyValue-D7-6WWS9.js +0 -24
- package/dist/isEmptyValue-D7-6WWS9.js.map +0 -1
- package/dist/isEmptyValue-DZaDHEIw.cjs +0 -30
- package/dist/isEmptyValue-DZaDHEIw.cjs.map +0 -1
- package/dist/isEqual-D8W3Wizi.cjs.map +0 -1
- package/dist/isEqual-ekId-j5b.js.map +0 -1
- package/dist/isFinite-BJO7Dt6B.js.map +0 -1
- package/dist/isFinite-Crw95XV8.cjs.map +0 -1
- package/dist/isInteger-B75voxys.js.map +0 -1
- package/dist/isInteger-CSMNm--9.cjs.map +0 -1
- package/dist/isPlainObject-ByfuseCf.d.cts +0 -339
- package/dist/isPlainObject-ByfuseCf.d.ts +0 -339
- package/dist/isServer-BHOSvBhV.js.map +0 -1
- package/dist/isServer-HA13Dzo2.cjs.map +0 -1
- package/dist/isTypedArray-CWlHRz_O.cjs +0 -43
- package/dist/isTypedArray-CWlHRz_O.cjs.map +0 -1
- package/dist/isTypedArray-CmnQ7Yx9.js +0 -31
- package/dist/isTypedArray-CmnQ7Yx9.js.map +0 -1
- package/dist/isValidDomain-BqyLVi7S.js.map +0 -1
- package/dist/isValidDomain-ByrOfQsh.cjs.map +0 -1
- package/dist/noop-CkwxErJ2.cjs.map +0 -1
- package/dist/noop-D_Ots__Z.js.map +0 -1
- package/dist/normalizeSpaces-88yaixiu.cjs.map +0 -1
- package/dist/normalizeSpaces-Cat8CHtt.js.map +0 -1
- package/dist/parsers-BLHzVoh-.js.map +0 -1
- package/dist/parsers-xAQmKCgS.cjs.map +0 -1
- package/dist/parsing-BYo6U0EG.js.map +0 -1
- package/dist/parsing-CuezVd0e.cjs.map +0 -1
- package/dist/predicates-BMTIIYx8.js.map +0 -1
- package/dist/predicates-ZmZpelMh.cjs.map +0 -1
- package/dist/punyCode-COTqgXMJ.js.map +0 -1
- package/dist/punyCode-WZ6-GaTM.cjs.map +0 -1
- package/dist/removeSpaces-BeGkktUl.cjs.map +0 -1
- package/dist/removeSpaces-CQJvw1yU.js.map +0 -1
- package/dist/safeJsonParse-BznDD3fi.cjs +0 -208
- package/dist/safeJsonParse-BznDD3fi.cjs.map +0 -1
- package/dist/safeJsonParse-D8H3wCv7.js.map +0 -1
- package/dist/safeStableStringify-4b-E_UHM.cjs +0 -106
- package/dist/safeStableStringify-4b-E_UHM.cjs.map +0 -1
- package/dist/safeStableStringify-BLwA1VC-.js.map +0 -1
- package/dist/tailwind-CjxdO7aL.cjs.map +0 -1
- package/dist/tailwind-RSE3obLb.js.map +0 -1
- package/dist/toStringArrayUnRecursive-D-jHROts.cjs +0 -51
- package/dist/toStringArrayUnRecursive-D-jHROts.cjs.map +0 -1
- package/dist/toStringArrayUnRecursive-NreW1dyV.js.map +0 -1
- package/dist/urls-C6BvhrrV.cjs +0 -299
- package/dist/urls-C6BvhrrV.cjs.map +0 -1
- package/dist/urls-CLVfEB7O.js.map +0 -1
|
@@ -2,22 +2,30 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
/**
|
|
11
|
+
import { T as NullToUndefined, d as IfNonEmptyArray, l as FixNeverArrayRecursive, s as Extends } from "./index-DZHiYYR7.cjs";
|
|
12
|
+
/** -------------------------------------------------------------------------------------
|
|
13
13
|
* * ***Utility: `getRandomItem`.***
|
|
14
|
-
*
|
|
14
|
+
* --------------------------------------------------------------------------------------
|
|
15
15
|
* **Function to get a random element from a given array.**
|
|
16
|
+
*
|
|
17
|
+
* ---
|
|
16
18
|
* @template T - The type of the input array.
|
|
19
|
+
*
|
|
20
|
+
* ---
|
|
17
21
|
* @param {*} array - The input array, can be `null`, `undefined`, or an empty array.
|
|
22
|
+
*
|
|
23
|
+
* ---
|
|
18
24
|
* @returns
|
|
19
25
|
* - If `array` is a non-empty tuple, returns one of its elements.
|
|
20
26
|
* - If `array` is empty, `null`, or `undefined`, returns `undefined`.
|
|
27
|
+
*
|
|
28
|
+
* ---
|
|
21
29
|
* @example
|
|
22
30
|
* getRandomItem([]);
|
|
23
31
|
* // ➔ undefined
|
|
@@ -45,24 +53,38 @@ declare function getRandomItem(array: []): undefined;
|
|
|
45
53
|
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>;
|
|
46
54
|
declare function getRandomItem<T extends readonly unknown[] | undefined | null>(array: T): T extends readonly unknown[] ? NullToUndefined<FixNeverArrayRecursive<T[number]>> | undefined : undefined;
|
|
47
55
|
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;
|
|
48
|
-
/**
|
|
56
|
+
/** -----------------------------------------------------------------------------------------------------
|
|
49
57
|
* * ***Utility: `randomInt`.***
|
|
50
|
-
*
|
|
58
|
+
* ------------------------------------------------------------------------------------------------------
|
|
51
59
|
* **Generates a random integer within a specified range (inclusive).**
|
|
60
|
+
*
|
|
61
|
+
* ---
|
|
52
62
|
* - **Generates a random integer between `min` and `max` (inclusive), with safety constraints:**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
63
|
+
* - `min` will be forced to be at least `1`.
|
|
64
|
+
* - `max` will be capped at `Number.MAX_SAFE_INTEGER`.
|
|
65
|
+
*
|
|
66
|
+
* ---
|
|
55
67
|
* @param {number} min - The minimum value (inclusive), must be an integer.
|
|
56
68
|
* @param {number} max - The maximum value (inclusive), must be an integer.
|
|
69
|
+
*
|
|
70
|
+
* ---
|
|
57
71
|
* @returns {number} A random integer N where `min ≤ N ≤ max`.
|
|
72
|
+
*
|
|
73
|
+
* ---
|
|
58
74
|
* @throws **{@link TypeError | `TypeError`}** if:
|
|
59
75
|
* - `min` or `max` is not an integer, or value is `Number.MIN_VALUE`.
|
|
60
76
|
* - `min` is greater than `max`.
|
|
77
|
+
*
|
|
78
|
+
* ---
|
|
61
79
|
* @example
|
|
62
|
-
* randomInt(1, 10);
|
|
63
|
-
*
|
|
64
|
-
* randomInt(
|
|
65
|
-
*
|
|
80
|
+
* randomInt(1, 10);
|
|
81
|
+
* // ➔ returns 1 up-to 10 (random)
|
|
82
|
+
* randomInt(50, 100);
|
|
83
|
+
* // ➔ returns 50 up-to 100 (random)
|
|
84
|
+
* randomInt(5, 5);
|
|
85
|
+
* // ➔ always returns 5 (exact)
|
|
86
|
+
* randomInt(-5, 3);
|
|
87
|
+
* // ➔ always returns ≥ 1, since min is adjusted (exact)
|
|
66
88
|
* randomInt(1, Number.MAX_SAFE_INTEGER + 10000);
|
|
67
89
|
* // ➔ still safely capped at MAX_SAFE_INTEGER
|
|
68
90
|
* randomInt(Number.MIN_VALUE, 3);
|
|
@@ -70,17 +92,23 @@ declare function getRandomItem<T>(array: T): unknown extends T ? unknown : Exten
|
|
|
70
92
|
*/
|
|
71
93
|
declare const randomInt: (min: number, max: number) => number;
|
|
72
94
|
type OptionsRandomIntByLength = {
|
|
73
|
-
/**
|
|
95
|
+
/** -----------------------------------------------------------------------------------
|
|
96
|
+
* * ***Minimum length of the random number, the `allowed minimal value` `integer` is `1` `and not bigger than value of` `maxLength`, defaultValue: `1`.***
|
|
97
|
+
* ------------------------------------------------------------------------------------
|
|
74
98
|
*
|
|
75
99
|
* @default 1
|
|
76
100
|
*/
|
|
77
101
|
minLength?: number;
|
|
78
|
-
/**
|
|
102
|
+
/** -----------------------------------------------------------------------------------
|
|
103
|
+
* * ***Maximum length of the random number, the `allowed maximal value` `integer` is `16`, defaultValue: `16`.***
|
|
104
|
+
* ------------------------------------------------------------------------------------
|
|
79
105
|
*
|
|
80
106
|
* @default 16
|
|
81
107
|
*/
|
|
82
108
|
maxLength?: number;
|
|
83
|
-
/**
|
|
109
|
+
/** -----------------------------------------------------------------------------------
|
|
110
|
+
* * ***If true, prevents the result from being zero, defaultValue: `false`.***
|
|
111
|
+
* ------------------------------------------------------------------------------------
|
|
84
112
|
*
|
|
85
113
|
* @default false
|
|
86
114
|
*/
|
|
@@ -90,78 +118,107 @@ type OptionsRandomIntByLength = {
|
|
|
90
118
|
* * ***Utility: `randomIntByLength`.***
|
|
91
119
|
* -----------------------------------------------------------------------------
|
|
92
120
|
* **Generates a random integer within a specified range of digit lengths.**
|
|
121
|
+
*
|
|
122
|
+
* ---
|
|
93
123
|
* @description
|
|
94
124
|
* This function allows generating random integers that strictly conform to a specified minimum and
|
|
95
125
|
* maximum digit length, it is useful for scenarios such as generating realistic-looking IDs, codes,
|
|
96
126
|
* or random test data.
|
|
127
|
+
*
|
|
128
|
+
* ---
|
|
97
129
|
* - **The function ensures:**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
130
|
+
* - `minLength` is at least 1 and not greater than `maxLength`.
|
|
131
|
+
* - `maxLength` is no more than 16 (due to JavaScript's `Number.MAX_SAFE_INTEGER`).
|
|
132
|
+
* - If `avoidZero` is `true`, ensures that `0` is never returned.
|
|
133
|
+
*
|
|
134
|
+
* ---
|
|
101
135
|
* @param {OptionsRandomIntByLength} [options] - Configuration options.
|
|
102
136
|
* @param {OptionsRandomIntByLength["minLength"]} [options.minLength=1] - Minimum number of digits (must be ≥ `1` and ≤ `maxLength`).
|
|
103
137
|
* @param {OptionsRandomIntByLength["maxLength"]} [options.maxLength=16] - Maximum number of digits (must be ≤ `16`).
|
|
104
138
|
* @param {OptionsRandomIntByLength["avoidZero"]} [options.avoidZero=false] - If true, will ensure the result is never zero.
|
|
105
|
-
*
|
|
139
|
+
*
|
|
140
|
+
* ---
|
|
106
141
|
* @throws **{@link TypeError | `TypeError`}** if parameters are invalid, such as:
|
|
107
|
-
* - `minLength` < `1
|
|
108
|
-
* - `maxLength` > `16
|
|
109
|
-
* - `minLength` > `maxLength
|
|
110
|
-
* - non-integer values for `minLength` or `maxLength
|
|
142
|
+
* - `minLength` < `1`.
|
|
143
|
+
* - `maxLength` > `16`.
|
|
144
|
+
* - `minLength` > `maxLength`.
|
|
145
|
+
* - non-integer values for `minLength` or `maxLength`.
|
|
146
|
+
*
|
|
147
|
+
* ---
|
|
148
|
+
* @returns {number} A randomly generated integer within the specified constraints.
|
|
149
|
+
*
|
|
150
|
+
* ---
|
|
111
151
|
* @example
|
|
112
152
|
* randomIntByLength({ minLength: 3, maxLength: 5 });
|
|
113
|
-
* // ➔ `
|
|
153
|
+
* // ➔ `xxx` (random int), `xxxx` (random int) or `xxxxx` (random int).
|
|
114
154
|
* randomIntByLength({ minLength: 4, maxLength: 4 });
|
|
115
|
-
* // ➔ `
|
|
116
|
-
* randomIntByLength({ avoidZero: true });
|
|
117
|
-
* // ➔ never 0
|
|
155
|
+
* // ➔ `xxxx` (exact 4 digits int)
|
|
156
|
+
* randomIntByLength({ avoidZero: true }); // never 0
|
|
118
157
|
*/
|
|
119
158
|
declare const randomIntByLength: (options?: OptionsRandomIntByLength) => number;
|
|
120
159
|
type OptionsRandomStr = {
|
|
121
|
-
/**
|
|
160
|
+
/** -----------------------------------------------------------------------------------
|
|
161
|
+
* * ***Ensures no whitespace characters in the generated string, defaultValue: `true`.***
|
|
162
|
+
* ------------------------------------------------------------------------------------
|
|
122
163
|
*
|
|
123
164
|
* @default true
|
|
124
165
|
*/
|
|
125
166
|
avoidWhiteSpace?: boolean;
|
|
126
|
-
/**
|
|
167
|
+
/** -----------------------------------------------------------------------------------
|
|
168
|
+
* * ***Custom characters to replace the default number set if `type` is `"number"`, defaultValue: `undefined`.***
|
|
169
|
+
* ------------------------------------------------------------------------------------
|
|
127
170
|
*
|
|
128
171
|
* @default undefined
|
|
129
172
|
*/
|
|
130
173
|
replaceGenInt?: string;
|
|
131
|
-
/**
|
|
174
|
+
/** -----------------------------------------------------------------------------------
|
|
175
|
+
* * ***Custom characters to replace the default string set if `type` is `"string"`, defaultValue: `undefined`.***
|
|
176
|
+
* ------------------------------------------------------------------------------------
|
|
132
177
|
*
|
|
133
178
|
* @default undefined
|
|
134
179
|
*/
|
|
135
180
|
replaceGenStr?: string;
|
|
136
|
-
/**
|
|
181
|
+
/** -----------------------------------------------------------------------------------
|
|
182
|
+
* * ***Additional characters to include in the generated string, defaultValue: `undefined`.***
|
|
183
|
+
* ------------------------------------------------------------------------------------
|
|
137
184
|
*
|
|
138
185
|
* @default undefined
|
|
139
186
|
*/
|
|
140
187
|
addChar?: string;
|
|
141
|
-
/**
|
|
188
|
+
/** -----------------------------------------------------------------------------------
|
|
189
|
+
* * ***Minimum length of the generated string (1 to 5000), defaultValue: `40`.***
|
|
190
|
+
* ------------------------------------------------------------------------------------
|
|
142
191
|
*
|
|
143
192
|
* @default 40
|
|
144
193
|
*/
|
|
145
194
|
minLength?: number;
|
|
146
|
-
/**
|
|
195
|
+
/** -----------------------------------------------------------------------------------
|
|
196
|
+
* * ***Maximum length of the generated string (1 to 5000), defaultValue: `40`.***
|
|
197
|
+
* ------------------------------------------------------------------------------------
|
|
147
198
|
*
|
|
148
199
|
* @default 40
|
|
149
200
|
*/
|
|
150
201
|
maxLength?: number;
|
|
151
|
-
/**
|
|
202
|
+
/** -----------------------------------------------------------------------------------
|
|
203
|
+
* * ***Type of output: `"string"` or `"number"`, defaultValue: `"string"`.***
|
|
204
|
+
* ------------------------------------------------------------------------------------
|
|
152
205
|
*
|
|
153
206
|
* @default "string"
|
|
154
207
|
*/
|
|
155
208
|
type?: "string" | "number";
|
|
156
209
|
};
|
|
157
|
-
/**
|
|
210
|
+
/** -----------------------------------------------------------------------------------
|
|
158
211
|
* * ***Utility: `randomStr`.***
|
|
159
|
-
*
|
|
212
|
+
* ------------------------------------------------------------------------------------
|
|
160
213
|
* **Generates a random alphanumeric string or number with a specified length range.**
|
|
214
|
+
*
|
|
215
|
+
* ---
|
|
161
216
|
* @description
|
|
162
217
|
* This function allows you to generate random strings or numbers with fully
|
|
163
218
|
* customizable options, such as length range, character sets, inclusion of
|
|
164
219
|
* additional characters, and whether to avoid whitespace.
|
|
220
|
+
*
|
|
221
|
+
* ---
|
|
165
222
|
* @param {OptionsRandomStr} [options] - Configuration options for generating the string.
|
|
166
223
|
* @param {OptionsRandomStr["minLength"]} [options.minLength=40] - Minimum length of the generated string (must be `≥` `1`).
|
|
167
224
|
* @param {OptionsRandomStr["maxLength"]} [options.maxLength=40] - Maximum length of the generated string (must be `≤` `5000`).
|
|
@@ -170,8 +227,14 @@ type OptionsRandomStr = {
|
|
|
170
227
|
* @param {OptionsRandomStr["replaceGenStr"]} [options.replaceGenStr] - A custom character set to use when `type` is `"string"`.
|
|
171
228
|
* @param {OptionsRandomStr["replaceGenInt"]} [options.replaceGenInt] - A custom character set to use when `type` is `"number"`.
|
|
172
229
|
* @param {OptionsRandomStr["addChar"]} [options.addChar] - Additional characters to always include in the character set.
|
|
173
|
-
*
|
|
230
|
+
*
|
|
231
|
+
* ---
|
|
174
232
|
* @throws **{@link TypeError | `TypeError`}** if provided options are invalid (such as minLength > maxLength, invalid type, or empty character set).
|
|
233
|
+
*
|
|
234
|
+
* ---
|
|
235
|
+
* @returns {string} The randomly generated string or numeric string of the desired length.
|
|
236
|
+
*
|
|
237
|
+
* ---
|
|
175
238
|
* @example
|
|
176
239
|
* randomStr();
|
|
177
240
|
* // ➔ Generates a 40-character random alphanumeric string
|
|
@@ -185,42 +248,63 @@ type OptionsRandomStr = {
|
|
|
185
248
|
* // ➔ Guaranteed to include !@# in the set
|
|
186
249
|
*/
|
|
187
250
|
declare const randomStr: (options?: OptionsRandomStr) => string;
|
|
188
|
-
/**
|
|
189
|
-
* Configuration options for `randomUUID()
|
|
251
|
+
/** ---------------------------------------------------------
|
|
252
|
+
* * ***Configuration options for `randomUUID()`.***
|
|
253
|
+
* ----------------------------------------------------------
|
|
190
254
|
*/
|
|
191
255
|
type OptionsRandomUUID = {
|
|
192
|
-
/**
|
|
193
|
-
* Specifies which UUID version to generate
|
|
256
|
+
/** ---------------------------------------------------------
|
|
257
|
+
* * ***Specifies which UUID version to generate.***
|
|
258
|
+
* ----------------------------------------------------------
|
|
194
259
|
*
|
|
195
|
-
* - `"v4"` — Fully random UUID (RFC 4122)
|
|
196
|
-
* - `"v7"` — Time-ordered UUID (RFC 9562)
|
|
260
|
+
* - `"v4"` — Fully random UUID (RFC 4122), no timestamp, no ordering guarantees.
|
|
261
|
+
* - `"v7"` — Time-ordered UUID (RFC 9562), uses Unix timestamp + randomness.
|
|
197
262
|
*
|
|
198
|
-
*
|
|
263
|
+
* ---
|
|
264
|
+
* @default
|
|
265
|
+
* ```ts
|
|
266
|
+
* "v4"
|
|
267
|
+
* ```
|
|
199
268
|
*
|
|
269
|
+
* ---
|
|
200
270
|
* @example
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
271
|
+
* 1. #### Random `v4` UUID:
|
|
272
|
+
* ```ts
|
|
273
|
+
* randomUUID({ version: "v4" });
|
|
274
|
+
* // ➔ "xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx"
|
|
275
|
+
* ```
|
|
276
|
+
* ---
|
|
277
|
+
* 2. #### Time-ordered `v7` UUID:
|
|
278
|
+
* ```ts
|
|
279
|
+
* randomUUID({ version: "v7" });
|
|
280
|
+
* // ➔ "xxxxxxxx-xxxx-7xxx-xxxx-xxxxxxxxxxxx"
|
|
281
|
+
* ```
|
|
207
282
|
*/
|
|
208
283
|
version?: "v4" | "v7";
|
|
209
|
-
/**
|
|
210
|
-
* Enables monotonic sequencing for UUID v7
|
|
284
|
+
/** ---------------------------------------------------------
|
|
285
|
+
* * ***Enables monotonic sequencing for UUID v7.***
|
|
286
|
+
* ----------------------------------------------------------
|
|
211
287
|
*
|
|
212
288
|
* - Guarantees that multiple UUIDs generated within the same millisecond
|
|
213
289
|
* are strictly non-decreasing (lexicographically and timestamp-wise).
|
|
214
|
-
* - Only valid when `version === "v7"
|
|
290
|
+
* - Only valid when `version === "v7"`, using with `v4` will throw a `TypeError`.
|
|
215
291
|
* - Useful for database inserts, logs, or any system where order matters.
|
|
216
292
|
*
|
|
217
|
-
*
|
|
293
|
+
* ---
|
|
294
|
+
* @default
|
|
295
|
+
* ```ts
|
|
296
|
+
* false
|
|
297
|
+
* ```
|
|
218
298
|
*
|
|
299
|
+
* ---
|
|
219
300
|
* @example
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
301
|
+
* - #### Monotonic `v7` UUIDs:
|
|
302
|
+
* ```ts
|
|
303
|
+
* const a = randomUUID({ version: "v7", monotonic: true });
|
|
304
|
+
* const b = randomUUID({ version: "v7", monotonic: true });
|
|
305
|
+
* console.log(a < b);
|
|
306
|
+
* // ➔ true (guaranteed)
|
|
307
|
+
* ```
|
|
224
308
|
*/
|
|
225
309
|
monotonic?: boolean;
|
|
226
310
|
};
|
|
@@ -229,112 +313,137 @@ type OptionsRandomUUID = {
|
|
|
229
313
|
* ------------------------------------------------------------------------
|
|
230
314
|
* **Generates a UUID string according to the specified version and options.**
|
|
231
315
|
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* - **v7**: Time-ordered; collisions extremely unlikely unless same ms + random repeat.
|
|
246
|
-
* - **Monotonic v7**: Guaranteed ordering per-process if multiple UUIDs are generated
|
|
247
|
-
* in the same millisecond.
|
|
248
|
-
* - **All versions**: Fallback safely if `crypto` APIs are unavailable.
|
|
316
|
+
* ---
|
|
317
|
+
* - #### Supported versions:
|
|
318
|
+
* - #### **`"v4"` *(default)*** ➔ Fully random UUID, RFC 4122 compliant.
|
|
319
|
+
* - Uses `crypto.randomUUID()` if available.
|
|
320
|
+
* - Falls back to `crypto.getRandomValues()` or `Math.random()`
|
|
321
|
+
* if needed.
|
|
322
|
+
* ---
|
|
323
|
+
* - #### **`"v7"`** ➔ Time-ordered UUID, RFC 9562 compliant.
|
|
324
|
+
* - Timestamp (Unix ms, 48 bits) + 80 bits randomness.
|
|
325
|
+
* - Good for database indexing / sorting.
|
|
326
|
+
* ---
|
|
327
|
+
* - #### **`"v7"` + `monotonic: true`** ➔ Ensures strictly non-decreasing UUIDs
|
|
328
|
+
* for multiple calls in the same millisecond (per-process).
|
|
249
329
|
*
|
|
330
|
+
* ---
|
|
331
|
+
* - #### Behavior / Safety Notes:
|
|
332
|
+
* - **v4**: Fully random; probability of duplicates is astronomically low.
|
|
333
|
+
* - **v7**: Time-ordered; collisions extremely unlikely unless same ms + random repeat.
|
|
334
|
+
* - **Monotonic v7**: Guaranteed ordering per-process if multiple UUIDs are generated
|
|
335
|
+
* in the same millisecond.
|
|
336
|
+
* - **All versions**: Fallback safely if `crypto` APIs are unavailable.
|
|
337
|
+
*
|
|
338
|
+
* ---
|
|
250
339
|
* @param {object} [options] - Optional settings object.
|
|
251
340
|
* @param {"v4" | "v7"} [options.version="v4"] - UUID version to generate.
|
|
252
|
-
* @param {boolean} [options.monotonic=false] - For v7 only
|
|
341
|
+
* @param {boolean} [options.monotonic=false] - ***For v7 only***, generate monotonic UUIDs
|
|
253
342
|
* to maintain strict lexicographic order
|
|
254
343
|
* when generating multiple UUIDs within the same ms.
|
|
255
344
|
*
|
|
256
|
-
* @returns {string} A 36-character UUID string compliant with the selected version.
|
|
257
|
-
*
|
|
258
345
|
* @throws **{@link TypeError | `TypeError`}** if:
|
|
259
|
-
* - `options` is not a plain object.
|
|
260
346
|
* - `options.version` is provided but not a string.
|
|
261
347
|
* - `options.monotonic` is provided but not a boolean.
|
|
262
348
|
* - `monotonic: true` is used with `version` other than `"v7"`.
|
|
263
|
-
* @throws **{@link RangeError | `RangeError`}** if `options.version` is provided but not `"v4"` or `"v7"`.
|
|
264
|
-
*
|
|
265
|
-
* @example
|
|
266
|
-
* // Default (v4)
|
|
267
|
-
* const id = randomUUID();
|
|
268
|
-
* // ➔ "3b12f1df-5232-4804-897e-917bf397618a"
|
|
269
349
|
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
* const id4 = randomUUID({ version: "v4" });
|
|
273
|
-
*
|
|
274
|
-
* @example
|
|
275
|
-
* // Time-ordered v7
|
|
276
|
-
* const id7 = randomUUID({ version: "v7" });
|
|
277
|
-
* // ➔ "018f48d2-84c1-7ccd-b5a3-2f9463b3a889"
|
|
278
|
-
*
|
|
279
|
-
* @example
|
|
280
|
-
* // Monotonic v7
|
|
281
|
-
* const a = randomUUID({ version: "v7", monotonic: true });
|
|
282
|
-
* const b = randomUUID({ version: "v7", monotonic: true });
|
|
283
|
-
* // a < b lexicographically (guaranteed)
|
|
350
|
+
* ---
|
|
351
|
+
* @returns {string} A 36-character UUID string compliant with the selected version.
|
|
284
352
|
*
|
|
285
|
-
* @
|
|
286
|
-
* // Throws TypeError
|
|
287
|
-
* randomUUID("v4" as any); // options must be object
|
|
288
|
-
* randomUUID({ version: 123 as any }); // version must be string
|
|
289
|
-
* randomUUID({ version: "v4", monotonic: true } as any); // monotonic only for v7
|
|
353
|
+
* @throws **{@link RangeError | `RangeError`}** if `options.version` is provided but not `"v4"` or `"v7"`.
|
|
290
354
|
*
|
|
291
355
|
* @example
|
|
292
|
-
*
|
|
293
|
-
*
|
|
356
|
+
* 1. #### Default (v4):
|
|
357
|
+
* ```ts
|
|
358
|
+
* const id = randomUUID();
|
|
359
|
+
* // ➔ "xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx"
|
|
360
|
+
* ```
|
|
361
|
+
* ---
|
|
362
|
+
* 2. #### Explicit `v4`:
|
|
363
|
+
* ```ts
|
|
364
|
+
* const id4 = randomUUID({ version: "v4" });
|
|
365
|
+
* // ➔ "xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx"
|
|
366
|
+
* ```
|
|
367
|
+
* ---
|
|
368
|
+
* 3. #### Time-ordered `v7`:
|
|
369
|
+
* ```ts
|
|
370
|
+
* const id7 = randomUUID({ version: "v7" });
|
|
371
|
+
* // ➔ "xxxxxxxx-xxxx-7xxx-xxxx-xxxxxxxxxxxx"
|
|
372
|
+
* ```
|
|
373
|
+
* ---
|
|
374
|
+
* 4. #### Monotonic `v7`:
|
|
375
|
+
* ```ts
|
|
376
|
+
* const a = randomUUID({ version: "v7", monotonic: true });
|
|
377
|
+
* const b = randomUUID({ version: "v7", monotonic: true });
|
|
378
|
+
* // a < b lexicographically (guaranteed)
|
|
379
|
+
* ```
|
|
380
|
+
* ---
|
|
381
|
+
* - #### *Throws:*
|
|
382
|
+
* - #### `TypeError`:
|
|
383
|
+
* ```ts
|
|
384
|
+
* randomUUID({ version: 123 as any });
|
|
385
|
+
* // version must be string
|
|
386
|
+
* randomUUID({ version: "v4", monotonic: true } as any);
|
|
387
|
+
* // monotonic only for v7
|
|
388
|
+
* ```
|
|
389
|
+
* ---
|
|
390
|
+
* - #### `RangeError`:
|
|
391
|
+
* ```ts
|
|
392
|
+
* randomUUID({ version: "v1" as any });
|
|
393
|
+
* // unsupported version
|
|
394
|
+
* ```
|
|
294
395
|
*/
|
|
295
396
|
declare function randomUUID(options?: OptionsRandomUUID): string;
|
|
296
|
-
/**
|
|
297
|
-
* --------------------------------------------------
|
|
397
|
+
/** ------------------------------------------------------------------------------------
|
|
298
398
|
* * ***Utility: `noop`.***
|
|
299
|
-
*
|
|
399
|
+
* -------------------------------------------------------------------------------------
|
|
300
400
|
* **A no-operation function that performs no action.**
|
|
301
401
|
*
|
|
402
|
+
* ---
|
|
302
403
|
* @description
|
|
303
404
|
* Commonly used as a **placeholder**, **default callback**, or **stub function**.
|
|
304
405
|
*
|
|
406
|
+
* ---
|
|
305
407
|
* - **Behavior**:
|
|
306
|
-
*
|
|
307
|
-
*
|
|
408
|
+
* - Does not return any meaningful value (`void`).
|
|
409
|
+
* - Safely callable in any context without side effects.
|
|
308
410
|
*
|
|
411
|
+
* ---
|
|
309
412
|
* @remarks
|
|
310
413
|
* Although this function returns `void`, it implicitly results in `undefined`,
|
|
311
414
|
* but the return value should never be relied upon.
|
|
312
415
|
*
|
|
416
|
+
* ---
|
|
313
417
|
* @example
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
418
|
+
* 1. #### **Basic usage** — does nothing and returns undefined implicitly:
|
|
419
|
+
* ```
|
|
420
|
+
* import { noop } from "@rzl-zone/utils-js/generators";
|
|
317
421
|
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
422
|
+
* noop();
|
|
423
|
+
* // ➔ no effect (void)
|
|
424
|
+
* ```
|
|
425
|
+
* ---
|
|
426
|
+
* 2. #### **Using with type-checking helpers:**
|
|
427
|
+
* ```ts
|
|
428
|
+
* import { noop } from "@rzl-zone/utils-js/generators";
|
|
429
|
+
* import { isFunction, isUndefined } from "@rzl-zone/utils-js/predicates";
|
|
430
|
+
*
|
|
431
|
+
* isFunction(noop);
|
|
432
|
+
* // ➔ true (`noop` is a function)
|
|
433
|
+
* isUndefined(noop());
|
|
434
|
+
* // ➔ true (calling `noop()` returns `undefined`)
|
|
435
|
+
* isFunction(noop());
|
|
436
|
+
* // ➔ false (the return value is `undefined`, not a function)
|
|
437
|
+
* ```
|
|
438
|
+
* ---
|
|
439
|
+
* 3. #### **As a default callback:**
|
|
440
|
+
* ```ts
|
|
441
|
+
* import { noop } from "@rzl-zone/utils-js/generators";
|
|
334
442
|
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
443
|
+
* const callback = noop;
|
|
444
|
+
* callback();
|
|
445
|
+
* // ➔ no effect (void)
|
|
446
|
+
* ```
|
|
338
447
|
*/
|
|
339
448
|
declare const noop: () => void;
|
|
340
449
|
export { randomInt as a, randomIntByLength as i, randomUUID as n, getRandomItem as o, randomStr as r, noop as t };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
@@ -11,4 +11,4 @@ const isBigInt = (value) => {
|
|
|
11
11
|
return typeof value === "bigint";
|
|
12
12
|
};
|
|
13
13
|
export { isBigInt as t };
|
|
14
|
-
//# sourceMappingURL=isBigInt-
|
|
14
|
+
//# sourceMappingURL=isBigInt-Cez32M69.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isBigInt-Cez32M69.js","names":[],"sources":["../src/predicates/is/isBigInt.ts"],"sourcesContent":["/** ----------------------------------------------------------\n * * ***Type guard: `isBigInt`.***\n * -----------------------------------------------------------\n * **Checks if a value is of type **[`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)**.**\n *\n * ---\n * - **Behavior:**\n * - Uses `typeof value === \"bigint\"` for strict type checking.\n * - Supports TypeScript type narrowing with `value is bigint`.\n * - Returns `false` for `BigInt` object (object-wrapped), e.g:\n * - `Object(BigInt(123))`.\n *\n * ---\n * @param {*} value - The value to check.\n *\n * ---\n * @returns {boolean} Return `true` if value is a primitive bigint.\n *\n * ---\n * @example\n * isBigInt(123n);\n * // ➔ true\n * isBigInt(BigInt(123));\n * // ➔ true\n * isBigInt(\"123\");\n * // ➔ false\n * isBigInt(Object(BigInt(1)));\n * // ➔ false\n */\nexport const isBigInt = (value: unknown): value is bigint => {\n return typeof value === \"bigint\";\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,YAAY,UAAoC;CAC3D,OAAO,OAAO,UAAU;AAC1B"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
@@ -17,4 +17,4 @@ Object.defineProperty(exports, 'isBigInt', {
|
|
|
17
17
|
return isBigInt;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
//# sourceMappingURL=isBigInt-
|
|
20
|
+
//# sourceMappingURL=isBigInt-YgpNKTbA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isBigInt-YgpNKTbA.cjs","names":[],"sources":["../src/predicates/is/isBigInt.ts"],"sourcesContent":["/** ----------------------------------------------------------\n * * ***Type guard: `isBigInt`.***\n * -----------------------------------------------------------\n * **Checks if a value is of type **[`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)**.**\n *\n * ---\n * - **Behavior:**\n * - Uses `typeof value === \"bigint\"` for strict type checking.\n * - Supports TypeScript type narrowing with `value is bigint`.\n * - Returns `false` for `BigInt` object (object-wrapped), e.g:\n * - `Object(BigInt(123))`.\n *\n * ---\n * @param {*} value - The value to check.\n *\n * ---\n * @returns {boolean} Return `true` if value is a primitive bigint.\n *\n * ---\n * @example\n * isBigInt(123n);\n * // ➔ true\n * isBigInt(BigInt(123));\n * // ➔ true\n * isBigInt(\"123\");\n * // ➔ false\n * isBigInt(Object(BigInt(1)));\n * // ➔ false\n */\nexport const isBigInt = (value: unknown): value is bigint => {\n return typeof value === \"bigint\";\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,YAAY,UAAoC;CAC3D,OAAO,OAAO,UAAU;AAC1B"}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
11
|
-
const isEmptyString = (value, options
|
|
10
|
+
import { w as isNonEmptyString } from "./logger-CLWnKRKE.js";
|
|
11
|
+
const isEmptyString = (value, options) => {
|
|
12
12
|
return !isNonEmptyString(value, options);
|
|
13
13
|
};
|
|
14
14
|
export { isEmptyString as t };
|
|
15
|
-
//# sourceMappingURL=isEmptyString-
|
|
15
|
+
//# sourceMappingURL=isEmptyString-C9QLWjx2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEmptyString-C9QLWjx2.js","names":[],"sources":["../src/predicates/is/isEmptyString.ts"],"sourcesContent":["import { isNonEmptyString } from \"./isNonEmptyString\";\n\ntype IsEmptyStringOptions = {\n /** ----------------------------------------------------------\n * * ***Whether to trim leading and trailing whitespace before checking.***\n * -----------------------------------------------------------\n *\n * @note\n * Non-boolean values fall back to the default behavior.\n *\n * ---\n * @default true\n */\n trim?: boolean;\n};\n\n/** ----------------------------------------------------------\n * * ***Predicate: `isEmptyString`.***\n * -----------------------------------------------------------\n * **Checks whether a given value is an **empty-string**.**\n *\n * ---\n * - **Behavior:**\n * - Considers `\"\"` and whitespace-only strings as\n * empty (if `trim` is enabled, which is the default).\n * - Non-string inputs are also considered empty.\n *\n * ---\n * @param {*} value - The value to check.\n * @param {IsEmptyStringOptions} [options]\n * Optional settings (non-plain object values are ignored and replaced with default options).\n * @param {IsEmptyStringOptions[\"trim\"]} [options.trim=true]\n * If `true`, trims the string before checking (non-boolean values fall back to the default behavior), defaults: `true`.\n *\n * ---\n * @returns {boolean} Returns `true` if the value is string not a string or value string is considered empty.\n *\n * ---\n * @example\n * isEmptyString(\"\");\n * // ➔ true\n * isEmptyString(\" \");\n * // ➔ true (default trims)\n * isEmptyString(\" \", { trim: false });\n * // ➔ false\n * isEmptyString(\"hello\");\n * // ➔ false\n * isEmptyString(undefined);\n * // ➔ true\n * isEmptyString(null);\n * // ➔ true\n * isEmptyString(123 as any);\n * // ➔ true\n *\n * // Used in validation\n * if (isEmptyString(form.name)) {\n * throw new Error(\"Name cannot be empty.\");\n * }\n */\nexport const isEmptyString = (\n value: unknown,\n options?: IsEmptyStringOptions\n): boolean => {\n return !isNonEmptyString(value, options);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAa,iBACX,OACA,YACY;CACZ,OAAO,CAAC,iBAAiB,OAAO,OAAO;AACzC"}
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
|
-
const
|
|
12
|
-
const isEmptyString = (value, options
|
|
13
|
-
return !
|
|
11
|
+
const require_logger = require('./logger-CUacYy3D.cjs');
|
|
12
|
+
const isEmptyString = (value, options) => {
|
|
13
|
+
return !require_logger.isNonEmptyString(value, options);
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, 'isEmptyString', {
|
|
16
16
|
enumerable: true,
|
|
@@ -18,4 +18,4 @@ Object.defineProperty(exports, 'isEmptyString', {
|
|
|
18
18
|
return isEmptyString;
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
|
-
//# sourceMappingURL=isEmptyString-
|
|
21
|
+
//# sourceMappingURL=isEmptyString-O4TFe1Ao.cjs.map
|