@kikiutils/shared 10.3.0 → 10.4.1

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.
Files changed (120) hide show
  1. package/dist/buffer.cjs +43 -0
  2. package/dist/buffer.cjs.map +1 -0
  3. package/dist/buffer.d.ts +35 -0
  4. package/dist/buffer.d.ts.map +1 -0
  5. package/dist/buffer.mjs +41 -0
  6. package/dist/buffer.mjs.map +1 -0
  7. package/dist/clipboard.cjs +4 -4
  8. package/dist/clipboard.cjs.map +1 -1
  9. package/dist/clipboard.d.ts +3 -3
  10. package/dist/clipboard.mjs +4 -4
  11. package/dist/clipboard.mjs.map +1 -1
  12. package/dist/datetime.cjs +13 -13
  13. package/dist/datetime.cjs.map +1 -1
  14. package/dist/datetime.d.ts +12 -12
  15. package/dist/datetime.mjs +13 -13
  16. package/dist/datetime.mjs.map +1 -1
  17. package/dist/element-plus.cjs +6 -6
  18. package/dist/element-plus.cjs.map +1 -1
  19. package/dist/element-plus.d.ts +6 -6
  20. package/dist/element-plus.mjs +6 -6
  21. package/dist/element-plus.mjs.map +1 -1
  22. package/dist/enum.cjs +12 -12
  23. package/dist/enum.cjs.map +1 -1
  24. package/dist/enum.d.ts +12 -12
  25. package/dist/enum.mjs +12 -12
  26. package/dist/enum.mjs.map +1 -1
  27. package/dist/env.cjs +4 -4
  28. package/dist/env.cjs.map +1 -1
  29. package/dist/env.d.ts +4 -4
  30. package/dist/env.mjs +4 -4
  31. package/dist/env.mjs.map +1 -1
  32. package/dist/general.cjs.map +1 -1
  33. package/dist/general.d.ts +5 -5
  34. package/dist/general.mjs.map +1 -1
  35. package/dist/math.cjs +4 -4
  36. package/dist/math.cjs.map +1 -1
  37. package/dist/math.d.ts +4 -4
  38. package/dist/math.mjs +4 -4
  39. package/dist/math.mjs.map +1 -1
  40. package/dist/number.cjs +3 -3
  41. package/dist/number.cjs.map +1 -1
  42. package/dist/number.d.ts +3 -3
  43. package/dist/number.mjs +3 -3
  44. package/dist/number.mjs.map +1 -1
  45. package/dist/object.cjs +4 -4
  46. package/dist/object.cjs.map +1 -1
  47. package/dist/object.d.ts +4 -4
  48. package/dist/object.mjs +4 -4
  49. package/dist/object.mjs.map +1 -1
  50. package/dist/random.cjs +7 -7
  51. package/dist/random.cjs.map +1 -1
  52. package/dist/random.d.ts +7 -7
  53. package/dist/random.mjs +7 -7
  54. package/dist/random.mjs.map +1 -1
  55. package/dist/storage/enhanced/local/core.cjs +11 -11
  56. package/dist/storage/enhanced/local/core.cjs.map +1 -1
  57. package/dist/storage/enhanced/local/core.d.ts +9 -9
  58. package/dist/storage/enhanced/local/core.mjs +11 -11
  59. package/dist/storage/enhanced/local/core.mjs.map +1 -1
  60. package/dist/storage/enhanced/local/keyed-store.cjs +3 -3
  61. package/dist/storage/enhanced/local/keyed-store.cjs.map +1 -1
  62. package/dist/storage/enhanced/local/keyed-store.d.ts +3 -3
  63. package/dist/storage/enhanced/local/keyed-store.mjs +3 -3
  64. package/dist/storage/enhanced/local/keyed-store.mjs.map +1 -1
  65. package/dist/storage/enhanced/redis/core.cjs +18 -18
  66. package/dist/storage/enhanced/redis/core.cjs.map +1 -1
  67. package/dist/storage/enhanced/redis/core.d.ts +16 -16
  68. package/dist/storage/enhanced/redis/core.mjs +18 -18
  69. package/dist/storage/enhanced/redis/core.mjs.map +1 -1
  70. package/dist/storage/enhanced/redis/keyed-store.cjs +4 -4
  71. package/dist/storage/enhanced/redis/keyed-store.cjs.map +1 -1
  72. package/dist/storage/enhanced/redis/keyed-store.d.ts +4 -4
  73. package/dist/storage/enhanced/redis/keyed-store.mjs +4 -4
  74. package/dist/storage/enhanced/redis/keyed-store.mjs.map +1 -1
  75. package/dist/storage/lru/keyed-store.cjs +3 -3
  76. package/dist/storage/lru/keyed-store.cjs.map +1 -1
  77. package/dist/storage/lru/keyed-store.d.ts +3 -3
  78. package/dist/storage/lru/keyed-store.mjs +3 -3
  79. package/dist/storage/lru/keyed-store.mjs.map +1 -1
  80. package/dist/string.cjs +5 -5
  81. package/dist/string.cjs.map +1 -1
  82. package/dist/string.d.ts +4 -4
  83. package/dist/string.mjs +5 -5
  84. package/dist/string.mjs.map +1 -1
  85. package/dist/url.cjs +3 -3
  86. package/dist/url.cjs.map +1 -1
  87. package/dist/url.d.ts +3 -3
  88. package/dist/url.mjs +3 -3
  89. package/dist/url.mjs.map +1 -1
  90. package/dist/vue.cjs +6 -6
  91. package/dist/vue.cjs.map +1 -1
  92. package/dist/vue.d.ts +6 -6
  93. package/dist/vue.mjs +6 -6
  94. package/dist/vue.mjs.map +1 -1
  95. package/dist/web.cjs +4 -4
  96. package/dist/web.cjs.map +1 -1
  97. package/dist/web.d.ts +4 -4
  98. package/dist/web.mjs +4 -4
  99. package/dist/web.mjs.map +1 -1
  100. package/package.json +2 -2
  101. package/src/buffer.ts +41 -0
  102. package/src/clipboard.ts +4 -4
  103. package/src/datetime.ts +13 -13
  104. package/src/element-plus.ts +6 -6
  105. package/src/enum.ts +12 -12
  106. package/src/env.ts +4 -4
  107. package/src/general.ts +5 -5
  108. package/src/math.ts +4 -4
  109. package/src/number.ts +3 -3
  110. package/src/object.ts +4 -4
  111. package/src/random.ts +7 -7
  112. package/src/storage/enhanced/local/core.ts +11 -11
  113. package/src/storage/enhanced/local/keyed-store.ts +3 -3
  114. package/src/storage/enhanced/redis/core.ts +18 -18
  115. package/src/storage/enhanced/redis/keyed-store.ts +4 -4
  116. package/src/storage/lru/keyed-store.ts +3 -3
  117. package/src/string.ts +5 -5
  118. package/src/url.ts +3 -3
  119. package/src/vue.ts +6 -6
  120. package/src/web.ts +4 -4
package/dist/vue.cjs CHANGED
@@ -7,9 +7,9 @@ const url = require('./url.cjs');
7
7
  /**
8
8
  * Appends the current Vue Router route's fullPath as the `redirect` query parameter to the given URL.
9
9
  *
10
- * @param {string} url - The base URL to modify.
10
+ * @param {string} url - The base URL to modify
11
11
  *
12
- * @returns {string} A new URL with the current route fullPath as the `redirect` parameter.
12
+ * @returns {string} A new URL with the current route fullPath as the `redirect` parameter
13
13
  */
