@rzl-zone/utils-js 3.13.1 → 3.14.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-CgE6QNOR.js +20 -0
- package/dist/AbortError-CgE6QNOR.js.map +1 -0
- package/dist/AbortError-D54txsmn.cjs +26 -0
- package/dist/AbortError-D54txsmn.cjs.map +1 -0
- package/dist/{assertIsArray-HgzPQIAM.js → assertIsArray-DmlqnTiq.js} +3 -3
- package/dist/assertIsArray-DmlqnTiq.js.map +1 -0
- package/dist/{assertIsArray-CeXL4xv5.cjs → assertIsArray-Xx-zlo6O.cjs} +5 -5
- package/dist/assertIsArray-Xx-zlo6O.cjs.map +1 -0
- package/dist/assertIsPlainObject-CIzDchLs.js +20 -0
- package/dist/assertIsPlainObject-CIzDchLs.js.map +1 -0
- package/dist/assertIsPlainObject-DYoxHcW5.cjs +26 -0
- package/dist/assertIsPlainObject-DYoxHcW5.cjs.map +1 -0
- package/dist/{assertIsString-DUrVt82d.cjs → assertIsString-CuPbh3FB.cjs} +6 -6
- package/dist/assertIsString-CuPbh3FB.cjs.map +1 -0
- package/dist/{assertIsString-CY_WkCLr.js → assertIsString-sgY3ml5f.js} +4 -4
- package/dist/assertIsString-sgY3ml5f.js.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-1s7xMBe_.js → conversions-BkxqYXxy.js} +43 -40
- package/dist/conversions-BkxqYXxy.js.map +1 -0
- package/dist/conversions-UdMB90xR.cjs +449 -0
- package/dist/conversions-UdMB90xR.cjs.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-BFgV1HhV-BtIJs2H2.js +55 -0
- package/dist/formatter-BFgV1HhV-BtIJs2H2.js.map +1 -0
- package/dist/formatter-BFgV1HhV-DyybWSuj.cjs +67 -0
- package/dist/formatter-BFgV1HhV-DyybWSuj.cjs.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-Cjng28nY.cjs +436 -0
- package/dist/formatters-Cjng28nY.cjs.map +1 -0
- package/dist/{formatters-C6cVZBbG.js → formatters-Dqccnt-p.js} +78 -71
- package/dist/formatters-Dqccnt-p.js.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-DTWYqy7S.cjs +53 -0
- package/dist/hasOwnProp-DTWYqy7S.cjs.map +1 -0
- package/dist/hasOwnProp-yVVsxPin.js +47 -0
- package/dist/hasOwnProp-yVVsxPin.js.map +1 -0
- package/dist/{index-BG8wdusZ.d.cts → index-9Ql1W3gt.d.cts} +229 -200
- package/dist/{index-RNQBTK8A.d.cts → index-BD0J8wkE.d.cts} +1374 -936
- package/dist/index-BcoUy2oV.d.ts +2424 -0
- package/dist/{index-B5EBAgmC.d.cts → index-Bpk3YwGW.d.ts} +1592 -790
- package/dist/index-CTMG8cZV.d.ts +1041 -0
- package/dist/index-DUBCXPy4.d.cts +1041 -0
- package/dist/{index-CRz9rSZL.d.ts → index-DhUTzQ_o.d.ts} +1374 -936
- package/dist/{index-B1VQ6USF.d.ts → index-DqYMKSmd.d.ts} +229 -200
- package/dist/index-JfwSupYB.d.ts +1103 -0
- package/dist/{index-ORbo-7zA.d.cts → index-O2q2f-pu.d.cts} +242 -133
- package/dist/{index-DPJ-e2JZ.d.ts → index-VgNZ6ndx.d.cts} +1592 -790
- package/dist/{index-ORbo-7zA.d.ts → index-k_rjVRjU.d.ts} +242 -133
- package/dist/index-or0oP9i2.d.cts +2179 -0
- package/dist/index-or0oP9i2.d.ts +2179 -0
- package/dist/index-u4-Euidh.d.cts +1103 -0
- package/dist/index-zAqCZxGr.d.cts +2424 -0
- package/dist/{isBigInt-y7s3rsKc.js → isBigInt-DdFRCpeE.js} +2 -2
- package/dist/isBigInt-DdFRCpeE.js.map +1 -0
- package/dist/{isBigInt-BVj0M5pq.cjs → isBigInt-LkCpVJ3E.cjs} +2 -2
- package/dist/isBigInt-LkCpVJ3E.cjs.map +1 -0
- package/dist/{isEmptyString-BYMz_wt9.js → isEmptyString-B6ubItgT.js} +4 -4
- package/dist/isEmptyString-B6ubItgT.js.map +1 -0
- package/dist/{isEmptyString-C8PYNPgw.cjs → isEmptyString-Csc5Sf_W.cjs} +5 -5
- package/dist/isEmptyString-Csc5Sf_W.cjs.map +1 -0
- package/dist/isEmptyValue-h97JT4pD.js +36 -0
- package/dist/isEmptyValue-h97JT4pD.js.map +1 -0
- package/dist/isEmptyValue-qNOhUBFE.cjs +54 -0
- package/dist/isEmptyValue-qNOhUBFE.cjs.map +1 -0
- package/dist/{isFinite-DeDaBDr2.cjs → isFinite-CKeuVXbD.cjs} +6 -6
- package/dist/isFinite-CKeuVXbD.cjs.map +1 -0
- package/dist/{isFinite-BEJFOv6B.js → isFinite-CzYYv-mQ.js} +5 -5
- package/dist/isFinite-CzYYv-mQ.js.map +1 -0
- package/dist/{isInteger-DEDbBGez.js → isInteger-BtA3flbk.js} +4 -4
- package/dist/isInteger-BtA3flbk.js.map +1 -0
- package/dist/{isInteger-CQLThJOR.cjs → isInteger-iTok9NaH.cjs} +4 -4
- package/dist/isInteger-iTok9NaH.cjs.map +1 -0
- package/dist/isNumber-C1mOuBuA.js +20 -0
- package/dist/isNumber-C1mOuBuA.js.map +1 -0
- package/dist/isNumber-CM1vdNcW.cjs +26 -0
- package/dist/isNumber-CM1vdNcW.cjs.map +1 -0
- package/dist/isPlainObject-DQoM4DGQ.d.ts +331 -0
- package/dist/isPlainObject-Y__iykWN.d.cts +331 -0
- package/dist/{isServer-DmycqWsF.cjs → isServer-CWlp2R2N.cjs} +2 -2
- package/dist/isServer-CWlp2R2N.cjs.map +1 -0
- package/dist/{isServer-q3o6cSwD.js → isServer-Drgyboev.js} +2 -2
- package/dist/isServer-Drgyboev.js.map +1 -0
- package/dist/{isEqual-DM4S_kWh.js → isTypedArray-BY8CIj3k.js} +29 -9
- package/dist/isTypedArray-BY8CIj3k.js.map +1 -0
- package/dist/{isEqual-DaPDxMyw.cjs → isTypedArray-DspIjxdk.cjs} +45 -13
- package/dist/isTypedArray-DspIjxdk.cjs.map +1 -0
- package/dist/{isValidDomain-B8Nukgw0.js → isValidDomain-BPfJEkFk.js} +13 -54
- package/dist/isValidDomain-BPfJEkFk.js.map +1 -0
- package/dist/{isValidDomain-ZbyeGOO9.cjs → isValidDomain-DUUCoKtD.cjs} +16 -69
- package/dist/isValidDomain-DUUCoKtD.cjs.map +1 -0
- package/dist/{assertIsBoolean-D41HrTB_.cjs → logger-BXg2xufj.cjs} +658 -612
- package/dist/logger-BXg2xufj.cjs.map +1 -0
- package/dist/{assertIsBoolean-CWUs-I5l.js → logger-Wxl_Krg6.js} +657 -587
- package/dist/logger-Wxl_Krg6.js.map +1 -0
- package/dist/{noop-BY43WaoU.cjs → noop-ByxeOveJ.cjs} +2 -2
- package/dist/noop-ByxeOveJ.cjs.map +1 -0
- package/dist/{noop-CjY8xVHv.js → noop-D8aGbjbP.js} +2 -2
- package/dist/noop-D8aGbjbP.js.map +1 -0
- package/dist/{normalizeSpaces-BhZp0U_6.cjs → normalizeSpaces-CQ7tZLNG.cjs} +6 -9
- package/dist/normalizeSpaces-CQ7tZLNG.cjs.map +1 -0
- package/dist/{normalizeSpaces-BoUDtq5P.js → normalizeSpaces-DNUOxp_8.js} +4 -7
- package/dist/normalizeSpaces-DNUOxp_8.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-B_FPX35n.cjs → parsers-CJ5tHtqF.cjs} +10 -9
- package/dist/parsers-CJ5tHtqF.cjs.map +1 -0
- package/dist/{parsers-B8KYXIjE.js → parsers-DMlqliPw.js} +9 -8
- package/dist/parsers-DMlqliPw.js.map +1 -0
- package/dist/{parsing-BCZGco7n.cjs → parsing-DB_S0WFz.cjs} +4 -4
- package/dist/parsing-DB_S0WFz.cjs.map +1 -0
- package/dist/{parsing-Bfaw85Hd.js → parsing-DhIQhWpX.js} +3 -3
- package/dist/parsing-DhIQhWpX.js.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-KlyOvBSC.js → predicates-BzYMbNrZ.js} +45 -40
- package/dist/predicates-BzYMbNrZ.js.map +1 -0
- package/dist/{predicates-8y28VrbT.cjs → predicates-DDW3etqF.cjs} +89 -84
- package/dist/predicates-DDW3etqF.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-DnKi0qjS.cjs → punyCode-B_VPjG0d.cjs} +12 -12
- package/dist/punyCode-B_VPjG0d.cjs.map +1 -0
- package/dist/{punyCode-Dwto1RpA.js → punyCode-DsuJbWCl.js} +12 -12
- package/dist/punyCode-DsuJbWCl.js.map +1 -0
- package/dist/{removeSpaces--8NW-HSx.js → removeSpaces-BF-T_1Yt.js} +4 -4
- package/dist/removeSpaces-BF-T_1Yt.js.map +1 -0
- package/dist/{removeSpaces-CmrrkeXz.cjs → removeSpaces-BJu-gKps.cjs} +7 -7
- package/dist/removeSpaces-BJu-gKps.cjs.map +1 -0
- package/dist/rzl-utils.global.js +13 -13
- package/dist/safeJsonParse-B5F8XtrZ.cjs +209 -0
- package/dist/safeJsonParse-B5F8XtrZ.cjs.map +1 -0
- package/dist/{safeJsonParse-OnUwG2El.js → safeJsonParse-DYSkUnhM.js} +29 -28
- package/dist/safeJsonParse-DYSkUnhM.js.map +1 -0
- package/dist/{safeStableStringify-B2KTTS3r.js → safeStableStringify-CDSYnLUz.js} +20 -13
- package/dist/safeStableStringify-CDSYnLUz.js.map +1 -0
- package/dist/safeStableStringify-MuBiT-4B.cjs +125 -0
- package/dist/safeStableStringify-MuBiT-4B.cjs.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-CUdmv-oO.js → tailwind-BhHULklj.js} +38 -32
- package/dist/tailwind-BhHULklj.js.map +1 -0
- package/dist/{tailwind-DUuboq52.cjs → tailwind-hx6TIFIL.cjs} +59 -53
- package/dist/tailwind-hx6TIFIL.cjs.map +1 -0
- package/dist/{toStringArrayUnRecursive-OOHGazks.js → toStringArrayUnRecursive-U-nkEIDs.js} +9 -9
- package/dist/toStringArrayUnRecursive-U-nkEIDs.js.map +1 -0
- package/dist/toStringArrayUnRecursive-_lJEmBlf.cjs +51 -0
- package/dist/toStringArrayUnRecursive-_lJEmBlf.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-BXT4Krsq.js → urls-BcGIFgfR.js} +50 -41
- package/dist/urls-BcGIFgfR.js.map +1 -0
- package/dist/urls-DGvZsMSN.cjs +308 -0
- package/dist/urls-DGvZsMSN.cjs.map +1 -0
- package/package.json +6 -6
- package/dist/assertIsArray-CeXL4xv5.cjs.map +0 -1
- package/dist/assertIsArray-HgzPQIAM.js.map +0 -1
- package/dist/assertIsBoolean-CWUs-I5l.js.map +0 -1
- package/dist/assertIsBoolean-D41HrTB_.cjs.map +0 -1
- package/dist/assertIsString-CY_WkCLr.js.map +0 -1
- package/dist/assertIsString-DUrVt82d.cjs.map +0 -1
- package/dist/conversions-1s7xMBe_.js.map +0 -1
- package/dist/conversions-B3Rf8uId.cjs +0 -446
- package/dist/conversions-B3Rf8uId.cjs.map +0 -1
- package/dist/formatters-C6cVZBbG.js.map +0 -1
- package/dist/formatters-aEAAuzjx.cjs +0 -429
- package/dist/formatters-aEAAuzjx.cjs.map +0 -1
- package/dist/index-CPCt6_Wq.d.cts +0 -765
- package/dist/index-CPCt6_Wq.d.ts +0 -765
- package/dist/index-DBwNa1iO.d.ts +0 -947
- package/dist/index-DPTYOQkn.d.cts +0 -947
- package/dist/index-Dig1fIhZ.d.cts +0 -1716
- package/dist/index-Dig1fIhZ.d.ts +0 -1716
- package/dist/isBigInt-BVj0M5pq.cjs.map +0 -1
- package/dist/isBigInt-y7s3rsKc.js.map +0 -1
- package/dist/isEmptyObject-BsHngDz4.cjs +0 -37
- package/dist/isEmptyObject-BsHngDz4.cjs.map +0 -1
- package/dist/isEmptyObject-DPGR9iPj.js +0 -25
- package/dist/isEmptyObject-DPGR9iPj.js.map +0 -1
- package/dist/isEmptyString-BYMz_wt9.js.map +0 -1
- package/dist/isEmptyString-C8PYNPgw.cjs.map +0 -1
- package/dist/isEmptyValue-BXf7f1jz.cjs +0 -30
- package/dist/isEmptyValue-BXf7f1jz.cjs.map +0 -1
- package/dist/isEmptyValue-D4OHTB3u.js +0 -24
- package/dist/isEmptyValue-D4OHTB3u.js.map +0 -1
- package/dist/isEqual-DM4S_kWh.js.map +0 -1
- package/dist/isEqual-DaPDxMyw.cjs.map +0 -1
- package/dist/isFinite-BEJFOv6B.js.map +0 -1
- package/dist/isFinite-DeDaBDr2.cjs.map +0 -1
- package/dist/isInteger-CQLThJOR.cjs.map +0 -1
- package/dist/isInteger-DEDbBGez.js.map +0 -1
- package/dist/isPlainObject-BwTkj3G0.d.cts +0 -339
- package/dist/isPlainObject-BwTkj3G0.d.ts +0 -339
- package/dist/isServer-DmycqWsF.cjs.map +0 -1
- package/dist/isServer-q3o6cSwD.js.map +0 -1
- package/dist/isTypedArray-BQLbLXsU.cjs +0 -43
- package/dist/isTypedArray-BQLbLXsU.cjs.map +0 -1
- package/dist/isTypedArray-XiBnifLN.js +0 -31
- package/dist/isTypedArray-XiBnifLN.js.map +0 -1
- package/dist/isValidDomain-B8Nukgw0.js.map +0 -1
- package/dist/isValidDomain-ZbyeGOO9.cjs.map +0 -1
- package/dist/noop-BY43WaoU.cjs.map +0 -1
- package/dist/noop-CjY8xVHv.js.map +0 -1
- package/dist/normalizeSpaces-BhZp0U_6.cjs.map +0 -1
- package/dist/normalizeSpaces-BoUDtq5P.js.map +0 -1
- package/dist/parsers-B8KYXIjE.js.map +0 -1
- package/dist/parsers-B_FPX35n.cjs.map +0 -1
- package/dist/parsing-BCZGco7n.cjs.map +0 -1
- package/dist/parsing-Bfaw85Hd.js.map +0 -1
- package/dist/predicates-8y28VrbT.cjs.map +0 -1
- package/dist/predicates-KlyOvBSC.js.map +0 -1
- package/dist/punyCode-DnKi0qjS.cjs.map +0 -1
- package/dist/punyCode-Dwto1RpA.js.map +0 -1
- package/dist/removeSpaces--8NW-HSx.js.map +0 -1
- package/dist/removeSpaces-CmrrkeXz.cjs.map +0 -1
- package/dist/safeJsonParse-OnUwG2El.js.map +0 -1
- package/dist/safeJsonParse-sFqVXf-e.cjs +0 -208
- package/dist/safeJsonParse-sFqVXf-e.cjs.map +0 -1
- package/dist/safeStableStringify-B2KTTS3r.js.map +0 -1
- package/dist/safeStableStringify-Cmi6GyWj.cjs +0 -106
- package/dist/safeStableStringify-Cmi6GyWj.cjs.map +0 -1
- package/dist/tailwind-CUdmv-oO.js.map +0 -1
- package/dist/tailwind-DUuboq52.cjs.map +0 -1
- package/dist/toStringArrayUnRecursive-OOHGazks.js.map +0 -1
- package/dist/toStringArrayUnRecursive-pfk2oP8C.cjs +0 -51
- package/dist/toStringArrayUnRecursive-pfk2oP8C.cjs.map +0 -1
- package/dist/urls-BL9C_yU3.cjs +0 -299
- package/dist/urls-BL9C_yU3.cjs.map +0 -1
- package/dist/urls-BXT4Krsq.js.map +0 -1
|
@@ -2,28 +2,222 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.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 { NumberRangeUnion } from "
|
|
11
|
+
import { D as NumberRangeUnion } from "../index-or0oP9i2.cjs";
|
|
12
|
+
type CopyMethod = "clipboard" | "fallback" | "manual";
|
|
13
|
+
type CopyStatus = "success" | "error";
|
|
14
|
+
type CopyResult = {
|
|
15
|
+
/** ---------------------------------------------------------
|
|
16
|
+
* * ***Final operation status.***
|
|
17
|
+
* ----------------------------------------------------------
|
|
18
|
+
*
|
|
19
|
+
* ---
|
|
20
|
+
* Usually `"success"` when copy succeeds, otherwise `"error"`.
|
|
21
|
+
*/
|
|
22
|
+
status: CopyStatus;
|
|
23
|
+
/** ---------------------------------------------------------
|
|
24
|
+
* * ***Indicates whether the operation succeeded.***
|
|
25
|
+
* ----------------------------------------------------------
|
|
26
|
+
*
|
|
27
|
+
* Usually `true` on successful copy operations.
|
|
28
|
+
*/
|
|
29
|
+
success: boolean;
|
|
30
|
+
/** ---------------------------------------------------------
|
|
31
|
+
* * ***Copy mechanism that was used.***
|
|
32
|
+
* ----------------------------------------------------------
|
|
33
|
+
*
|
|
34
|
+
* - **Possible values:**
|
|
35
|
+
* - `"clipboard"`.
|
|
36
|
+
* - `"fallback"`.
|
|
37
|
+
* - `"manual"`.
|
|
38
|
+
*/
|
|
39
|
+
method: CopyMethod;
|
|
40
|
+
/**
|
|
41
|
+
* * ***Optional error object captured during execution.***
|
|
42
|
+
*/
|
|
43
|
+
error?: unknown;
|
|
44
|
+
/** ---------------------------------------------------------
|
|
45
|
+
* * ***Optional failure or fallback reason.***
|
|
46
|
+
* ----------------------------------------------------------
|
|
47
|
+
*
|
|
48
|
+
* - **Possible values:**
|
|
49
|
+
* - `"no-browser"`.
|
|
50
|
+
* - `"no-clipboard"`.
|
|
51
|
+
* - `"clipboard-error"`.
|
|
52
|
+
* - `"timeout"`.
|
|
53
|
+
* - `"fallback-failed"`.
|
|
54
|
+
*/
|
|
55
|
+
reason?: "no-browser" | "no-clipboard" | "clipboard-error" | "timeout" | "fallback-failed";
|
|
56
|
+
/**
|
|
57
|
+
* * ***Total number of attempts performed.***
|
|
58
|
+
*/
|
|
59
|
+
attempts: number;
|
|
60
|
+
/**
|
|
61
|
+
* * ***Total execution duration in milliseconds.***
|
|
62
|
+
*/
|
|
63
|
+
duration: number;
|
|
64
|
+
/**
|
|
65
|
+
* * ***Unix timestamp of execution completion.***
|
|
66
|
+
*/
|
|
67
|
+
timestamp: number;
|
|
68
|
+
};
|
|
69
|
+
/** ----------------------------------------------------------------------
|
|
70
|
+
* * ***Type: `CopyOptions`.***
|
|
71
|
+
* -----------------------------------------------------------------------
|
|
72
|
+
* **Configuration options for the `copyText` utility.**
|
|
73
|
+
*
|
|
74
|
+
* ---
|
|
75
|
+
* - **Behavior:**
|
|
76
|
+
* - Controls retry attempts and timeout handling.
|
|
77
|
+
* - Enables optional debug logging.
|
|
78
|
+
* - All properties are optional.
|
|
79
|
+
*/
|
|
80
|
+
type CopyOptions = {
|
|
81
|
+
/** -----------------------------------------------------------------------
|
|
82
|
+
* * ***Enables internal debug logging.***
|
|
83
|
+
* ------------------------------------------------------------------------
|
|
84
|
+
*
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
87
|
+
debug?: boolean;
|
|
88
|
+
/** -----------------------------------------------------------------------
|
|
89
|
+
* * ***Number of retry attempts before fallback.***
|
|
90
|
+
* ------------------------------------------------------------------------
|
|
91
|
+
*
|
|
92
|
+
* @default 1
|
|
93
|
+
*/
|
|
94
|
+
retries?: number;
|
|
95
|
+
/** -----------------------------------------------------------------------
|
|
96
|
+
* * ***Timeout duration (in milliseconds) for each Clipboard API attempt.***
|
|
97
|
+
* ------------------------------------------------------------------------
|
|
98
|
+
*
|
|
99
|
+
* @default 2000
|
|
100
|
+
*/
|
|
101
|
+
timeout?: number;
|
|
102
|
+
};
|
|
103
|
+
/** ----------------------------------------------------------------------
|
|
104
|
+
* * ***Utility: `copyText`.***
|
|
105
|
+
* -----------------------------------------------------------------------
|
|
106
|
+
* **Copies text to the user's clipboard with robust fallback handling.**
|
|
107
|
+
*
|
|
108
|
+
* ---
|
|
109
|
+
* - **Behavior:**
|
|
110
|
+
* - Attempts to use the modern
|
|
111
|
+
* ***`navigator.clipboard.writeText`*** Clipboard API.
|
|
112
|
+
* - Automatically retries clipboard operations when configured.
|
|
113
|
+
* - Falls back to legacy
|
|
114
|
+
* ***`document.execCommand("copy")`***
|
|
115
|
+
* if the Clipboard API is unavailable or fails.
|
|
116
|
+
* - As a last resort, programmatically selects the text
|
|
117
|
+
* to allow manual copying by the user.
|
|
118
|
+
* - Detects non-browser environments and safely exits
|
|
119
|
+
* without accessing browser-only APIs.
|
|
120
|
+
* - Returns detailed operation metadata including method,
|
|
121
|
+
* duration, attempts, and failure reason.
|
|
122
|
+
* - Does **not throw** on copy failure;
|
|
123
|
+
* instead returns a structured
|
|
124
|
+
* ***{@link CopyResult | `CopyResult`}*** object.
|
|
125
|
+
*
|
|
126
|
+
* ---
|
|
127
|
+
* @param {string} text
|
|
128
|
+
* The text content to copy to the clipboard.
|
|
129
|
+
*
|
|
130
|
+
* @param {CopyOptions} [options={}]
|
|
131
|
+
* Optional configuration object.
|
|
132
|
+
*
|
|
133
|
+
* @param {boolean} [options.debug=false]
|
|
134
|
+
* Enables internal debug logging.
|
|
135
|
+
*
|
|
136
|
+
* @param {number} [options.retries=1]
|
|
137
|
+
* Number of additional retry attempts
|
|
138
|
+
* after the initial Clipboard API attempt.
|
|
139
|
+
*
|
|
140
|
+
* @param {number} [options.timeout=2000]
|
|
141
|
+
* Timeout duration (in milliseconds)
|
|
142
|
+
* for each Clipboard API attempt.
|
|
143
|
+
*
|
|
144
|
+
* ---
|
|
145
|
+
* @returns {Promise<CopyResult>}
|
|
146
|
+
* A promise resolving to a
|
|
147
|
+
* ***{@link CopyResult | `CopyResult`}*** object containing:
|
|
148
|
+
* - `status` ➔ `"success"` or `"error"`.
|
|
149
|
+
* - `success` ➔ Indicates whether the operation succeeded.
|
|
150
|
+
* - `method` ➔ Copy mechanism used
|
|
151
|
+
* (`"clipboard"`, `"fallback"`, or `"manual"`).
|
|
152
|
+
* - `reason` ➔ Optional failure or fallback reason.
|
|
153
|
+
* - `error` ➔ Optional thrown error object.
|
|
154
|
+
* - `attempts` ➔ Total number of attempts performed.
|
|
155
|
+
* - `duration` ➔ Execution duration in milliseconds.
|
|
156
|
+
* - `timestamp` ➔ Unix timestamp of execution.
|
|
157
|
+
*
|
|
158
|
+
* ---
|
|
159
|
+
* @remarks
|
|
160
|
+
* - The Clipboard API requires a secure context
|
|
161
|
+
* (`HTTPS` or `localhost`).
|
|
162
|
+
* - Some browsers or mobile environments may restrict
|
|
163
|
+
* clipboard access without direct user interaction.
|
|
164
|
+
* - Clipboard operations may fail due to browser permission
|
|
165
|
+
* policies or missing user interaction.
|
|
166
|
+
* - Manual selection mode is only triggered when all
|
|
167
|
+
* programmatic copy strategies fail.
|
|
168
|
+
* - In server-side environments,
|
|
169
|
+
* the utility returns `"no-browser"`
|
|
170
|
+
* without attempting DOM access.
|
|
171
|
+
*
|
|
172
|
+
* ---
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* const result = await copyText("Hello world");
|
|
176
|
+
*
|
|
177
|
+
* if (result.success) {
|
|
178
|
+
* console.log(`Copied using ${result.method}`);
|
|
179
|
+
* } else {
|
|
180
|
+
* console.error(result.reason);
|
|
181
|
+
* }
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* ---
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* await copyText("Debug mode", {
|
|
188
|
+
* debug: true,
|
|
189
|
+
* retries: 2
|
|
190
|
+
* });
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
declare function copyText(text: string, options?: CopyOptions): Promise<CopyResult>;
|
|
12
194
|
/** ----------------------------------------------------------------------
|
|
13
195
|
* * ***Utility: `findDuplicates`.***
|
|
14
|
-
*
|
|
196
|
+
* -----------------------------------------------------------------------
|
|
15
197
|
* **Finds duplicate values in an array by deep equality comparison.**
|
|
198
|
+
*
|
|
199
|
+
* ---
|
|
16
200
|
* - **Behavior:**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
201
|
+
* - Uses ***`isEqual` utility function*** to compare elements
|
|
202
|
+
* (handles objects, arrays, dates, NaN, etc.).
|
|
203
|
+
* - Returns a new array containing only the *first occurrences* of duplicated values.
|
|
204
|
+
* - Does **not mutate** the original array.
|
|
205
|
+
* - Throws ***{@link TypeError | `TypeError`}*** if input is not an array.
|
|
206
|
+
*
|
|
207
|
+
* ---
|
|
22
208
|
* @template T Type of elements in the input array.
|
|
209
|
+
*
|
|
210
|
+
* ---
|
|
23
211
|
* @param {T[]} values - The array to check for duplicates.
|
|
212
|
+
*
|
|
213
|
+
* ---
|
|
214
|
+
* @throws **{@link TypeError | `TypeError`}** if the provided `values` argument is not an array.
|
|
215
|
+
*
|
|
216
|
+
* ---
|
|
24
217
|
* @returns {T[]} An array of the duplicate values found in the input,
|
|
25
218
|
* preserving order of their first duplicate appearance.
|
|
26
|
-
*
|
|
219
|
+
*
|
|
220
|
+
* ---
|
|
27
221
|
* @example
|
|
28
222
|
* findDuplicates([1, 2, 2, 3, 4, 4]);
|
|
29
223
|
* // ➔ [2, 4]
|
|
@@ -39,62 +233,90 @@ import { NumberRangeUnion } from "@rzl-zone/ts-types-plus";
|
|
|
39
233
|
* // ➔ []
|
|
40
234
|
*/
|
|
41
235
|
declare const findDuplicates: <T>(values: T[]) => T[];
|
|
42
|
-
/**
|
|
236
|
+
/** -------------------------------------------------------------------------------
|
|
43
237
|
* * ***Utility: `omitKeys`.***
|
|
44
|
-
*
|
|
238
|
+
* --------------------------------------------------------------------------------
|
|
45
239
|
* **This function creates a shallow copy of the given object omitting the
|
|
46
240
|
* specified keys.**
|
|
241
|
+
*
|
|
242
|
+
* ---
|
|
47
243
|
* - **Behavior:**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
244
|
+
* - It will return a new object without mutating the original.
|
|
245
|
+
* - It also validates that ***`keysToOmit`*** does not contain duplicate keys.
|
|
246
|
+
*
|
|
247
|
+
* ---
|
|
248
|
+
* - **Internally:**
|
|
249
|
+
* - It uses ***`isEqual`*** to check for duplicates in
|
|
250
|
+
* the ***`keysToOmit`*** array.
|
|
251
|
+
*
|
|
252
|
+
* ---
|
|
53
253
|
* @template I The type of the input object.
|
|
54
254
|
* @template K The keys to omit from the object.
|
|
255
|
+
*
|
|
256
|
+
* ---
|
|
55
257
|
* @param {I} object - The source object to omit keys from.
|
|
56
258
|
* @param {K[]} keysToOmit - An array of keys to exclude from the returned object.
|
|
57
|
-
*
|
|
259
|
+
*
|
|
260
|
+
* ---
|
|
58
261
|
* @throws **{@link TypeError | `TypeError`}** if `keysToOmit` is not an array.
|
|
59
262
|
* @throws **{@link Error | `Error`}** if duplicate keys are found in `keysToOmit`.
|
|
263
|
+
*
|
|
264
|
+
* ---
|
|
265
|
+
* @returns {Omit<I, K>} A new object without the specified keys.
|
|
266
|
+
*
|
|
267
|
+
* ---
|
|
60
268
|
* @example
|
|
61
269
|
* omitKeys({ a: 1, b: 2, c: 3 }, ["b", "c"]);
|
|
62
|
-
*
|
|
270
|
+
* // ➔ { a: 1 }
|
|
63
271
|
* omitKeys({ name: "John", age: 30 }, ["age"]);
|
|
64
|
-
*
|
|
272
|
+
* // ➔ { name: "John" }
|
|
65
273
|
* omitKeys({ a: 1, b: 2 }, []);
|
|
66
|
-
*
|
|
274
|
+
* // ➔ { a: 1, b: 2 } (no changes)
|
|
67
275
|
*/
|
|
68
276
|
declare const omitKeys: <I extends Record<string, unknown>, K extends keyof I>(object: I, keysToOmit: K[]) => Omit<I, K>;
|
|
69
277
|
type IndexArray = NumberRangeUnion<0, 30>;
|
|
70
278
|
type DotPath<T, Prev extends string = ""> = T extends Array<infer U> ? DotPath<U, `${Prev}${Prev extends "" ? "" : "."}${IndexArray}`> : T extends object ? { [K in keyof T & string]: `${Prev}${Prev extends "" ? "" : "."}${K}` | DotPath<T[K], `${Prev}${Prev extends "" ? "" : "."}${K}`> }[keyof T & string] : never;
|
|
71
279
|
/** ------------------------------------------------------
|
|
72
280
|
* * ***Utility: `omitKeysDeep`.***
|
|
73
|
-
*
|
|
281
|
+
* -------------------------------------------------------
|
|
74
282
|
* **Recursively omits properties from an object using dot notation paths.**
|
|
283
|
+
*
|
|
284
|
+
* ---
|
|
75
285
|
* - **Behavior:**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
286
|
+
* - Removes resulting empty objects (`{}`) and arrays (`[]`), cascading upwards
|
|
287
|
+
* to remove empty parents until root if needed.
|
|
288
|
+
* ---
|
|
289
|
+
* - **Be careful:**
|
|
290
|
+
* - If after omission an object or array becomes empty, it will be removed entirely
|
|
291
|
+
* including all the way up to the root if necessary, resulting in `{}`.
|
|
292
|
+
* ---
|
|
293
|
+
* - **Note:**
|
|
294
|
+
* - For array indices, TypeScript autocomplete only suggests `0`–`30`
|
|
295
|
+
* (to prevent editor lag on large unions).
|
|
296
|
+
* However, higher indices are still fully supported at runtime — you can
|
|
297
|
+
* manually type `"arr.99.key"` and it will work the same.
|
|
298
|
+
*
|
|
299
|
+
* ---
|
|
300
|
+
* @template I - Type of the input object.
|
|
301
|
+
*
|
|
302
|
+
* ---
|
|
87
303
|
* @param {I} object
|
|
88
304
|
* The object to process, should be a plain nested object or array structure.
|
|
89
305
|
* @param {DotPath<I>[]} keysToOmit
|
|
90
306
|
* An array of string paths in dot notation indicating the properties to remove, paths
|
|
91
307
|
* can include numeric indices to target array elements, e.g. `"arr.0.x"` to
|
|
92
308
|
* remove `x` from the first object inside the `arr` array.
|
|
309
|
+
*
|
|
310
|
+
* ---
|
|
311
|
+
* @throws **{@link TypeError | `TypeError`}** if `keysToOmit` is not an array.
|
|
312
|
+
* @throws **{@link Error | `Error`}** if `keysToOmit` contains duplicate paths.
|
|
313
|
+
*
|
|
314
|
+
* ---
|
|
93
315
|
* @returns {Partial<I>}
|
|
94
316
|
* A new deeply cloned object with the specified keys omitted, with resulting
|
|
95
317
|
* empty objects or arrays fully removed (even if it collapses to `{}`).
|
|
96
|
-
*
|
|
97
|
-
*
|
|
318
|
+
*
|
|
319
|
+
* ---
|
|
98
320
|
* @example
|
|
99
321
|
* omitKeysDeep({ arr: [{ a: 1 }] }, ["arr.0.a"]);
|
|
100
322
|
* // ➔ {} (array becomes empty and removed)
|
|
@@ -136,4 +358,4 @@ type DotPath<T, Prev extends string = ""> = T extends Array<infer U> ? DotPath<U
|
|
|
136
358
|
* // ➔ { mixed: { a: [1, 2, 3] } }
|
|
137
359
|
*/
|
|
138
360
|
declare const omitKeysDeep: <I extends Record<string, unknown>>(object: I, keysToOmit: DotPath<I>[]) => Partial<I>;
|
|
139
|
-
export { findDuplicates, omitKeys, omitKeysDeep };
|
|
361
|
+
export { copyText, findDuplicates, omitKeys, omitKeysDeep };
|