@choksheak/ts-utils 0.3.6 → 0.3.7

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 (256) hide show
  1. package/arrayBuffer.cjs +39 -10
  2. package/arrayBuffer.min.cjs +1 -1
  3. package/arrayBuffer.min.cjs.map +1 -1
  4. package/arrayBuffer.min.mjs +1 -1
  5. package/arrayBuffer.min.mjs.map +1 -1
  6. package/arrayBuffer.mjs +10 -7
  7. package/asNumber.cjs +38 -6
  8. package/asNumber.min.cjs +1 -1
  9. package/asNumber.min.cjs.map +1 -1
  10. package/asNumber.min.mjs +1 -1
  11. package/asNumber.min.mjs.map +1 -1
  12. package/asNumber.mjs +11 -4
  13. package/assert.cjs +27 -4
  14. package/assert.min.cjs +1 -1
  15. package/assert.min.cjs.map +1 -1
  16. package/assert.min.mjs +1 -1
  17. package/assert.min.mjs.map +1 -1
  18. package/assert.mjs +0 -2
  19. package/base64Url.cjs +29 -5
  20. package/base64Url.min.cjs +1 -1
  21. package/base64Url.min.cjs.map +1 -1
  22. package/base64Url.min.mjs +1 -1
  23. package/base64Url.min.mjs.map +1 -1
  24. package/base64Url.mjs +0 -2
  25. package/capLength.cjs +71 -7
  26. package/capLength.min.cjs +5 -1
  27. package/capLength.min.cjs.map +1 -1
  28. package/capLength.min.mjs +5 -1
  29. package/capLength.min.mjs.map +1 -1
  30. package/capLength.mjs +41 -4
  31. package/concatIterators.cjs +27 -4
  32. package/concatIterators.min.cjs +1 -1
  33. package/concatIterators.min.cjs.map +1 -1
  34. package/concatIterators.min.mjs +1 -1
  35. package/concatIterators.min.mjs.map +1 -1
  36. package/concatIterators.mjs +0 -2
  37. package/dateTimeStr.cjs +119 -31
  38. package/dateTimeStr.min.cjs +1 -1
  39. package/dateTimeStr.min.cjs.map +1 -1
  40. package/dateTimeStr.min.mjs +1 -1
  41. package/dateTimeStr.min.mjs.map +1 -1
  42. package/dateTimeStr.mjs +69 -17
  43. package/duration.cjs +188 -24
  44. package/duration.min.cjs +1 -1
  45. package/duration.min.cjs.map +1 -1
  46. package/duration.min.mjs +1 -1
  47. package/duration.min.mjs.map +1 -1
  48. package/duration.mjs +144 -14
  49. package/getEnv.cjs +31 -7
  50. package/getEnv.min.cjs +1 -1
  51. package/getEnv.min.cjs.map +1 -1
  52. package/getEnv.min.mjs +1 -1
  53. package/getEnv.min.mjs.map +1 -1
  54. package/getEnv.mjs +0 -2
  55. package/isEmpty.cjs +46 -8
  56. package/isEmpty.min.cjs +1 -1
  57. package/isEmpty.min.cjs.map +1 -1
  58. package/isEmpty.min.mjs +1 -1
  59. package/isEmpty.min.mjs.map +1 -1
  60. package/isEmpty.mjs +19 -6
  61. package/isPromise.cjs +29 -5
  62. package/isPromise.min.cjs +1 -1
  63. package/isPromise.min.cjs.map +1 -1
  64. package/isPromise.min.mjs +1 -1
  65. package/isPromise.min.mjs.map +1 -1
  66. package/isPromise.mjs +0 -2
  67. package/kvStore.cjs +353 -15
  68. package/kvStore.min.cjs +1 -1
  69. package/kvStore.min.cjs.map +1 -1
  70. package/kvStore.min.mjs +1 -1
  71. package/kvStore.min.mjs.map +1 -1
  72. package/kvStore.mjs +319 -12
  73. package/localStore.cjs +264 -15
  74. package/localStore.min.cjs +1 -1
  75. package/localStore.min.cjs.map +1 -1
  76. package/localStore.min.mjs +1 -1
  77. package/localStore.min.mjs.map +1 -1
  78. package/localStore.mjs +230 -12
  79. package/mean.cjs +48 -8
  80. package/mean.min.cjs +1 -1
  81. package/mean.min.cjs.map +1 -1
  82. package/mean.min.mjs +1 -1
  83. package/mean.min.mjs.map +1 -1
  84. package/mean.mjs +18 -5
  85. package/median.cjs +41 -7
  86. package/median.min.cjs +1 -1
  87. package/median.min.cjs.map +1 -1
  88. package/median.min.mjs +1 -1
  89. package/median.min.mjs.map +1 -1
  90. package/median.mjs +11 -4
  91. package/nonEmpty.cjs +48 -8
  92. package/nonEmpty.min.cjs +1 -1
  93. package/nonEmpty.min.cjs.map +1 -1
  94. package/nonEmpty.min.mjs +1 -1
  95. package/nonEmpty.min.mjs.map +1 -1
  96. package/nonEmpty.mjs +19 -6
  97. package/nonNil.cjs +27 -4
  98. package/nonNil.min.cjs +1 -1
  99. package/nonNil.min.cjs.map +1 -1
  100. package/nonNil.min.mjs +1 -1
  101. package/nonNil.min.mjs.map +1 -1
  102. package/nonNil.mjs +0 -2
  103. package/package.json +1 -257
  104. package/round.cjs +32 -6
  105. package/round.min.cjs +1 -1
  106. package/round.min.cjs.map +1 -1
  107. package/round.min.mjs +1 -1
  108. package/round.min.mjs.map +1 -1
  109. package/round.mjs +5 -4
  110. package/roundToString.cjs +35 -7
  111. package/roundToString.min.cjs +1 -1
  112. package/roundToString.min.cjs.map +1 -1
  113. package/roundToString.min.mjs +1 -1
  114. package/roundToString.min.mjs.map +1 -1
  115. package/roundToString.mjs +5 -4
  116. package/safeBtoa.cjs +27 -4
  117. package/safeBtoa.min.cjs +1 -1
  118. package/safeBtoa.min.cjs.map +1 -1
  119. package/safeBtoa.min.mjs +1 -1
  120. package/safeBtoa.min.mjs.map +1 -1
  121. package/safeBtoa.mjs +0 -2
  122. package/sha256.cjs +34 -8
  123. package/sha256.min.cjs +1 -1
  124. package/sha256.min.cjs.map +1 -1
  125. package/sha256.min.mjs +1 -1
  126. package/sha256.min.mjs.map +1 -1
  127. package/sha256.mjs +7 -6
  128. package/sleep.cjs +27 -4
  129. package/sleep.min.cjs +1 -1
  130. package/sleep.min.cjs.map +1 -1
  131. package/sleep.min.mjs +1 -1
  132. package/sleep.min.mjs.map +1 -1
  133. package/sleep.mjs +0 -2
  134. package/storageAdapter.cjs +18 -1
  135. package/storageAdapter.min.cjs +2 -1
  136. package/storageAdapter.min.cjs.map +1 -1
  137. package/sum.cjs +45 -5
  138. package/sum.min.cjs +1 -1
  139. package/sum.min.cjs.map +1 -1
  140. package/sum.min.mjs +1 -1
  141. package/sum.min.mjs.map +1 -1
  142. package/sum.mjs +18 -5
  143. package/timeConstants.cjs +69 -35
  144. package/timeConstants.min.cjs +1 -1
  145. package/timeConstants.min.cjs.map +1 -1
  146. package/timeConstants.min.mjs +1 -1
  147. package/timeConstants.min.mjs.map +1 -1
  148. package/timeConstants.mjs +15 -19
  149. package/timer.cjs +180 -7
  150. package/timer.min.cjs +1 -1
  151. package/timer.min.cjs.map +1 -1
  152. package/timer.min.mjs +1 -1
  153. package/timer.min.mjs.map +1 -1
  154. package/timer.mjs +154 -8
  155. package/toReadableString.cjs +68 -6
  156. package/toReadableString.min.cjs +5 -1
  157. package/toReadableString.min.cjs.map +1 -1
  158. package/toReadableString.min.mjs +5 -1
  159. package/toReadableString.min.mjs.map +1 -1
  160. package/toReadableString.mjs +41 -4
  161. package/chunk-22JDWCOS.min.cjs +0 -2
  162. package/chunk-22JDWCOS.min.cjs.map +0 -1
  163. package/chunk-244NBT4Q.min.mjs +0 -2
  164. package/chunk-244NBT4Q.min.mjs.map +0 -1
  165. package/chunk-27MBP3ES.min.cjs +0 -2
  166. package/chunk-27MBP3ES.min.cjs.map +0 -1
  167. package/chunk-34ENP2B3.min.mjs +0 -438
  168. package/chunk-34ENP2B3.min.mjs.map +0 -1
  169. package/chunk-3EBQ2GO2.min.cjs +0 -2
  170. package/chunk-3EBQ2GO2.min.cjs.map +0 -1
  171. package/chunk-4GLOLTJ5.cjs +0 -167
  172. package/chunk-6TQBMXTL.min.cjs +0 -2
  173. package/chunk-6TQBMXTL.min.cjs.map +0 -1
  174. package/chunk-AWZBCFMG.min.cjs +0 -2
  175. package/chunk-AWZBCFMG.min.cjs.map +0 -1
  176. package/chunk-AXNETZET.cjs +0 -20
  177. package/chunk-BKZM6NWX.min.cjs +0 -2
  178. package/chunk-BKZM6NWX.min.cjs.map +0 -1
  179. package/chunk-BZKQXX3A.cjs +0 -40
  180. package/chunk-CERFUU5I.cjs +0 -93
  181. package/chunk-CSTKFJ6G.mjs +0 -239
  182. package/chunk-DUN4UY2Q.cjs +0 -239
  183. package/chunk-EDJJUP4K.min.cjs +0 -6
  184. package/chunk-EDJJUP4K.min.cjs.map +0 -1
  185. package/chunk-FFNQBZH5.cjs +0 -14
  186. package/chunk-FZZRSHSH.min.mjs +0 -6
  187. package/chunk-FZZRSHSH.min.mjs.map +0 -1
  188. package/chunk-GAP2HS5M.min.cjs +0 -2
  189. package/chunk-GAP2HS5M.min.cjs.map +0 -1
  190. package/chunk-GLYMAPS4.min.mjs +0 -2
  191. package/chunk-GLYMAPS4.min.mjs.map +0 -1
  192. package/chunk-I65KPVMO.min.cjs +0 -438
  193. package/chunk-I65KPVMO.min.cjs.map +0 -1
  194. package/chunk-ILGTU46T.cjs +0 -39
  195. package/chunk-IOKRXHKE.min.mjs +0 -2
  196. package/chunk-IOKRXHKE.min.mjs.map +0 -1
  197. package/chunk-ISP4SMRC.min.cjs +0 -2
  198. package/chunk-ISP4SMRC.min.cjs.map +0 -1
  199. package/chunk-KETP5HBF.cjs +0 -24
  200. package/chunk-KLHNGJ4Y.min.mjs +0 -2
  201. package/chunk-KLHNGJ4Y.min.mjs.map +0 -1
  202. package/chunk-KMNTU3DJ.mjs +0 -45
  203. package/chunk-LDVEXETI.cjs +0 -45
  204. package/chunk-LZENHV35.min.cjs +0 -2
  205. package/chunk-LZENHV35.min.cjs.map +0 -1
  206. package/chunk-M5PIM2HB.mjs +0 -42
  207. package/chunk-M6PYQYOX.mjs +0 -39
  208. package/chunk-MN5EYNZN.min.mjs +0 -2
  209. package/chunk-MN5EYNZN.min.mjs.map +0 -1
  210. package/chunk-NRIBJ2OJ.mjs +0 -16031
  211. package/chunk-NVLYXWLX.cjs +0 -32
  212. package/chunk-O352F2MT.mjs +0 -24
  213. package/chunk-O6B2TKFK.min.mjs +0 -2
  214. package/chunk-O6B2TKFK.min.mjs.map +0 -1
  215. package/chunk-OGF34H4T.min.cjs +0 -2
  216. package/chunk-OGF34H4T.min.cjs.map +0 -1
  217. package/chunk-OXSWWWOM.min.mjs +0 -2
  218. package/chunk-OXSWWWOM.min.mjs.map +0 -1
  219. package/chunk-PRUGHVRT.mjs +0 -14
  220. package/chunk-Q4WCMSOW.min.mjs +0 -2
  221. package/chunk-Q4WCMSOW.min.mjs.map +0 -1
  222. package/chunk-QH74JZCK.mjs +0 -9
  223. package/chunk-QNNJNLGK.min.cjs +0 -2
  224. package/chunk-QNNJNLGK.min.cjs.map +0 -1
  225. package/chunk-QWCFN7ZM.mjs +0 -15
  226. package/chunk-SDM2OPT6.mjs +0 -32
  227. package/chunk-SHKRZCF2.cjs +0 -16031
  228. package/chunk-SJDJDNDN.min.cjs +0 -2
  229. package/chunk-SJDJDNDN.min.cjs.map +0 -1
  230. package/chunk-SULNMALN.cjs +0 -328
  231. package/chunk-SV35RBZ7.min.mjs +0 -2
  232. package/chunk-SV35RBZ7.min.mjs.map +0 -1
  233. package/chunk-TJFYGFOW.mjs +0 -328
  234. package/chunk-UHRYBUUX.min.mjs +0 -2
  235. package/chunk-UHRYBUUX.min.mjs.map +0 -1
  236. package/chunk-UOU6IP3S.min.mjs +0 -2
  237. package/chunk-UOU6IP3S.min.mjs.map +0 -1
  238. package/chunk-V76XVNZ5.mjs +0 -20
  239. package/chunk-VFYQ7I5V.min.mjs +0 -2
  240. package/chunk-VFYQ7I5V.min.mjs.map +0 -1
  241. package/chunk-VG7VV7J2.mjs +0 -167
  242. package/chunk-VJCV56DO.cjs +0 -15
  243. package/chunk-VREA6AKG.cjs +0 -9
  244. package/chunk-W5I6Y5FK.min.mjs +0 -2
  245. package/chunk-W5I6Y5FK.min.mjs.map +0 -1
  246. package/chunk-Y7MC73BZ.cjs +0 -42
  247. package/chunk-YVWROQKU.mjs +0 -40
  248. package/chunk-ZKIZ5SWK.min.cjs +0 -2
  249. package/chunk-ZKIZ5SWK.min.cjs.map +0 -1
  250. package/chunk-ZZZB7NJX.mjs +0 -93
  251. package/magic-string.es-4UY437WL.min.mjs +0 -14
  252. package/magic-string.es-4UY437WL.min.mjs.map +0 -1
  253. package/magic-string.es-OAQWZQTY.mjs +0 -1323
  254. package/magic-string.es-UE2UVQEL.cjs +0 -1323
  255. package/magic-string.es-X6DNUB6Y.min.cjs +0 -14
  256. package/magic-string.es-X6DNUB6Y.min.cjs.map +0 -1