14
14
  function appendRedirectParamFromCurrentRouteToUrl(url$1) {
15
15
  return url.appendRedirectParamToUrl(url$1, vueRouter.useRoute().fullPath);
@@ -17,7 +17,7 @@ function appendRedirectParamFromCurrentRouteToUrl(url$1) {
17
17
  /**
18
18
  * Clears an interval referenced by a Vue ref and sets it to null.
19
19
  *
20
- * @param {Ref<null | ReturnType<typeof setInterval>>} intervalRef - A Vue ref holding a NodeJS.Timeout or null.
20
+ * @param {Ref<null | ReturnType<typeof setInterval>>} intervalRef - A Vue ref holding a NodeJS.Timeout or null
21
21
  */
22
22
  function clearIntervalRef(intervalRef) {
23
23
  if (intervalRef.value)
@@ -27,7 +27,7 @@ function clearIntervalRef(intervalRef) {
27
27
  /**
28
28
  * Clears a timeout referenced by a Vue ref and sets it to null.
29
29
  *
30
- * @param {Ref<null | ReturnType<typeof setTimeout>>} timeoutRef - A Vue ref holding a NodeJS.Timeout or null.
30
+ * @param {Ref<null | ReturnType<typeof setTimeout>>} timeoutRef - A Vue ref holding a NodeJS.Timeout or null
31
31
  */
32
32
  function clearTimeoutRef(timeoutRef) {
33
33
  if (timeoutRef.value)
@@ -38,9 +38,9 @@ function clearTimeoutRef(timeoutRef) {
38
38
  * A Vue composition function that remembers and restores scroll position
39
39
  * of a scrollable container across route changes and keep-alive activation.
40
40
  *
41
- * @template T - The type of the scrollable element (defaults to HTMLElement).
41
+ * @template T - The type of the scrollable element (defaults to HTMLElement)
42
42
  *
43
- * @param {Ref<null | T>} containerRef - A ref to the scrollable HTML element.
43
+ * @param {Ref<null | T>} containerRef - A ref to the scrollable HTML element
44
44
  */
45
45
  function usePreserveScroll(containerRef) {
46
46
  let scrollLeft = 0;
package/dist/vue.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vue.cjs","sources":["../src/vue.ts"],"sourcesContent":["import { onActivated } from 'vue';\nimport type { Ref } from 'vue';\nimport {\n onBeforeRouteLeave,\n useRoute,\n} from 'vue-router';\n\nimport { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current Vue Router route's fullPath as the `redirect` query parameter to the given URL.\n *\n * @param {string} url - The base URL to modify.\n *\n * @returns {string} A new URL with the current route fullPath as the `redirect` parameter.\n */\nexport function appendRedirectParamFromCurrentRouteToUrl(url: string) {\n return appendRedirectParamToUrl(url, useRoute().fullPath);\n}\n\n/**\n * Clears an interval referenced by a Vue ref and sets it to null.\n *\n * @param {Ref<null | ReturnType<typeof setInterval>>} intervalRef - A Vue ref holding a NodeJS.Timeout or null.\n */\nexport function clearIntervalRef(intervalRef: Ref<null | ReturnType<typeof setInterval>>) {\n if (intervalRef.value) clearInterval(intervalRef.value);\n intervalRef.value = null;\n}\n\n/**\n * Clears a timeout referenced by a Vue ref and sets it to null.\n *\n * @param {Ref<null | ReturnType<typeof setTimeout>>} timeoutRef - A Vue ref holding a NodeJS.Timeout or null.\n */\nexport function clearTimeoutRef(timeoutRef: Ref<null | ReturnType<typeof setTimeout>>) {\n if (timeoutRef.value) clearTimeout(timeoutRef.value);\n timeoutRef.value = null;\n}\n\n/**\n * A Vue composition function that remembers and restores scroll position\n * of a scrollable container across route changes and keep-alive activation.\n *\n * @template T - The type of the scrollable element (defaults to HTMLElement).\n *\n * @param {Ref<null | T>} containerRef - A ref to the scrollable HTML element.\n */\nexport function usePreserveScroll<T extends Element = HTMLElement>(containerRef: Ref<null | T>) {\n let scrollLeft = 0;\n let scrollTop = 0;\n onActivated(() => {\n if (!containerRef.value) return;\n containerRef.value.scrollLeft = scrollLeft;\n containerRef.value.scrollTop = scrollTop;\n });\n\n onBeforeRouteLeave(() => {\n scrollLeft = containerRef.value?.scrollLeft || 0;\n scrollTop = containerRef.value?.scrollTop || 0;\n });\n}\n"],"names":["url","appendRedirectParamToUrl","useRoute","onActivated","onBeforeRouteLeave"],"mappings":";;;;;;AASA;;;;;;AAMG;AACG,SAAU,wCAAwC,CAACA,KAAW,EAAA;IAChE,OAAOC,4BAAwB,CAACD,KAAG,EAAEE,kBAAQ,EAAE,CAAC,QAAQ,CAAC;AAC7D;AAEA;;;;AAIG;AACG,SAAU,gBAAgB,CAAC,WAAuD,EAAA;IACpF,IAAI,WAAW,CAAC,KAAK;AAAE,QAAA,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC;AACvD,IAAA,WAAW,CAAC,KAAK,GAAG,IAAI;AAC5B;AAEA;;;;AAIG;AACG,SAAU,eAAe,CAAC,UAAqD,EAAA;IACjF,IAAI,UAAU,CAAC,KAAK;AAAE,QAAA,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC;AACpD,IAAA,UAAU,CAAC,KAAK,GAAG,IAAI;AAC3B;AAEA;;;;;;;AAOG;AACG,SAAU,iBAAiB,CAAkC,YAA2B,EAAA;IAC1F,IAAI,UAAU,GAAG,CAAC;IAClB,IAAI,SAAS,GAAG,CAAC;IACjBC,eAAW,CAAC,MAAK;QACb,IAAI,CAAC,YAAY,CAAC,KAAK;YAAE;AACzB,QAAA,YAAY,CAAC,KAAK,CAAC,UAAU,GAAG,UAAU;AAC1C,QAAA,YAAY,CAAC,KAAK,CAAC,SAAS,GAAG,SAAS;AAC5C,IAAA,CAAC,CAAC;IAEFC,4BAAkB,CAAC,MAAK;QACpB,UAAU,GAAG,YAAY,CAAC,KAAK,EAAE,UAAU,IAAI,CAAC;QAChD,SAAS,GAAG,YAAY,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC;AAClD,IAAA,CAAC,CAAC;AACN;;;;;;;"}
1
+ {"version":3,"file":"vue.cjs","sources":["../src/vue.ts"],"sourcesContent":["import { onActivated } from 'vue';\nimport type { Ref } from 'vue';\nimport {\n onBeforeRouteLeave,\n useRoute,\n} from 'vue-router';\n\nimport { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current Vue Router route's fullPath as the `redirect` query parameter to the given URL.\n *\n * @param {string} url - The base URL to modify\n *\n * @returns {string} A new URL with the current route fullPath as the `redirect` parameter\n */\nexport function appendRedirectParamFromCurrentRouteToUrl(url: string) {\n return appendRedirectParamToUrl(url, useRoute().fullPath);\n}\n\n/**\n * Clears an interval referenced by a Vue ref and sets it to null.\n *\n * @param {Ref<null | ReturnType<typeof setInterval>>} intervalRef - A Vue ref holding a NodeJS.Timeout or null\n */\nexport function clearIntervalRef(intervalRef: Ref<null | ReturnType<typeof setInterval>>) {\n if (intervalRef.value) clearInterval(intervalRef.value);\n intervalRef.value = null;\n}\n\n/**\n * Clears a timeout referenced by a Vue ref and sets it to null.\n *\n * @param {Ref<null | ReturnType<typeof setTimeout>>} timeoutRef - A Vue ref holding a NodeJS.Timeout or null\n */\nexport function clearTimeoutRef(timeoutRef: Ref<null | ReturnType<typeof setTimeout>>) {\n if (timeoutRef.value) clearTimeout(timeoutRef.value);\n timeoutRef.value = null;\n}\n\n/**\n * A Vue composition function that remembers and restores scroll position\n * of a scrollable container across route changes and keep-alive activation.\n *\n * @template T - The type of the scrollable element (defaults to HTMLElement)\n *\n * @param {Ref<null | T>} containerRef - A ref to the scrollable HTML element\n */\nexport function usePreserveScroll<T extends Element = HTMLElement>(containerRef: Ref<null | T>) {\n let scrollLeft = 0;\n let scrollTop = 0;\n onActivated(() => {\n if (!containerRef.value) return;\n containerRef.value.scrollLeft = scrollLeft;\n containerRef.value.scrollTop = scrollTop;\n });\n\n onBeforeRouteLeave(() => {\n scrollLeft = containerRef.value?.scrollLeft || 0;\n scrollTop = containerRef.value?.scrollTop || 0;\n });\n}\n"],"names":["url","appendRedirectParamToUrl","useRoute","onActivated","onBeforeRouteLeave"],"mappings":";;;;;;AASA;;;;;;AAMG;AACG,SAAU,wCAAwC,CAACA,KAAW,EAAA;IAChE,OAAOC,4BAAwB,CAACD,KAAG,EAAEE,kBAAQ,EAAE,CAAC,QAAQ,CAAC;AAC7D;AAEA;;;;AAIG;AACG,SAAU,gBAAgB,CAAC,WAAuD,EAAA;IACpF,IAAI,WAAW,CAAC,KAAK;AAAE,QAAA,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC;AACvD,IAAA,WAAW,CAAC,KAAK,GAAG,IAAI;AAC5B;AAEA;;;;AAIG;AACG,SAAU,eAAe,CAAC,UAAqD,EAAA;IACjF,IAAI,UAAU,CAAC,KAAK;AAAE,QAAA,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC;AACpD,IAAA,UAAU,CAAC,KAAK,GAAG,IAAI;AAC3B;AAEA;;;;;;;AAOG;AACG,SAAU,iBAAiB,CAAkC,YAA2B,EAAA;IAC1F,IAAI,UAAU,GAAG,CAAC;IAClB,IAAI,SAAS,GAAG,CAAC;IACjBC,eAAW,CAAC,MAAK;QACb,IAAI,CAAC,YAAY,CAAC,KAAK;YAAE;AACzB,QAAA,YAAY,CAAC,KAAK,CAAC,UAAU,GAAG,UAAU;AAC1C,QAAA,YAAY,CAAC,KAAK,CAAC,SAAS,GAAG,SAAS;AAC5C,IAAA,CAAC,CAAC;IAEFC,4BAAkB,CAAC,MAAK;QACpB,UAAU,GAAG,YAAY,CAAC,KAAK,EAAE,UAAU,IAAI,CAAC;QAChD,SAAS,GAAG,YAAY,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC;AAClD,IAAA,CAAC,CAAC;AACN;;;;;;;"}
package/dist/vue.d.ts CHANGED
@@ -2,30 +2,30 @@ import type { Ref } from 'vue';
2
2
  /**
3
3
  * Appends the current Vue Router route's fullPath as the `redirect` query parameter to the given URL.
4
4
  *
5
- * @param {string} url - The base URL to modify.
5
+ * @param {string} url - The base URL to modify
6
6
  *
7
- * @returns {string} A new URL with the current route fullPath as the `redirect` parameter.
7
+ * @returns {string} A new URL with the current route fullPath as the `redirect` parameter
8
8
  */
9
9
  export declare function appendRedirectParamFromCurrentRouteToUrl(url: string): string;
10
10
  /**
11
11
  * Clears an interval referenced by a Vue ref and sets it to null.
12
12
  *
13
- * @param {Ref<null | ReturnType<typeof setInterval>>} intervalRef - A Vue ref holding a NodeJS.Timeout or null.
13
+ * @param {Ref<null | ReturnType<typeof setInterval>>} intervalRef - A Vue ref holding a NodeJS.Timeout or null
14
14
  */
15
15
  export declare function clearIntervalRef(intervalRef: Ref<null | ReturnType<typeof setInterval>>): void;
16
16
  /**
17
17
  * Clears a timeout referenced by a Vue ref and sets it to null.
18
18
  *
19
- * @param {Ref<null | ReturnType<typeof setTimeout>>} timeoutRef - A Vue ref holding a NodeJS.Timeout or null.
19
+ * @param {Ref<null | ReturnType<typeof setTimeout>>} timeoutRef - A Vue ref holding a NodeJS.Timeout or null
20
20
  */
21
21
  export declare function clearTimeoutRef(timeoutRef: Ref<null | ReturnType<typeof setTimeout>>): void;
22
22
  /**
23
23
  * A Vue composition function that remembers and restores scroll position
24
24
  * of a scrollable container across route changes and keep-alive activation.
25
25
  *
26
- * @template T - The type of the scrollable element (defaults to HTMLElement).
26
+ * @template T - The type of the scrollable element (defaults to HTMLElement)
27
27
  *
28
- * @param {Ref<null | T>} containerRef - A ref to the scrollable HTML element.
28
+ * @param {Ref<null | T>} containerRef - A ref to the scrollable HTML element
29
29
  */
30
30
  export declare function usePreserveScroll<T extends Element = HTMLElement>(containerRef: Ref<null | T>): void;
31
31
  //# sourceMappingURL=vue.d.ts.map
package/dist/vue.mjs CHANGED
@@ -5,9 +5,9 @@ import { appendRedirectParamToUrl } from './url.mjs';
5
5
  /**
6
6
  * Appends the current Vue Router route's fullPath as the `redirect` query parameter to the given URL.
7
7
  *
8
- * @param {string} url - The base URL to modify.
8
+ * @param {string} url - The base URL to modify
9
9
  *
10
- * @returns {string} A new URL with the current route fullPath as the `redirect` parameter.
10
+ * @returns {string} A new URL with the current route fullPath as the `redirect` parameter
11
11
  */
12
12
  function appendRedirectParamFromCurrentRouteToUrl(url) {
13
13
  return appendRedirectParamToUrl(url, useRoute().fullPath);
@@ -15,7 +15,7 @@ function appendRedirectParamFromCurrentRouteToUrl(url) {
15
15
  /**
16
16
  * Clears an interval referenced by a Vue ref and sets it to null.
17
17
  *
18
- * @param {Ref<null | ReturnType<typeof setInterval>>} intervalRef - A Vue ref holding a NodeJS.Timeout or null.
18
+ * @param {Ref<null | ReturnType<typeof setInterval>>} intervalRef - A Vue ref holding a NodeJS.Timeout or null
19
19
  */
20
20
  function clearIntervalRef(intervalRef) {
21
21
  if (intervalRef.value)
@@ -25,7 +25,7 @@ function clearIntervalRef(intervalRef) {
25
25
  /**
26
26
  * Clears a timeout referenced by a Vue ref and sets it to null.
27
27
  *
28
- * @param {Ref<null | ReturnType<typeof setTimeout>>} timeoutRef - A Vue ref holding a NodeJS.Timeout or null.
28
+ * @param {Ref<null | ReturnType<typeof setTimeout>>} timeoutRef - A Vue ref holding a NodeJS.Timeout or null
29
29
  */
30
30
  function clearTimeoutRef(timeoutRef) {
31
31
  if (timeoutRef.value)
@@ -36,9 +36,9 @@ function clearTimeoutRef(timeoutRef) {
36
36
  * A Vue composition function that remembers and restores scroll position
37
37
  * of a scrollable container across route changes and keep-alive activation.
38
38
  *
39
- * @template T - The type of the scrollable element (defaults to HTMLElement).
39
+ * @template T - The type of the scrollable element (defaults to HTMLElement)
40
40
  *
41
- * @param {Ref<null | T>} containerRef - A ref to the scrollable HTML element.
41
+ * @param {Ref<null | T>} containerRef - A ref to the scrollable HTML element
42
42
  */
43
43
  function usePreserveScroll(containerRef) {
44
44
  let scrollLeft = 0;
package/dist/vue.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vue.mjs","sources":["../src/vue.ts"],"sourcesContent":["import { onActivated } from 'vue';\nimport type { Ref } from 'vue';\nimport {\n onBeforeRouteLeave,\n useRoute,\n} from 'vue-router';\n\nimport { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current Vue Router route's fullPath as the `redirect` query parameter to the given URL.\n *\n * @param {string} url - The base URL to modify.\n *\n * @returns {string} A new URL with the current route fullPath as the `redirect` parameter.\n */\nexport function appendRedirectParamFromCurrentRouteToUrl(url: string) {\n return appendRedirectParamToUrl(url, useRoute().fullPath);\n}\n\n/**\n * Clears an interval referenced by a Vue ref and sets it to null.\n *\n * @param {Ref<null | ReturnType<typeof setInterval>>} intervalRef - A Vue ref holding a NodeJS.Timeout or null.\n */\nexport function clearIntervalRef(intervalRef: Ref<null | ReturnType<typeof setInterval>>) {\n if (intervalRef.value) clearInterval(intervalRef.value);\n intervalRef.value = null;\n}\n\n/**\n * Clears a timeout referenced by a Vue ref and sets it to null.\n *\n * @param {Ref<null | ReturnType<typeof setTimeout>>} timeoutRef - A Vue ref holding a NodeJS.Timeout or null.\n */\nexport function clearTimeoutRef(timeoutRef: Ref<null | ReturnType<typeof setTimeout>>) {\n if (timeoutRef.value) clearTimeout(timeoutRef.value);\n timeoutRef.value = null;\n}\n\n/**\n * A Vue composition function that remembers and restores scroll position\n * of a scrollable container across route changes and keep-alive activation.\n *\n * @template T - The type of the scrollable element (defaults to HTMLElement).\n *\n * @param {Ref<null | T>} containerRef - A ref to the scrollable HTML element.\n */\nexport function usePreserveScroll<T extends Element = HTMLElement>(containerRef: Ref<null | T>) {\n let scrollLeft = 0;\n let scrollTop = 0;\n onActivated(() => {\n if (!containerRef.value) return;\n containerRef.value.scrollLeft = scrollLeft;\n containerRef.value.scrollTop = scrollTop;\n });\n\n onBeforeRouteLeave(() => {\n scrollLeft = containerRef.value?.scrollLeft || 0;\n scrollTop = containerRef.value?.scrollTop || 0;\n });\n}\n"],"names":[],"mappings":";;;;AASA;;;;;;AAMG;AACG,SAAU,wCAAwC,CAAC,GAAW,EAAA;IAChE,OAAO,wBAAwB,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC;AAC7D;AAEA;;;;AAIG;AACG,SAAU,gBAAgB,CAAC,WAAuD,EAAA;IACpF,IAAI,WAAW,CAAC,KAAK;AAAE,QAAA,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC;AACvD,IAAA,WAAW,CAAC,KAAK,GAAG,IAAI;AAC5B;AAEA;;;;AAIG;AACG,SAAU,eAAe,CAAC,UAAqD,EAAA;IACjF,IAAI,UAAU,CAAC,KAAK;AAAE,QAAA,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC;AACpD,IAAA,UAAU,CAAC,KAAK,GAAG,IAAI;AAC3B;AAEA;;;;;;;AAOG;AACG,SAAU,iBAAiB,CAAkC,YAA2B,EAAA;IAC1F,IAAI,UAAU,GAAG,CAAC;IAClB,IAAI,SAAS,GAAG,CAAC;IACjB,WAAW,CAAC,MAAK;QACb,IAAI,CAAC,YAAY,CAAC,KAAK;YAAE;AACzB,QAAA,YAAY,CAAC,KAAK,CAAC,UAAU,GAAG,UAAU;AAC1C,QAAA,YAAY,CAAC,KAAK,CAAC,SAAS,GAAG,SAAS;AAC5C,IAAA,CAAC,CAAC;IAEF,kBAAkB,CAAC,MAAK;QACpB,UAAU,GAAG,YAAY,CAAC,KAAK,EAAE,UAAU,IAAI,CAAC;QAChD,SAAS,GAAG,YAAY,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC;AAClD,IAAA,CAAC,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"vue.mjs","sources":["../src/vue.ts"],"sourcesContent":["import { onActivated } from 'vue';\nimport type { Ref } from 'vue';\nimport {\n onBeforeRouteLeave,\n useRoute,\n} from 'vue-router';\n\nimport { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current Vue Router route's fullPath as the `redirect` query parameter to the given URL.\n *\n * @param {string} url - The base URL to modify\n *\n * @returns {string} A new URL with the current route fullPath as the `redirect` parameter\n */\nexport function appendRedirectParamFromCurrentRouteToUrl(url: string) {\n return appendRedirectParamToUrl(url, useRoute().fullPath);\n}\n\n/**\n * Clears an interval referenced by a Vue ref and sets it to null.\n *\n * @param {Ref<null | ReturnType<typeof setInterval>>} intervalRef - A Vue ref holding a NodeJS.Timeout or null\n */\nexport function clearIntervalRef(intervalRef: Ref<null | ReturnType<typeof setInterval>>) {\n if (intervalRef.value) clearInterval(intervalRef.value);\n intervalRef.value = null;\n}\n\n/**\n * Clears a timeout referenced by a Vue ref and sets it to null.\n *\n * @param {Ref<null | ReturnType<typeof setTimeout>>} timeoutRef - A Vue ref holding a NodeJS.Timeout or null\n */\nexport function clearTimeoutRef(timeoutRef: Ref<null | ReturnType<typeof setTimeout>>) {\n if (timeoutRef.value) clearTimeout(timeoutRef.value);\n timeoutRef.value = null;\n}\n\n/**\n * A Vue composition function that remembers and restores scroll position\n * of a scrollable container across route changes and keep-alive activation.\n *\n * @template T - The type of the scrollable element (defaults to HTMLElement)\n *\n * @param {Ref<null | T>} containerRef - A ref to the scrollable HTML element\n */\nexport function usePreserveScroll<T extends Element = HTMLElement>(containerRef: Ref<null | T>) {\n let scrollLeft = 0;\n let scrollTop = 0;\n onActivated(() => {\n if (!containerRef.value) return;\n containerRef.value.scrollLeft = scrollLeft;\n containerRef.value.scrollTop = scrollTop;\n });\n\n onBeforeRouteLeave(() => {\n scrollLeft = containerRef.value?.scrollLeft || 0;\n scrollTop = containerRef.value?.scrollTop || 0;\n });\n}\n"],"names":[],"mappings":";;;;AASA;;;;;;AAMG;AACG,SAAU,wCAAwC,CAAC,GAAW,EAAA;IAChE,OAAO,wBAAwB,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC;AAC7D;AAEA;;;;AAIG;AACG,SAAU,gBAAgB,CAAC,WAAuD,EAAA;IACpF,IAAI,WAAW,CAAC,KAAK;AAAE,QAAA,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC;AACvD,IAAA,WAAW,CAAC,KAAK,GAAG,IAAI;AAC5B;AAEA;;;;AAIG;AACG,SAAU,eAAe,CAAC,UAAqD,EAAA;IACjF,IAAI,UAAU,CAAC,KAAK;AAAE,QAAA,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC;AACpD,IAAA,UAAU,CAAC,KAAK,GAAG,IAAI;AAC3B;AAEA;;;;;;;AAOG;AACG,SAAU,iBAAiB,CAAkC,YAA2B,EAAA;IAC1F,IAAI,UAAU,GAAG,CAAC;IAClB,IAAI,SAAS,GAAG,CAAC;IACjB,WAAW,CAAC,MAAK;QACb,IAAI,CAAC,YAAY,CAAC,KAAK;YAAE;AACzB,QAAA,YAAY,CAAC,KAAK,CAAC,UAAU,GAAG,UAAU;AAC1C,QAAA,YAAY,CAAC,KAAK,CAAC,SAAS,GAAG,SAAS;AAC5C,IAAA,CAAC,CAAC;IAEF,kBAAkB,CAAC,MAAK;QACpB,UAAU,GAAG,YAAY,CAAC,KAAK,EAAE,UAAU,IAAI,CAAC;QAChD,SAAS,GAAG,YAAY,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC;AAClD,IAAA,CAAC,CAAC;AACN;;;;"}
package/dist/web.cjs CHANGED
@@ -5,9 +5,9 @@ const url = require('./url.cjs');
5
5
  /**
6
6
  * Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.
7
7
  *
8
- * @param {string} url - The base URL to modify.
8
+ * @param {string} url - The base URL to modify
9
9
  *
10
- * @returns {string} A new URL with the current location as the `redirect` parameter.
10
+ * @returns {string} A new URL with the current location as the `redirect` parameter
11
11
  */
12
12
  function appendRedirectParamFromCurrentLocationToUrl(url$1) {
13
13
  const currentPath = `${window.location.pathname}${window.location.search}${window.location.hash}`;
@@ -20,8 +20,8 @@ function appendRedirectParamFromCurrentLocationToUrl(url$1) {
20
20
  * Useful for redirecting to login or other gateways while preserving
21
21
  * the current location for post-auth navigation.
22
22
  *
23
- * @param {string} url - The destination URL to navigate to.
24
- * @param {number} [delayMs] - Optional delay in milliseconds before navigation.
23
+ * @param {string} url - The destination URL to navigate to
24
+ * @param {number} [delayMs] - Optional delay in milliseconds before navigation
25
25
  */
26
26
  function assignUrlWithRedirectParamFromCurrentLocation(url, delayMs) {
27
27
  if (delayMs === undefined)
package/dist/web.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"web.cjs","sources":["../src/web.ts"],"sourcesContent":["import { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.\n *\n * @param {string} url - The base URL to modify.\n *\n * @returns {string} A new URL with the current location as the `redirect` parameter.\n */\nexport function appendRedirectParamFromCurrentLocationToUrl(url: string) {\n const currentPath = `${window.location.pathname}${window.location.search}${window.location.hash}`;\n return appendRedirectParamToUrl(url, currentPath);\n}\n\n/**\n * Navigates to the given URL, appending the current browser location\n * (path, query, and hash) as the `redirect` query parameter.\n *\n * Useful for redirecting to login or other gateways while preserving\n * the current location for post-auth navigation.\n *\n * @param {string} url - The destination URL to navigate to.\n * @param {number} [delayMs] - Optional delay in milliseconds before navigation.\n */\nexport function assignUrlWithRedirectParamFromCurrentLocation(url: string, delayMs?: number) {\n if (delayMs === undefined) window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url));\n else return setTimeout(() => window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url)), delayMs);\n}\n"],"names":["url","appendRedirectParamToUrl"],"mappings":";;;;AAEA;;;;;;AAMG;AACG,SAAU,2CAA2C,CAACA,KAAW,EAAA;IACnE,MAAM,WAAW,GAAG,CAAA,EAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAA,EAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAA,EAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAA,CAAE;AACjG,IAAA,OAAOC,4BAAwB,CAACD,KAAG,EAAE,WAAW,CAAC;AACrD;AAEA;;;;;;;;;AASG;AACG,SAAU,6CAA6C,CAAC,GAAW,EAAE,OAAgB,EAAA;IACvF,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,2CAA2C,CAAC,GAAG,CAAC,CAAC;;AAC9F,QAAA,OAAO,UAAU,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,2CAA2C,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC;AACnH;;;;;"}
1
+ {"version":3,"file":"web.cjs","sources":["../src/web.ts"],"sourcesContent":["import { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.\n *\n * @param {string} url - The base URL to modify\n *\n * @returns {string} A new URL with the current location as the `redirect` parameter\n */\nexport function appendRedirectParamFromCurrentLocationToUrl(url: string) {\n const currentPath = `${window.location.pathname}${window.location.search}${window.location.hash}`;\n return appendRedirectParamToUrl(url, currentPath);\n}\n\n/**\n * Navigates to the given URL, appending the current browser location\n * (path, query, and hash) as the `redirect` query parameter.\n *\n * Useful for redirecting to login or other gateways while preserving\n * the current location for post-auth navigation.\n *\n * @param {string} url - The destination URL to navigate to\n * @param {number} [delayMs] - Optional delay in milliseconds before navigation\n */\nexport function assignUrlWithRedirectParamFromCurrentLocation(url: string, delayMs?: number) {\n if (delayMs === undefined) window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url));\n else return setTimeout(() => window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url)), delayMs);\n}\n"],"names":["url","appendRedirectParamToUrl"],"mappings":";;;;AAEA;;;;;;AAMG;AACG,SAAU,2CAA2C,CAACA,KAAW,EAAA;IACnE,MAAM,WAAW,GAAG,CAAA,EAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAA,EAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAA,EAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAA,CAAE;AACjG,IAAA,OAAOC,4BAAwB,CAACD,KAAG,EAAE,WAAW,CAAC;AACrD;AAEA;;;;;;;;;AASG;AACG,SAAU,6CAA6C,CAAC,GAAW,EAAE,OAAgB,EAAA;IACvF,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,2CAA2C,CAAC,GAAG,CAAC,CAAC;;AAC9F,QAAA,OAAO,UAAU,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,2CAA2C,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC;AACnH;;;;;"}
package/dist/web.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.
3
3
  *
4
- * @param {string} url - The base URL to modify.
4
+ * @param {string} url - The base URL to modify
5
5
  *
6
- * @returns {string} A new URL with the current location as the `redirect` parameter.
6
+ * @returns {string} A new URL with the current location as the `redirect` parameter
7
7
  */
8
8
  export declare function appendRedirectParamFromCurrentLocationToUrl(url: string): string;
9
9
  /**
@@ -13,8 +13,8 @@ export declare function appendRedirectParamFromCurrentLocationToUrl(url: string)
13
13
  * Useful for redirecting to login or other gateways while preserving
14
14
  * the current location for post-auth navigation.
15
15
  *
16
- * @param {string} url - The destination URL to navigate to.
17
- * @param {number} [delayMs] - Optional delay in milliseconds before navigation.
16
+ * @param {string} url - The destination URL to navigate to
17
+ * @param {number} [delayMs] - Optional delay in milliseconds before navigation
18
18
  */
19
19
  export declare function assignUrlWithRedirectParamFromCurrentLocation(url: string, delayMs?: number): NodeJS.Timeout | undefined;
20
20
  //# sourceMappingURL=web.d.ts.map
package/dist/web.mjs CHANGED
@@ -3,9 +3,9 @@ import { appendRedirectParamToUrl } from './url.mjs';
3
3
  /**
4
4
  * Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.
5
5
  *
6
- * @param {string} url - The base URL to modify.
6
+ * @param {string} url - The base URL to modify
7
7
  *
8
- * @returns {string} A new URL with the current location as the `redirect` parameter.
8
+ * @returns {string} A new URL with the current location as the `redirect` parameter
9
9
  */
10
10
  function appendRedirectParamFromCurrentLocationToUrl(url) {
11
11
  const currentPath = `${window.location.pathname}${window.location.search}${window.location.hash}`;
@@ -18,8 +18,8 @@ function appendRedirectParamFromCurrentLocationToUrl(url) {
18
18
  * Useful for redirecting to login or other gateways while preserving
19
19
  * the current location for post-auth navigation.
20
20
  *
21
- * @param {string} url - The destination URL to navigate to.
22
- * @param {number} [delayMs] - Optional delay in milliseconds before navigation.
21
+ * @param {string} url - The destination URL to navigate to
22
+ * @param {number} [delayMs] - Optional delay in milliseconds before navigation
23
23
  */
24
24
  function assignUrlWithRedirectParamFromCurrentLocation(url, delayMs) {
25
25
  if (delayMs === undefined)
package/dist/web.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"web.mjs","sources":["../src/web.ts"],"sourcesContent":["import { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.\n *\n * @param {string} url - The base URL to modify.\n *\n * @returns {string} A new URL with the current location as the `redirect` parameter.\n */\nexport function appendRedirectParamFromCurrentLocationToUrl(url: string) {\n const currentPath = `${window.location.pathname}${window.location.search}${window.location.hash}`;\n return appendRedirectParamToUrl(url, currentPath);\n}\n\n/**\n * Navigates to the given URL, appending the current browser location\n * (path, query, and hash) as the `redirect` query parameter.\n *\n * Useful for redirecting to login or other gateways while preserving\n * the current location for post-auth navigation.\n *\n * @param {string} url - The destination URL to navigate to.\n * @param {number} [delayMs] - Optional delay in milliseconds before navigation.\n */\nexport function assignUrlWithRedirectParamFromCurrentLocation(url: string, delayMs?: number) {\n if (delayMs === undefined) window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url));\n else return setTimeout(() => window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url)), delayMs);\n}\n"],"names":[],"mappings":";;AAEA;;;;;;AAMG;AACG,SAAU,2CAA2C,CAAC,GAAW,EAAA;IACnE,MAAM,WAAW,GAAG,CAAA,EAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAA,EAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAA,EAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAA,CAAE;AACjG,IAAA,OAAO,wBAAwB,CAAC,GAAG,EAAE,WAAW,CAAC;AACrD;AAEA;;;;;;;;;AASG;AACG,SAAU,6CAA6C,CAAC,GAAW,EAAE,OAAgB,EAAA;IACvF,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,2CAA2C,CAAC,GAAG,CAAC,CAAC;;AAC9F,QAAA,OAAO,UAAU,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,2CAA2C,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC;AACnH;;;;"}
1
+ {"version":3,"file":"web.mjs","sources":["../src/web.ts"],"sourcesContent":["import { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.\n *\n * @param {string} url - The base URL to modify\n *\n * @returns {string} A new URL with the current location as the `redirect` parameter\n */\nexport function appendRedirectParamFromCurrentLocationToUrl(url: string) {\n const currentPath = `${window.location.pathname}${window.location.search}${window.location.hash}`;\n return appendRedirectParamToUrl(url, currentPath);\n}\n\n/**\n * Navigates to the given URL, appending the current browser location\n * (path, query, and hash) as the `redirect` query parameter.\n *\n * Useful for redirecting to login or other gateways while preserving\n * the current location for post-auth navigation.\n *\n * @param {string} url - The destination URL to navigate to\n * @param {number} [delayMs] - Optional delay in milliseconds before navigation\n */\nexport function assignUrlWithRedirectParamFromCurrentLocation(url: string, delayMs?: number) {\n if (delayMs === undefined) window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url));\n else return setTimeout(() => window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url)), delayMs);\n}\n"],"names":[],"mappings":";;AAEA;;;;;;AAMG;AACG,SAAU,2CAA2C,CAAC,GAAW,EAAA;IACnE,MAAM,WAAW,GAAG,CAAA,EAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAA,EAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAA,EAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAA,CAAE;AACjG,IAAA,OAAO,wBAAwB,CAAC,GAAG,EAAE,WAAW,CAAC;AACrD;AAEA;;;;;;;;;AASG;AACG,SAAU,6CAA6C,CAAC,GAAW,EAAE,OAAgB,EAAA;IACvF,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,2CAA2C,CAAC,GAAG,CAAC,CAAC;;AAC9F,QAAA,OAAO,UAAU,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,2CAA2C,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC;AACnH;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kikiutils/shared",
3
- "version": "10.3.0",
3
+ "version": "10.4.1",
4
4
  "description": "A lightweight and modular utility library for modern JavaScript and TypeScript — includes secure hashing, flexible logging, datetime tools, Vue/web helpers, storage abstraction, and more.",
5
5
  "author": "kiki-kanri",
6
6
  "license": "MIT",
@@ -69,7 +69,7 @@
69
69
  "unused-exports": "ts-unused-exports ./tsconfig.json"
70
70
  },
71
71
  "devDependencies": {
72
- "@kikiutils/changelogen": "^0.8.0",
72
+ "@kikiutils/changelogen": "^0.8.1",
73
73
  "@kikiutils/eslint-config": "^1.2.7",
74
74
  "@kikiutils/tsconfigs": "^5.0.4",
75
75
  "@noble/hashes": "^1.8.0",
package/src/buffer.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { Buffer } from 'node:buffer';
2
+ import type {
3
+ Blob as NodeBlob,
4
+ File as NodeFile,
5
+ } from 'node:buffer';
6
+
7
+ /**
8
+ * Converts a Blob, Buffer, or File to a Buffer.
9
+ *
10
+ * This function provides a unified way to convert various binary data types
11
+ * to Node.js Buffer. If the input is already a Buffer, it returns it as-is.
12
+ * For Blob or File inputs, it converts them to Buffer via ArrayBuffer.
13
+ *
14
+ * @param {Blob | Buffer | File} input - The input to convert to Buffer
15
+ *
16
+ * @returns {Promise<Buffer>} A Promise that resolves to a Buffer
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { toBuffer } from '@kikiutils/shared/general';
21
+ *
22
+ * // Convert a Buffer (returns as-is)
23
+ * const buffer = Buffer.from('Hello World');
24
+ * const result1 = await toBuffer(buffer);
25
+ * console.log(result1); // <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>
26
+ *
27
+ * // Convert a Blob
28
+ * const blob = new Blob(['Hello from Blob'], { type: 'text/plain' });
29
+ * const result2 = await toBuffer(blob);
30
+ * console.log(result2.toString()); // 'Hello from Blob'
31
+ *
32
+ * // Convert a File
33
+ * const file = new File(['File content'], 'test.txt', { type: 'text/plain' });
34
+ * const result3 = await toBuffer(file);
35
+ * console.log(result3.toString()); // 'File content'
36
+ * ```
37
+ */
38
+ export async function toBuffer(input: Blob | Buffer | File | NodeBlob | NodeFile) {
39
+ if (Buffer.isBuffer(input)) return input;
40
+ return Buffer.from(await input.arrayBuffer());
41
+ }
package/src/clipboard.ts CHANGED
@@ -10,8 +10,8 @@ type CopyResult =
10
10
  * - Must be called **in response to a user interaction** (e.g. click, input).
11
11
  * - Not supported in Safari and some older browsers.
12
12
  *
13
- * @param {Blob} blob - The Blob object to copy (e.g. from a File, image, or text content).
14
- * @param {ClipboardItemOptions} [options] - Optional options passed to the ClipboardItem constructor.
13
+ * @param {Blob} blob - The Blob object to copy (e.g. from a File, image, or text content)
14
+ * @param {ClipboardItemOptions} [options] - Optional options passed to the ClipboardItem constructor
15
15
  *
16
16
  * @returns {Promise<CopyResult>} A promise resolving to a `CopyResult`:
17
17
  * - `{ ok: true }` if the copy succeeded
@@ -33,7 +33,7 @@ type CopyResult =
33
33
  export async function copyBlobToClipboard(blob: Blob, options?: ClipboardItemOptions): Promise<CopyResult> {
34
34
  if (!navigator.clipboard?.write) {
35
35
  return {
36
- error: new Error('Clipboard.write is not supported in this browser.'),
36
+ error: new Error('Clipboard.write is not supported in this browser'),
37
37
  ok: false,
38
38
  };
39
39
  }
@@ -58,7 +58,7 @@ export async function copyBlobToClipboard(blob: Blob, options?: ClipboardItemOpt
58
58
  * - Must be called **in response to a user interaction** (e.g. click, input).
59
59
  * - Not supported in some older browsers (especially legacy Safari).
60
60
  *
61
- * @param {string} text - The string to be copied to the clipboard.
61
+ * @param {string} text - The string to be copied to the clipboard
62
62
  *
63
63
  * @returns {Promise<CopyResult>} A promise resolving to a `CopyResult`:
64
64
  * - `{ ok: true }` if the copy succeeded
package/src/datetime.ts CHANGED
@@ -23,11 +23,11 @@ export type DateRangeType = 'lastMonth' | 'lastWeek' | 'thisMonth' | 'thisWeek'
23
23
  *
24
24
  * This function is a wrapper around `date-fns/format`.
25
25
  *
26
- * @param {DateArg<Date>} date - The input date to format. Can be a Date object, a timestamp, or a string.
27
- * @param {string} [format] - The target format string.
28
- * @param {FormatOptions} [options] - Optional formatting options passed to `date-fns/format`.
26
+ * @param {DateArg<Date>} date - The input date to format. Can be a Date object, a timestamp, or a string
27
+ * @param {string} [format] - The target format string
28
+ * @param {FormatOptions} [options] - Optional formatting options passed to `date-fns/format`
29
29
  *
30
- * @returns {string} The formatted date string.
30
+ * @returns {string} The formatted date string
31
31
  *
32
32
  * @example
33
33
  * ```typescript
@@ -54,13 +54,13 @@ export function formatDate(date: DateArg<Date> & {}, format: string = 'yyyy-MM-d
54
54
  *
55
55
  * Supports common range types like 'lastMonth', 'lastWeek', 'thisMonth', 'thisWeek', 'today', and 'yesterday'.
56
56
  *
57
- * @param {Date} date - The reference date.
58
- * @param {DateRangeType} type - The range type to compute.
59
- * @param {object} [options] - Optional settings.
60
- * @param {boolean} [options.setEndDateToNextDayStart] - If true, set `endDate` to 00:00:00.000 of the next day.
61
- * @param {Day} [options.weekStartsOn] - The start day of the week (0 = Sunday, 1 = Monday, ..., 6 = Saturday).
57
+ * @param {Date} date - The reference date
58
+ * @param {DateRangeType} type - The range type to compute
59
+ * @param {object} [options] - Optional settings
60
+ * @param {boolean} [options.setEndDateToNextDayStart] - If true, set `endDate` to 00:00:00.000 of the next day
61
+ * @param {Day} [options.weekStartsOn] - The start day of the week (0 = Sunday, 1 = Monday, ..., 6 = Saturday)
62
62
  *
63
- * @returns {{ startDate: Date, endDate: Date }} An object with `startDate` and `endDate`.
63
+ * @returns {{ startDate: Date, endDate: Date }} An object with `startDate` and `endDate`
64
64
  *
65
65
  * @example
66
66
  * ```typescript
@@ -123,7 +123,7 @@ export function getDateRangeFromDate(
123
123
  }
124
124
 
125
125
  break;
126
- default: throw new Error(`Unsupported date range type: ${type}.`);
126
+ default: throw new Error(`Unsupported date range type: ${type}`);
127
127
  }
128
128
 
129
129
  if (options?.setEndDateToNextDayStart) endDate.setHours(24, 0, 0, 0);
@@ -136,9 +136,9 @@ export function getDateRangeFromDate(
136
136
  /**
137
137
  * Returns a `Date` object set to midnight (00:00:00) of today, with an optional day offset.
138
138
  *
139
- * @param {number} [offsetDays] - Number of days to offset from today. Can be negative.
139
+ * @param {number} [offsetDays] - Number of days to offset from today. Can be negative
140
140
  *
141
- * @returns {Date} A `Date` object at 00:00:00 of the offset day.
141
+ * @returns {Date} A `Date` object at 00:00:00 of the offset day
142
142
  *
143
143
  * @example
144
144
  * ```typescript
@@ -10,13 +10,13 @@ export type DoNotRemoveOrUseThisType = RuleType;
10
10
  * while allowing overrides via the `options` parameter. It simplifies common
11
11
  * form validation rule creation and ensures consistency across forms.
12
12
  *
13
- * @param {string} message - The validation message to display when the rule fails.
14
- * @param {FormItemRule} [options] - Optional overrides for the rule fields.
15
- * @param {boolean} [options.required] - Whether the field is required (default: `true`).
16
- * @param {string | string[]} [options.trigger] - The event(s) that trigger validation (default: `'blur'`).
17
- * @param {RuleType} [options.type] - The expected type of the field (default: `'string'`).
13
+ * @param {string} message - The validation message to display when the rule fails
14
+ * @param {FormItemRule} [options] - Optional overrides for the rule fields
15
+ * @param {boolean} [options.required] - Whether the field is required (default: `true`)
16
+ * @param {string | string[]} [options.trigger] - The event(s) that trigger validation (default: `'blur'`)
17
+ * @param {RuleType} [options.type] - The expected type of the field (default: `'string'`)
18
18
  *
19
- * @returns A `FormItemRule` object that can be used in Element Plus form validation.
19
+ * @returns A `FormItemRule` object that can be used in Element Plus form validation
20
20
  *
21
21
  * @example
22
22
  * ```typescript
package/src/enum.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Extracts only the numeric values from an enumeration-like object.
3
3
  *
4
- * @template T - The type of the enum object.
4
+ * @template T - The type of the enum object
5
5
  *
6
- * @param {T} enumObject - The enumeration-like object to extract numeric values from.
7
- * The object can contain numeric values, string values, or both.
6
+ * @param {T} enumObject - The enumeration-like object to extract numeric values from,
7
+ * the object can contain numeric values, string values, or both.
8
8
  *
9
- * @returns {Extract<T[keyof T], number>[]} An array of numeric values extracted from the enum object.
9
+ * @returns {Extract<T[keyof T], number>[]} An array of numeric values extracted from the enum object
10
10
  *
11
11
  * @example
12
12
  * ```typescript
@@ -28,12 +28,12 @@ export function getEnumNumberValues<T extends Record<string, any>>(enumObject: T
28
28
  /**
29
29
  * Extracts only the string values from an enumeration-like object.
30
30
  *
31
- * @template T - The type of the enum object.
31
+ * @template T - The type of the enum object
32
32
  *
33
- * @param {T} enumObject - The enumeration-like object to extract string values from.
34
- * The object can contain numeric values, string values, or both.
33
+ * @param {T} enumObject - The enumeration-like object to extract string values from,
34
+ * the object can contain numeric values, string values, or both.
35
35
  *
36
- * @returns {Extract<T[keyof T], string>[]} An array of string values extracted from the enum object.
36
+ * @returns {Extract<T[keyof T], string>[]} An array of string values extracted from the enum object
37
37
  *
38
38
  * @example
39
39
  * ```typescript
@@ -59,12 +59,12 @@ export function getEnumStringValues<T extends Record<string, any>>(enumObject: T
59
59
  * that occurs with numeric enums. It works with pure numeric enums, pure string enums,
60
60
  * and mixed enums.
61
61
  *
62
- * @template T - The type of the enum object.
62
+ * @template T - The type of the enum object
63
63
  *
64
- * @param {T} enumObject - The enumeration-like object to extract values from.
65
- * The object can contain numeric values, string values, or both.
64
+ * @param {T} enumObject - The enumeration-like object to extract values from,
65
+ * the object can contain numeric values, string values, or both.
66
66
  *
67
- * @returns {(T[keyof T])[]} An array containing all the values from the enum object.
67
+ * @returns {(T[keyof T])[]} An array containing all the values from the enum object
68
68
  *
69
69
  * @example
70
70
  * ```typescript
package/src/env.ts CHANGED
@@ -11,7 +11,7 @@ export class EnvironmentNotFoundError extends Error {
11
11
  /**
12
12
  * Creates a new EnvironmentNotFoundError.
13
13
  *
14
- * @param {string} key - The missing environment variable key.
14
+ * @param {string} key - The missing environment variable key
15
15
  */
16
16
  constructor(key: string) {
17
17
  super(`Missing environment variable: ${key}`);
@@ -27,11 +27,11 @@ export class EnvironmentNotFoundError extends Error {
27
27
  * Only checks for `process.env[key] === undefined`. An empty string (e.g. '') or any falsy string
28
28
  * value like `'0'` or `'false'` is considered a valid (defined) value.
29
29
  *
30
- * @param {string} key - The environment variable key to retrieve.
30
+ * @param {string} key - The environment variable key to retrieve
31
31
  *
32
- * @returns {string} The value of the environment variable.
32
+ * @returns {string} The value of the environment variable
33
33
  *
34
- * @throws {EnvironmentNotFoundError} If the environment variable is not defined.
34
+ * @throws {EnvironmentNotFoundError} If the environment variable is not defined
35
35
  *
36
36
  * @example
37
37
  * ```typescript
package/src/general.ts CHANGED
@@ -7,13 +7,13 @@
7
7
  * - If `value` is not an array, returns `value` directly.
8
8
  * - If the result is `null` or `undefined`, and `defaultValue` is provided, returns `defaultValue` instead.
9
9
  *
10
- * @template T - The type of the input value(s).
11
- * @template D - The type of the default value (if provided).
10
+ * @template T - The type of the input value(s)
11
+ * @template D - The type of the default value (if provided)
12
12
  *
13
- * @param {T | T[]} value - A single value or an array of values.
14
- * @param {D} [defaultValue] - A fallback value if the result is `null` or `undefined`.
13
+ * @param {T | T[]} value - A single value or an array of values
14
+ * @param {D} [defaultValue] - A fallback value if the result is `null` or `undefined`
15
15
  *
16
- * @returns {T | D | undefined} The first value or the fallback.
16
+ * @returns {T | D | undefined} The first value or the fallback
17
17
  *
18
18
  * @example
19
19
  * ```typescript
package/src/math.ts CHANGED
@@ -28,11 +28,11 @@ export interface ToPercentageStringOptions {
28
28
  * - Supports custom decimal places and optional percentage symbol.
29
29
  * - Returns `'0.00%'` if result is `NaN` or division is invalid.
30
30
  *
31
- * @param {CalculableValue} molecular - The numerator of the fraction.
32
- * @param {CalculableValue} denominator - The denominator of the fraction.
33
- * @param {ToPercentageStringOptions} [options] - Optional output settings.
31
+ * @param {CalculableValue} molecular - The numerator of the fraction
32
+ * @param {CalculableValue} denominator - The denominator of the fraction
33
+ * @param {ToPercentageStringOptions} [options] - Optional output settings
34
34
  *
35
- * @returns {string} Formatted percentage string.
35
+ * @returns {string} Formatted percentage string
36
36
  *
37
37
  * @example
38
38
  * ```typescript
package/src/number.ts CHANGED
@@ -5,10 +5,10 @@ import { millify } from 'millify';
5
5
  *
6
6
  * Applies lowercase units (e.g. 'k', 'm') and default precision of 2, unless overridden.
7
7
  *
8
- * @param {number} value - The number to format.
9
- * @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`.
8
+ * @param {number} value - The number to format
9
+ * @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`
10
10
  *
11
- * @returns {string} The compact number string.
11
+ * @returns {string} The compact number string
12
12
  *
13
13
  * @example
14
14
  * ```typescript
package/src/object.ts CHANGED
@@ -8,10 +8,10 @@
8
8
  * It is designed for use cases such as signature generation, cache key construction,
9
9
  * or any context requiring consistent and predictable object serialization.
10
10
  *
11
- * @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays.
12
- * @param {string} kvSeparator - The string used to separate each key from its value (default: '=').
13
- * @param {string} pairSeparator - The string used to separate each key-value pair (default: '&').
14
- * @returns {string} A deterministic string representation of the input object.
11
+ * @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays
12
+ * @param {string} kvSeparator - The string used to separate each key from its value (default: '=')
13
+ * @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')
14
+ * @returns {string} A deterministic string representation of the input object
15
15
  *
16
16
  * @example
17
17
  * ```typescript
package/src/random.ts CHANGED
@@ -8,15 +8,15 @@
8
8
  *
9
9
  * This function supports any return type by using a generic type parameter.
10
10
  *
11
- * @template T - The return type of the generator function.
11
+ * @template T - The return type of the generator function
12
12
  *
13
- * @param {(length: number) => T} generator - A function that accepts a length and returns a value of type T.
14
- * @param {number} minMin - Lower bound of the first random range.
15
- * @param {number} minMax - Upper bound of the first random range.
16
- * @param {number} maxMin - Lower bound of the second random range.
17
- * @param {number} maxMax - Upper bound of the second random range.
13
+ * @param {(length: number) => T} generator - A function that accepts a length and returns a value of type T
14
+ * @param {number} minMin - Lower bound of the first random range
15
+ * @param {number} minMax - Upper bound of the first random range
16
+ * @param {number} maxMin - Lower bound of the second random range
17
+ * @param {number} maxMax - Upper bound of the second random range
18
18
  *
19
- * @returns {T} The result of the generator function using the computed final length.
19
+ * @returns {T} The result of the generator function using the computed final length
20
20
  */
21
21
  export function generateWithNestedRandomLength<T = string>(
22
22
  generator: (length: number) => T,