@@ -1,39 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __esm = (fn, res) => function __init() {
8
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
- };
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
13
- var __export = (target, all) => {
14
- for (var name in all)
15
- __defProp(target, name, { get: all[name], enumerable: true });
16
- };
17
- var __copyProps = (to, from, except, desc) => {
18
- if (from && typeof from === "object" || typeof from === "function") {
19
- for (let key of __getOwnPropNames(from))
20
- if (!__hasOwnProp.call(to, key) && key !== except)
21
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
- }
23
- return to;
24
- };
25
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
- // If the importer is in node compatibility mode or this is not an ESM
27
- // file that has been converted to a CommonJS file using a Babel-
28
- // compatible transform (i.e. "__esModule" has not been set), then set
29
- // "default" to the CommonJS "module.exports" for node compatibility.
30
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
- mod
32
- ));
33
-
34
-
35
-
36
-
37
-
38
-
39
- exports.__esm = __esm; exports.__commonJS = __commonJS; exports.__export = __export; exports.__toESM = __toESM;
@@ -1,2 +0,0 @@
1
- import{a as n}from"./chunk-UOU6IP3S.min.mjs";async function c(r){let e=new TextEncoder().encode(r);return await crypto.subtle.digest("SHA-256",e)}var t=n(()=>{});export{c as a,t as b};
2
- //# sourceMappingURL=chunk-IOKRXHKE.min.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/sha256.ts"],"sourcesContent":["/**\n * SHA-256 hash an input string into an ArrayBuffer.\n */\nexport async function sha256(input: string): Promise<ArrayBuffer> {\n // Encode the input string as a Uint8Array\n const encoder = new TextEncoder();\n const uint8Array = encoder.encode(input);\n\n // Compute the SHA-256 hash using the SubtleCrypto API\n const arrayBuffer = await crypto.subtle.digest(\"SHA-256\", uint8Array);\n\n return arrayBuffer;\n}\n"],"mappings":"6CAGA,eAAsBA,EAAOC,EAAqC,CAGhE,IAAMC,EADU,IAAI,YAAY,EACL,OAAOD,CAAK,EAKvC,OAFoB,MAAM,OAAO,OAAO,OAAO,UAAWC,CAAU,CAGtE,CAZA,IAAAC,EAAAC,EAAA","names":["sha256","input","uint8Array","init_sha256","__esmMin"]}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQNNJNLGKmincjs = require('./chunk-QNNJNLGK.min.cjs');function f(r){let t=new Uint8Array(r);return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("")}function i(r){let t=new Uint8Array(r),n=Array.from(t).map(a=>String.fromCodePoint(a)).join("");return btoa(n)}var e=_chunkQNNJNLGKmincjs.a.call(void 0, ()=>{});exports.a = f; exports.b = i; exports.c = e;
2
- //# sourceMappingURL=chunk-ISP4SMRC.min.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/choksheaklau/src/ts-utils/dist/chunk-ISP4SMRC.min.cjs","../src/arrayBuffer.ts"],"names":["arrayBufferToHex","buffer","byteArray","byte","arrayBufferToBase64","binaryString","init_arrayBuffer","__esmMin"],"mappings":"AAAA,wIAA4C,SCG5BA,CAAAA,CAAiBC,CAAAA,CAA6B,CAE5D,IAAMC,CAAAA,CAAY,IAAI,UAAA,CAAWD,CAAM,CAAA,CAGvC,OAAO,KAAA,CAAM,IAAA,CAAKC,CAAS,CAAA,CACxB,GAAA,CAAKC,CAAAA,EAASA,CAAAA,CAAK,QAAA,CAAS,EAAE,CAAA,CAAE,QAAA,CAAS,CAAA,CAAG,GAAG,CAAC,CAAA,CAChD,IAAA,CAAK,EAAE,CACZ,CAKO,SAASC,CAAAA,CAAoBH,CAAAA,CAA6B,CAE/D,IAAMC,CAAAA,CAAY,IAAI,UAAA,CAAWD,CAAM,CAAA,CAGjCI,CAAAA,CAAe,KAAA,CAAM,IAAA,CAAKH,CAAS,CAAA,CACtC,GAAA,CAAKC,CAAAA,EAAS,MAAA,CAAO,aAAA,CAAcA,CAAI,CAAC,CAAA,CACxC,IAAA,CAAK,EAAE,CAAA,CAIV,OAAO,IAAA,CAAKE,CAAY,CAC1B,CA5BA,IAAAC,CAAAA,CAAAC,oCAAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,4CAAA","file":"/Users/choksheaklau/src/ts-utils/dist/chunk-ISP4SMRC.min.cjs","sourcesContent":[null,"/**\n * Encode an input ArrayBuffer into a hex string.\n */\nexport function arrayBufferToHex(buffer: ArrayBuffer): string {\n // Create a Uint8Array view of the ArrayBuffer\n const byteArray = new Uint8Array(buffer);\n\n // Convert each byte to a two-character hexadecimal string\n return Array.from(byteArray)\n .map((byte) => byte.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\n/**\n * Encode an input ArrayBuffer into a base64 string.\n */\nexport function arrayBufferToBase64(buffer: ArrayBuffer): string {\n // Convert the ArrayBuffer to a Uint8Array\n const byteArray = new Uint8Array(buffer);\n\n // Create a binary string from the byte array\n const binaryString = Array.from(byteArray)\n .map((byte) => String.fromCodePoint(byte))\n .join(\"\");\n\n // Encode the binary string to base64. No need to use safeBtoa because we\n // already simplified the binary input above.\n return btoa(binaryString);\n}\n"]}
@@ -1,24 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkILGTU46Tcjs = require('./chunk-ILGTU46T.cjs');
4
-
5
- // src/arrayBuffer.ts
6
- function arrayBufferToHex(buffer) {
7
- const byteArray = new Uint8Array(buffer);
8
- return Array.from(byteArray).map((byte) => byte.toString(16).padStart(2, "0")).join("");
9
- }
10
- function arrayBufferToBase64(buffer) {
11
- const byteArray = new Uint8Array(buffer);
12
- const binaryString = Array.from(byteArray).map((byte) => String.fromCodePoint(byte)).join("");
13
- return btoa(binaryString);
14
- }
15
- var init_arrayBuffer = _chunkILGTU46Tcjs.__esm.call(void 0, {
16
- "src/arrayBuffer.ts"() {
17
- }
18
- });
19
-
20
-
21
-
22
-
23
-
24
- exports.arrayBufferToHex = arrayBufferToHex; exports.arrayBufferToBase64 = arrayBufferToBase64; exports.init_arrayBuffer = init_arrayBuffer;
@@ -1,2 +0,0 @@
1
- function e(n,r=0){return typeof n=="number"?isFinite(n)?n:r:(n=Number(n),typeof n=="number"&&isFinite(n)?n:r)}export{e as a};
2
- //# sourceMappingURL=chunk-KLHNGJ4Y.min.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/asNumber.ts"],"sourcesContent":["/**\n * Coerce `u` into a number if possible, otherwise just return 0.\n */\nexport function asNumber(u: unknown, defaultValue = 0): number {\n // If u is a valid number, return it.\n if (typeof u === \"number\") {\n return isFinite(u) ? u : defaultValue;\n }\n\n // Try to make into a number if not already a number.\n u = Number(u);\n\n // If u is a valid number, return it.\n if (typeof u === \"number\" && isFinite(u)) {\n return u;\n }\n\n // Return `defaultValue` for everything else. This is usually ok if want to\n // just ignore all other noise.\n return defaultValue;\n}\n"],"mappings":"AAGO,SAASA,EAASC,EAAYC,EAAe,EAAW,CAE7D,OAAI,OAAOD,GAAM,SACR,SAASA,CAAC,EAAIA,EAAIC,GAI3BD,EAAI,OAAOA,CAAC,EAGR,OAAOA,GAAM,UAAY,SAASA,CAAC,EAC9BA,EAKFC,EACT","names":["asNumber","u","defaultValue"]}
@@ -1,45 +0,0 @@
1
- // src/toReadableString.ts
2
- function toReadableString(u, options) {
3
- if (typeof u === "string") {
4
- return u;
5
- }
6
- if (u instanceof Error) {
7
- const error = u;
8
- let result = "";
9
- const errorName = error.name || "Error";
10
- const errorMessage = error.message || "An error occurred with no message provided.";
11
- result += `${errorName}: ${errorMessage}`;
12
- if (options?.includeStack && error.stack) {
13
- const stack = error.stack.replace(new RegExp(`^${errorName}:.*\\n?`), "").trim();
14
- if (stack) {
15
- result += `
16
- Stack Trace:
17
- ${stack}`;
18
- }
19
- }
20
- if (options?.includeErrorProps) {
21
- const customProps = error;
22
- const additionalInfo = Object.keys(customProps).filter(
23
- (key) => key !== "name" && key !== "message" && key !== "stack" && typeof customProps[key] !== "function" && typeof customProps[key] !== "object"
24
- ).map((key) => `
25
- - ${key}: ${customProps[key]}`);
26
- if (additionalInfo.length > 0) {
27
- result += `
28
- Additional Data:${additionalInfo.join("")}`;
29
- }
30
- }
31
- return result;
32
- }
33
- if (u !== null && typeof u === "object" && u.toString !== Object.prototype.toString) {
34
- return u.toString();
35
- }
36
- try {
37
- return JSON.stringify(u);
38
- } catch {
39
- return String(u);
40
- }
41
- }
42
-
43
- export {
44
- toReadableString
45
- };
@@ -1,45 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/toReadableString.ts
2
- function toReadableString(u, options) {
3
- if (typeof u === "string") {
4
- return u;
5
- }
6
- if (u instanceof Error) {
7
- const error = u;
8
- let result = "";
9
- const errorName = error.name || "Error";
10
- const errorMessage = error.message || "An error occurred with no message provided.";
11
- result += `${errorName}: ${errorMessage}`;
12
- if (_optionalChain([options, 'optionalAccess', _ => _.includeStack]) && error.stack) {
13
- const stack = error.stack.replace(new RegExp(`^${errorName}:.*\\n?`), "").trim();
14
- if (stack) {
15
- result += `
16
- Stack Trace:
17
- ${stack}`;
18
- }
19
- }
20
- if (_optionalChain([options, 'optionalAccess', _2 => _2.includeErrorProps])) {
21
- const customProps = error;
22
- const additionalInfo = Object.keys(customProps).filter(
23
- (key) => key !== "name" && key !== "message" && key !== "stack" && typeof customProps[key] !== "function" && typeof customProps[key] !== "object"
24
- ).map((key) => `
25
- - ${key}: ${customProps[key]}`);
26
- if (additionalInfo.length > 0) {
27
- result += `
28
- Additional Data:${additionalInfo.join("")}`;
29
- }
30
- }
31
- return result;
32
- }
33
- if (u !== null && typeof u === "object" && u.toString !== Object.prototype.toString) {
34
- return u.toString();
35
- }
36
- try {
37
- return JSON.stringify(u);
38
- } catch (e) {
39
- return String(u);
40
- }
41
- }
42
-
43
-
44
-
45
- exports.toReadableString = toReadableString;
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkAWZBCFMGmincjs = require('./chunk-AWZBCFMG.min.cjs');function o(r){return r.reduce((u,e)=>u+_chunkAWZBCFMGmincjs.a.call(void 0, e),0)}exports.a = o;
2
- //# sourceMappingURL=chunk-LZENHV35.min.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/choksheaklau/src/ts-utils/dist/chunk-LZENHV35.min.cjs","../src/sum.ts"],"names":["sum","numbers","accumulated","current","asNumber"],"mappings":"AAAA,wIAA4C,SCM5BA,CAAAA,CAAIC,CAAAA,CAA4B,CAC9C,OAAOA,CAAAA,CAAQ,MAAA,CAAO,CAACC,CAAAA,CAAqBC,CAAAA,CAAAA,EACnCD,CAAAA,CAAcE,oCAAAA,CAAgB,CAAA,CACpC,CAAC,CACN,CAAA,cAAA","file":"/Users/choksheaklau/src/ts-utils/dist/chunk-LZENHV35.min.cjs","sourcesContent":[null,"import { asNumber } from \"./asNumber\";\n\n/**\n * Add all the numbers together in the given array.\n * Non-numbers will be coerced into numbers if possible.\n */\nexport function sum(numbers: unknown[]): number {\n return numbers.reduce((accumulated: number, current: unknown) => {\n return accumulated + asNumber(current);\n }, 0);\n}\n"]}
@@ -1,42 +0,0 @@
1
- import {
2
- __esm
3
- } from "./chunk-M6PYQYOX.mjs";
4
-
5
- // src/timeConstants.ts
6
- var MS_PER_SECOND, MS_PER_MINUTE, MS_PER_HOUR, MS_PER_DAY, MS_PER_WEEK, SECONDS_PER_MINUTE, SECONDS_PER_HOUR, SECONDS_PER_DAY, SECONDS_PER_WEEK, MINUTES_PER_HOUR, MINUTES_PER_DAY, MINUTES_PER_WEEK, HOURS_PER_DAY, HOURS_PER_WEEK;
7
- var init_timeConstants = __esm({
8
- "src/timeConstants.ts"() {
9
- MS_PER_SECOND = 1e3;
10
- MS_PER_MINUTE = 6e4;
11
- MS_PER_HOUR = 36e5;
12
- MS_PER_DAY = 864e5;
13
- MS_PER_WEEK = 6048e5;
14
- SECONDS_PER_MINUTE = 60;
15
- SECONDS_PER_HOUR = 3600;
16
- SECONDS_PER_DAY = 86400;
17
- SECONDS_PER_WEEK = 604800;
18
- MINUTES_PER_HOUR = 60;
19
- MINUTES_PER_DAY = 1440;
20
- MINUTES_PER_WEEK = 10080;
21
- HOURS_PER_DAY = 24;
22
- HOURS_PER_WEEK = 168;
23
- }
24
- });
25
-
26
- export {
27
- MS_PER_SECOND,
28
- MS_PER_MINUTE,
29
- MS_PER_HOUR,
30
- MS_PER_DAY,
31
- MS_PER_WEEK,
32
- SECONDS_PER_MINUTE,
33
- SECONDS_PER_HOUR,
34
- SECONDS_PER_DAY,
35
- SECONDS_PER_WEEK,
36
- MINUTES_PER_HOUR,
37
- MINUTES_PER_DAY,
38
- MINUTES_PER_WEEK,
39
- HOURS_PER_DAY,
40
- HOURS_PER_WEEK,
41
- init_timeConstants
42
- };
@@ -1,39 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __esm = (fn, res) => function __init() {
8
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
- };
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
13
- var __export = (target, all) => {
14
- for (var name in all)
15
- __defProp(target, name, { get: all[name], enumerable: true });
16
- };
17
- var __copyProps = (to, from, except, desc) => {
18
- if (from && typeof from === "object" || typeof from === "function") {
19
- for (let key of __getOwnPropNames(from))
20
- if (!__hasOwnProp.call(to, key) && key !== except)
21
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
- }
23
- return to;
24
- };
25
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
- // If the importer is in node compatibility mode or this is not an ESM
27
- // file that has been converted to a CommonJS file using a Babel-
28
- // compatible transform (i.e. "__esModule" has not been set), then set
29
- // "default" to the CommonJS "module.exports" for node compatibility.
30
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
- mod
32
- ));
33
-
34
- export {
35
- __esm,
36
- __commonJS,
37
- __export,
38
- __toESM
39
- };
@@ -1,2 +0,0 @@
1
- import{a as _}from"./chunk-UOU6IP3S.min.mjs";var o,t,R,S,c,e,n,p,r,s,x,P,M,N,E=_(()=>{o=1e3,t=6e4,R=36e5,S=864e5,c=6048e5,e=60,n=3600,p=86400,r=604800,s=60,x=1440,P=10080,M=24,N=168});export{o as a,t as b,R as c,S as d,c as e,e as f,n as g,p as h,r as i,s as j,x as k,P as l,M as m,N as n,E as o};
2
- //# sourceMappingURL=chunk-MN5EYNZN.min.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/timeConstants.ts"],"sourcesContent":["/**\n * Note that month and year do not have fixed durations, and hence are excluded\n * from this file.\n */\n\nexport const MS_PER_SECOND = 1000;\nexport const MS_PER_MINUTE = 60_000;\nexport const MS_PER_HOUR = 3_600_000;\nexport const MS_PER_DAY = 86_400_000;\nexport const MS_PER_WEEK = 604_800_000;\n\nexport const SECONDS_PER_MINUTE = 60;\nexport const SECONDS_PER_HOUR = 3_600;\nexport const SECONDS_PER_DAY = 86_400;\nexport const SECONDS_PER_WEEK = 604_800;\n\nexport const MINUTES_PER_HOUR = 60;\nexport const MINUTES_PER_DAY = 1440;\nexport const MINUTES_PER_WEEK = 10_080;\n\nexport const HOURS_PER_DAY = 24;\nexport const HOURS_PER_WEEK = 168;\n"],"mappings":"6CAAA,IAKaA,EACAC,EACAC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EAEAC,EACAC,EACAC,EAEAC,EACAC,EArBbC,EAAAC,EAAA,KAKaf,EAAgB,IAChBC,EAAgB,IAChBC,EAAc,KACdC,EAAa,MACbC,EAAc,OAEdC,EAAqB,GACrBC,EAAmB,KACnBC,EAAkB,MAClBC,EAAmB,OAEnBC,EAAmB,GACnBC,EAAkB,KAClBC,EAAmB,MAEnBC,EAAgB,GAChBC,EAAiB","names":["MS_PER_SECOND","MS_PER_MINUTE","MS_PER_HOUR","MS_PER_DAY","MS_PER_WEEK","SECONDS_PER_MINUTE","SECONDS_PER_HOUR","SECONDS_PER_DAY","SECONDS_PER_WEEK","MINUTES_PER_HOUR","MINUTES_PER_DAY","MINUTES_PER_WEEK","HOURS_PER_DAY","HOURS_PER_WEEK","init_timeConstants","__esmMin"]}