@choksheak/ts-utils 0.3.5 → 0.3.6

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 (258) hide show
  1. package/arrayBuffer.cjs +10 -39
  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 +7 -10
  7. package/asNumber.cjs +6 -38
  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 +4 -11
  13. package/assert.cjs +4 -27
  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 +2 -0
  19. package/base64Url.cjs +5 -29
  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 +2 -0
  25. package/capLength.cjs +7 -71
  26. package/capLength.min.cjs +1 -5
  27. package/capLength.min.cjs.map +1 -1
  28. package/capLength.min.mjs +1 -5
  29. package/capLength.min.mjs.map +1 -1
  30. package/capLength.mjs +4 -41
  31. package/chunk-22JDWCOS.min.cjs +2 -0
  32. package/chunk-22JDWCOS.min.cjs.map +1 -0
  33. package/chunk-244NBT4Q.min.mjs +2 -0
  34. package/chunk-244NBT4Q.min.mjs.map +1 -0
  35. package/chunk-27MBP3ES.min.cjs +2 -0
  36. package/chunk-27MBP3ES.min.cjs.map +1 -0
  37. package/chunk-34ENP2B3.min.mjs +438 -0
  38. package/chunk-34ENP2B3.min.mjs.map +1 -0
  39. package/chunk-3EBQ2GO2.min.cjs +2 -0
  40. package/chunk-3EBQ2GO2.min.cjs.map +1 -0
  41. package/chunk-4GLOLTJ5.cjs +167 -0
  42. package/chunk-6TQBMXTL.min.cjs +2 -0
  43. package/chunk-6TQBMXTL.min.cjs.map +1 -0
  44. package/chunk-AWZBCFMG.min.cjs +2 -0
  45. package/chunk-AWZBCFMG.min.cjs.map +1 -0
  46. package/chunk-AXNETZET.cjs +20 -0
  47. package/chunk-BKZM6NWX.min.cjs +2 -0
  48. package/chunk-BKZM6NWX.min.cjs.map +1 -0
  49. package/chunk-BZKQXX3A.cjs +40 -0
  50. package/chunk-CERFUU5I.cjs +93 -0
  51. package/chunk-CSTKFJ6G.mjs +239 -0
  52. package/chunk-DUN4UY2Q.cjs +239 -0
  53. package/chunk-EDJJUP4K.min.cjs +6 -0
  54. package/chunk-EDJJUP4K.min.cjs.map +1 -0
  55. package/chunk-FFNQBZH5.cjs +14 -0
  56. package/chunk-FZZRSHSH.min.mjs +6 -0
  57. package/chunk-FZZRSHSH.min.mjs.map +1 -0
  58. package/chunk-GAP2HS5M.min.cjs +2 -0
  59. package/chunk-GAP2HS5M.min.cjs.map +1 -0
  60. package/chunk-GLYMAPS4.min.mjs +2 -0
  61. package/chunk-GLYMAPS4.min.mjs.map +1 -0
  62. package/chunk-I65KPVMO.min.cjs +438 -0
  63. package/chunk-I65KPVMO.min.cjs.map +1 -0
  64. package/chunk-ILGTU46T.cjs +39 -0
  65. package/chunk-IOKRXHKE.min.mjs +2 -0
  66. package/chunk-IOKRXHKE.min.mjs.map +1 -0
  67. package/chunk-ISP4SMRC.min.cjs +2 -0
  68. package/chunk-ISP4SMRC.min.cjs.map +1 -0
  69. package/chunk-KETP5HBF.cjs +24 -0
  70. package/chunk-KLHNGJ4Y.min.mjs +2 -0
  71. package/chunk-KLHNGJ4Y.min.mjs.map +1 -0
  72. package/chunk-KMNTU3DJ.mjs +45 -0
  73. package/chunk-LDVEXETI.cjs +45 -0
  74. package/chunk-LZENHV35.min.cjs +2 -0
  75. package/chunk-LZENHV35.min.cjs.map +1 -0
  76. package/chunk-M5PIM2HB.mjs +42 -0
  77. package/chunk-M6PYQYOX.mjs +39 -0
  78. package/chunk-MN5EYNZN.min.mjs +2 -0
  79. package/chunk-MN5EYNZN.min.mjs.map +1 -0
  80. package/chunk-NRIBJ2OJ.mjs +16031 -0
  81. package/chunk-NVLYXWLX.cjs +32 -0
  82. package/chunk-O352F2MT.mjs +24 -0
  83. package/chunk-O6B2TKFK.min.mjs +2 -0
  84. package/chunk-O6B2TKFK.min.mjs.map +1 -0
  85. package/chunk-OGF34H4T.min.cjs +2 -0
  86. package/chunk-OGF34H4T.min.cjs.map +1 -0
  87. package/chunk-OXSWWWOM.min.mjs +2 -0
  88. package/chunk-OXSWWWOM.min.mjs.map +1 -0
  89. package/chunk-PRUGHVRT.mjs +14 -0
  90. package/chunk-Q4WCMSOW.min.mjs +2 -0
  91. package/chunk-Q4WCMSOW.min.mjs.map +1 -0
  92. package/chunk-QH74JZCK.mjs +9 -0
  93. package/chunk-QNNJNLGK.min.cjs +2 -0
  94. package/chunk-QNNJNLGK.min.cjs.map +1 -0
  95. package/chunk-QWCFN7ZM.mjs +15 -0
  96. package/chunk-SDM2OPT6.mjs +32 -0
  97. package/chunk-SHKRZCF2.cjs +16031 -0
  98. package/chunk-SJDJDNDN.min.cjs +2 -0
  99. package/chunk-SJDJDNDN.min.cjs.map +1 -0
  100. package/chunk-SULNMALN.cjs +328 -0
  101. package/chunk-SV35RBZ7.min.mjs +2 -0
  102. package/chunk-SV35RBZ7.min.mjs.map +1 -0
  103. package/chunk-TJFYGFOW.mjs +328 -0
  104. package/chunk-UHRYBUUX.min.mjs +2 -0
  105. package/chunk-UHRYBUUX.min.mjs.map +1 -0
  106. package/chunk-UOU6IP3S.min.mjs +2 -0
  107. package/chunk-UOU6IP3S.min.mjs.map +1 -0
  108. package/chunk-V76XVNZ5.mjs +20 -0
  109. package/chunk-VFYQ7I5V.min.mjs +2 -0
  110. package/chunk-VFYQ7I5V.min.mjs.map +1 -0
  111. package/chunk-VG7VV7J2.mjs +167 -0
  112. package/chunk-VJCV56DO.cjs +15 -0
  113. package/chunk-VREA6AKG.cjs +9 -0
  114. package/chunk-W5I6Y5FK.min.mjs +2 -0
  115. package/chunk-W5I6Y5FK.min.mjs.map +1 -0
  116. package/chunk-Y7MC73BZ.cjs +42 -0
  117. package/chunk-YVWROQKU.mjs +40 -0
  118. package/chunk-ZKIZ5SWK.min.cjs +2 -0
  119. package/chunk-ZKIZ5SWK.min.cjs.map +1 -0
  120. package/chunk-ZZZB7NJX.mjs +93 -0
  121. package/concatIterators.cjs +4 -27
  122. package/concatIterators.min.cjs +1 -1
  123. package/concatIterators.min.cjs.map +1 -1
  124. package/concatIterators.min.mjs +1 -1
  125. package/concatIterators.min.mjs.map +1 -1
  126. package/concatIterators.mjs +2 -0
  127. package/dateTimeStr.cjs +31 -119
  128. package/dateTimeStr.min.cjs +1 -1
  129. package/dateTimeStr.min.cjs.map +1 -1
  130. package/dateTimeStr.min.mjs +1 -1
  131. package/dateTimeStr.min.mjs.map +1 -1
  132. package/dateTimeStr.mjs +17 -69
  133. package/duration.cjs +24 -188
  134. package/duration.min.cjs +1 -1
  135. package/duration.min.cjs.map +1 -1
  136. package/duration.min.mjs +1 -1
  137. package/duration.min.mjs.map +1 -1
  138. package/duration.mjs +14 -144
  139. package/getEnv.cjs +20 -0
  140. package/getEnv.d.mts +11 -0
  141. package/getEnv.d.ts +11 -0
  142. package/getEnv.min.cjs +2 -0
  143. package/getEnv.min.cjs.map +1 -0
  144. package/getEnv.min.mjs +2 -0
  145. package/getEnv.min.mjs.map +1 -0
  146. package/getEnv.mjs +20 -0
  147. package/isEmpty.cjs +8 -46
  148. package/isEmpty.min.cjs +1 -1
  149. package/isEmpty.min.cjs.map +1 -1
  150. package/isEmpty.min.mjs +1 -1
  151. package/isEmpty.min.mjs.map +1 -1
  152. package/isEmpty.mjs +6 -19
  153. package/isPromise.cjs +5 -29
  154. package/isPromise.min.cjs +1 -1
  155. package/isPromise.min.cjs.map +1 -1
  156. package/isPromise.min.mjs +1 -1
  157. package/isPromise.min.mjs.map +1 -1
  158. package/isPromise.mjs +2 -0
  159. package/kvStore.cjs +15 -353
  160. package/kvStore.min.cjs +1 -1
  161. package/kvStore.min.cjs.map +1 -1
  162. package/kvStore.min.mjs +1 -1
  163. package/kvStore.min.mjs.map +1 -1
  164. package/kvStore.mjs +12 -319
  165. package/localStore.cjs +15 -264
  166. package/localStore.min.cjs +1 -1
  167. package/localStore.min.cjs.map +1 -1
  168. package/localStore.min.mjs +1 -1
  169. package/localStore.min.mjs.map +1 -1
  170. package/localStore.mjs +12 -230
  171. package/magic-string.es-4UY437WL.min.mjs +14 -0
  172. package/magic-string.es-4UY437WL.min.mjs.map +1 -0
  173. package/magic-string.es-OAQWZQTY.mjs +1323 -0
  174. package/magic-string.es-UE2UVQEL.cjs +1323 -0
  175. package/magic-string.es-X6DNUB6Y.min.cjs +14 -0
  176. package/magic-string.es-X6DNUB6Y.min.cjs.map +1 -0
  177. package/mean.cjs +8 -48
  178. package/mean.min.cjs +1 -1
  179. package/mean.min.cjs.map +1 -1
  180. package/mean.min.mjs +1 -1
  181. package/mean.min.mjs.map +1 -1
  182. package/mean.mjs +5 -18
  183. package/median.cjs +7 -41
  184. package/median.min.cjs +1 -1
  185. package/median.min.cjs.map +1 -1
  186. package/median.min.mjs +1 -1
  187. package/median.min.mjs.map +1 -1
  188. package/median.mjs +4 -11
  189. package/nonEmpty.cjs +8 -48
  190. package/nonEmpty.min.cjs +1 -1
  191. package/nonEmpty.min.cjs.map +1 -1
  192. package/nonEmpty.min.mjs +1 -1
  193. package/nonEmpty.min.mjs.map +1 -1
  194. package/nonEmpty.mjs +6 -19
  195. package/nonNil.cjs +4 -27
  196. package/nonNil.min.cjs +1 -1
  197. package/nonNil.min.cjs.map +1 -1
  198. package/nonNil.min.mjs +1 -1
  199. package/nonNil.min.mjs.map +1 -1
  200. package/nonNil.mjs +2 -0
  201. package/package.json +273 -1
  202. package/round.cjs +6 -32
  203. package/round.min.cjs +1 -1
  204. package/round.min.cjs.map +1 -1
  205. package/round.min.mjs +1 -1
  206. package/round.min.mjs.map +1 -1
  207. package/round.mjs +4 -5
  208. package/roundToString.cjs +7 -35
  209. package/roundToString.min.cjs +1 -1
  210. package/roundToString.min.cjs.map +1 -1
  211. package/roundToString.min.mjs +1 -1
  212. package/roundToString.min.mjs.map +1 -1
  213. package/roundToString.mjs +4 -5
  214. package/safeBtoa.cjs +4 -27
  215. package/safeBtoa.min.cjs +1 -1
  216. package/safeBtoa.min.cjs.map +1 -1
  217. package/safeBtoa.min.mjs +1 -1
  218. package/safeBtoa.min.mjs.map +1 -1
  219. package/safeBtoa.mjs +2 -0
  220. package/sha256.cjs +8 -34
  221. package/sha256.min.cjs +1 -1
  222. package/sha256.min.cjs.map +1 -1
  223. package/sha256.min.mjs +1 -1
  224. package/sha256.min.mjs.map +1 -1
  225. package/sha256.mjs +6 -7
  226. package/sleep.cjs +4 -27
  227. package/sleep.min.cjs +1 -1
  228. package/sleep.min.cjs.map +1 -1
  229. package/sleep.min.mjs +1 -1
  230. package/sleep.min.mjs.map +1 -1
  231. package/sleep.mjs +2 -0
  232. package/storageAdapter.cjs +1 -18
  233. package/storageAdapter.min.cjs +1 -2
  234. package/storageAdapter.min.cjs.map +1 -1
  235. package/sum.cjs +5 -45
  236. package/sum.min.cjs +1 -1
  237. package/sum.min.cjs.map +1 -1
  238. package/sum.min.mjs +1 -1
  239. package/sum.min.mjs.map +1 -1
  240. package/sum.mjs +5 -18
  241. package/timeConstants.cjs +35 -69
  242. package/timeConstants.min.cjs +1 -1
  243. package/timeConstants.min.cjs.map +1 -1
  244. package/timeConstants.min.mjs +1 -1
  245. package/timeConstants.min.mjs.map +1 -1
  246. package/timeConstants.mjs +19 -15
  247. package/timer.cjs +7 -180
  248. package/timer.min.cjs +1 -1
  249. package/timer.min.cjs.map +1 -1
  250. package/timer.min.mjs +1 -1
  251. package/timer.min.mjs.map +1 -1
  252. package/timer.mjs +8 -154
  253. package/toReadableString.cjs +6 -68
  254. package/toReadableString.min.cjs +1 -5
  255. package/toReadableString.min.cjs.map +1 -1
  256. package/toReadableString.min.mjs +1 -5
  257. package/toReadableString.min.mjs.map +1 -1
  258. package/toReadableString.mjs +4 -41
@@ -0,0 +1,40 @@
1
+ import {
2
+ elapsed,
3
+ init_duration
4
+ } from "./chunk-VG7VV7J2.mjs";
5
+ import {
6
+ __esm
7
+ } from "./chunk-M6PYQYOX.mjs";
8
+
9
+ // src/timer.ts
10
+ function timer() {
11
+ const obj = {
12
+ startMs: Date.now(),
13
+ endMs: 0,
14
+ stop() {
15
+ obj.endMs = Date.now();
16
+ },
17
+ restart() {
18
+ obj.endMs = 0;
19
+ obj.startMs = Date.now();
20
+ },
21
+ elapsedMs() {
22
+ const stopMs = obj.endMs || Date.now();
23
+ return stopMs - obj.startMs;
24
+ },
25
+ toString() {
26
+ return elapsed(obj.elapsedMs());
27
+ }
28
+ };
29
+ return obj;
30
+ }
31
+ var init_timer = __esm({
32
+ "src/timer.ts"() {
33
+ init_duration();
34
+ }
35
+ });
36
+
37
+ export {
38
+ timer,
39
+ init_timer
40
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk27MBP3ESmincjs = require('./chunk-27MBP3ES.min.cjs');var _chunkQNNJNLGKmincjs = require('./chunk-QNNJNLGK.min.cjs');function a(){let t={startMs:Date.now(),endMs:0,stop(){t.endMs=Date.now()},restart(){t.endMs=0,t.startMs=Date.now()},elapsedMs(){return(t.endMs||Date.now())-t.startMs},toString(){return _chunk27MBP3ESmincjs.h.call(void 0, t.elapsedMs())}};return t}var n=_chunkQNNJNLGKmincjs.a.call(void 0, ()=>{_chunk27MBP3ESmincjs.i.call(void 0, )});exports.a = a; exports.b = n;
2
+ //# sourceMappingURL=chunk-ZKIZ5SWK.min.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/choksheaklau/src/ts-utils/dist/chunk-ZKIZ5SWK.min.cjs","../src/timer.ts"],"names":["timer","obj","elapsed","init_timer","__esmMin","init_duration"],"mappings":"AAAA,wIAAmD,+DAA6C,SCMhFA,CAAAA,CAAAA,CAAQ,CACtB,IAAMC,CAAAA,CAAM,CACV,OAAA,CAAS,IAAA,CAAK,GAAA,CAAI,CAAA,CAClB,KAAA,CAAO,CAAA,CAEP,IAAA,CAAA,CAAa,CACXA,CAAAA,CAAI,KAAA,CAAQ,IAAA,CAAK,GAAA,CAAI,CACvB,CAAA,CAEA,OAAA,CAAA,CAAgB,CACdA,CAAAA,CAAI,KAAA,CAAQ,CAAA,CACZA,CAAAA,CAAI,OAAA,CAAU,IAAA,CAAK,GAAA,CAAI,CACzB,CAAA,CAEA,SAAA,CAAA,CAAoB,CAElB,MAAA,CADeA,CAAAA,CAAI,KAAA,EAAS,IAAA,CAAK,GAAA,CAAI,CAAA,CAAA,CACrBA,CAAAA,CAAI,OACtB,CAAA,CAEA,QAAA,CAAA,CAAmB,CACjB,OAAOC,oCAAAA,CAAQD,CAAI,SAAA,CAAU,CAAC,CAChC,CACF,CAAA,CAEA,OAAOA,CACT,CA/BA,IAAAE,CAAAA,CAAAC,oCAAAA,CAAA,CAAA,EAAA,CAAAC,oCAAAA,CAAAA,CAAAA,CAAAA,CAAAA,6BAAAA","file":"/Users/choksheaklau/src/ts-utils/dist/chunk-ZKIZ5SWK.min.cjs","sourcesContent":[null,"import { elapsed } from \"./duration\";\n\n/**\n * Create a new timer and starts the timing right away. Returns a closed object\n * instead of a class to make sure the variables are bound correctly.\n */\nexport function timer() {\n const obj = {\n startMs: Date.now(),\n endMs: 0,\n\n stop(): void {\n obj.endMs = Date.now();\n },\n\n restart(): void {\n obj.endMs = 0;\n obj.startMs = Date.now();\n },\n\n elapsedMs(): number {\n const stopMs = obj.endMs || Date.now();\n return stopMs - obj.startMs;\n },\n\n toString(): string {\n return elapsed(obj.elapsedMs());\n },\n };\n\n return obj;\n}\n\n/** Defines the type of the Timer object. */\nexport type Timer = ReturnType<typeof timer>;\n"]}
@@ -0,0 +1,93 @@
1
+ import {
2
+ __esm
3
+ } from "./chunk-M6PYQYOX.mjs";
4
+
5
+ // src/dateTimeStr.ts
6
+ function isAllDigits(str) {
7
+ return /^\d+$/.test(str);
8
+ }
9
+ function toDate(ts) {
10
+ if (typeof ts === "number") {
11
+ if (ts < 1e11) {
12
+ return new Date(ts * 1e3);
13
+ }
14
+ return new Date(ts);
15
+ }
16
+ if (typeof ts === "string") {
17
+ if (isAllDigits(ts)) {
18
+ return toDate(Number(ts));
19
+ }
20
+ return new Date(ts);
21
+ }
22
+ return ts;
23
+ }
24
+ function yyyyMm(dt = /* @__PURE__ */ new Date(), separator = "-") {
25
+ const yr = dt.getFullYear();
26
+ const mth = dt.getMonth() + 1;
27
+ return yr + separator + (mth < 10 ? "0" + mth : mth);
28
+ }
29
+ function yyyyMmDd(dt = /* @__PURE__ */ new Date(), separator = "-") {
30
+ const day = dt.getDate();
31
+ return yyyyMm(dt, separator) + separator + (day < 10 ? "0" + day : day);
32
+ }
33
+ function hhMm(dt = /* @__PURE__ */ new Date(), separator = ":") {
34
+ const hr = dt.getHours();
35
+ const min = dt.getMinutes();
36
+ return (hr < 10 ? "0" + hr : hr) + separator + (min < 10 ? "0" + min : min);
37
+ }
38
+ function hhMmSs(dt = /* @__PURE__ */ new Date(), separator = ":") {
39
+ const sec = dt.getSeconds();
40
+ return hhMm(dt, separator) + separator + (sec < 10 ? "0" + sec : sec);
41
+ }
42
+ function hhMmSsMs(dt = /* @__PURE__ */ new Date(), timeSeparator = ":", msSeparator = ".") {
43
+ const ms = dt.getMilliseconds();
44
+ return hhMmSs(dt, timeSeparator) + msSeparator + (ms < 10 ? "00" + ms : ms < 100 ? "0" + ms : ms);
45
+ }
46
+ function tzShort(dt = /* @__PURE__ */ new Date()) {
47
+ if (dt.getTimezoneOffset() === 0) {
48
+ return "Z";
49
+ }
50
+ const tzHours = dt.getTimezoneOffset() / 60;
51
+ return tzHours >= 0 ? "+" + tzHours : String(tzHours);
52
+ }
53
+ function getLongMonthNameZeroIndexed(month, locales = "default") {
54
+ return new Date(2024, month, 15).toLocaleString(locales, {
55
+ month: "long"
56
+ });
57
+ }
58
+ function getLongMonthNameOneIndexed(month, locales = "default") {
59
+ return getLongMonthNameZeroIndexed(month - 1, locales);
60
+ }
61
+ function getShortMonthNameZeroIndexed(month, locales = "default") {
62
+ return new Date(2e3, month, 15).toLocaleString(locales, {
63
+ month: "short"
64
+ });
65
+ }
66
+ function getShortMonthNameOneIndexed(month, locales = "default") {
67
+ return getShortMonthNameZeroIndexed(month - 1, locales);
68
+ }
69
+ function getDisplayDateTime(ts) {
70
+ const iso = toDate(ts).toISOString();
71
+ const noMs = iso.slice(0, 19) + "Z";
72
+ return noMs.replace("T", " ");
73
+ }
74
+ var init_dateTimeStr = __esm({
75
+ "src/dateTimeStr.ts"() {
76
+ }
77
+ });
78
+
79
+ export {
80
+ toDate,
81
+ yyyyMm,
82
+ yyyyMmDd,
83
+ hhMm,
84
+ hhMmSs,
85
+ hhMmSsMs,
86
+ tzShort,
87
+ getLongMonthNameZeroIndexed,
88
+ getLongMonthNameOneIndexed,
89
+ getShortMonthNameZeroIndexed,
90
+ getShortMonthNameOneIndexed,
91
+ getDisplayDateTime,
92
+ init_dateTimeStr
93
+ };
@@ -1,34 +1,11 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-ILGTU46T.cjs');
19
2
 
20
3
  // src/concatIterators.ts
21
- var concatIterators_exports = {};
22
- __export(concatIterators_exports, {
23
- concatIterators: () => concatIterators
24
- });
25
- module.exports = __toCommonJS(concatIterators_exports);
26
4
  function* concatIterators(...iterators) {
27
5
  for (const iterator of iterators) {
28
6
  yield* iterator;
29
7
  }
30
8
  }
31
- // Annotate the CommonJS export names for ESM import in node:
32
- 0 && (module.exports = {
33
- concatIterators
34
- });
9
+
10
+
11
+ exports.concatIterators = concatIterators;
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var s=(t,o)=>{for(var e in o)n(t,e,{get:o[e],enumerable:!0})},T=(t,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of f(o))!i.call(t,r)&&r!==e&&n(t,r,{get:()=>o[r],enumerable:!(a=c(o,r))||a.enumerable});return t};var d=t=>T(n({},"__esModule",{value:!0}),t);var p={};s(p,{concatIterators:()=>l});module.exports=d(p);function*l(...t){for(let o of t)yield*o}0&&(module.exports={concatIterators});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-QNNJNLGK.min.cjs');function*r(...o){for(let t of o)yield*t}exports.concatIterators = r;
2
2
  //# sourceMappingURL=concatIterators.min.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/concatIterators.ts"],"sourcesContent":["/** Memory-efficient way to concat two or more iterators. */\nexport function* concatIterators<T>(...iterators: Generator<T>[]) {\n for (const iterator of iterators) {\n yield* iterator;\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GACO,SAAUE,KAAsBE,EAA2B,CAChE,QAAWC,KAAYD,EACrB,MAAOC,CAEX","names":["concatIterators_exports","__export","concatIterators","__toCommonJS","iterators","iterator"]}
1
+ {"version":3,"sources":["/Users/choksheaklau/src/ts-utils/dist/concatIterators.min.cjs","../src/concatIterators.ts"],"names":["concatIterators","iterators","iterator"],"mappings":"AAAA,6GAAgC,QCCzB,CAAUA,CAAAA,CAAAA,GAAsBC,CAAAA,CAA2B,CAChE,GAAA,CAAA,IAAWC,EAAAA,GAAYD,CAAAA,CACrB,KAAA,CAAOC,CAEX,CAAA,4BAAA","file":"/Users/choksheaklau/src/ts-utils/dist/concatIterators.min.cjs","sourcesContent":[null,"/** Memory-efficient way to concat two or more iterators. */\nexport function* concatIterators<T>(...iterators: Generator<T>[]) {\n for (const iterator of iterators) {\n yield* iterator;\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- function*r(...o){for(let t of o)yield*t}export{r as concatIterators};
1
+ import"./chunk-UOU6IP3S.min.mjs";function*r(...o){for(let t of o)yield*t}export{r as concatIterators};
2
2
  //# sourceMappingURL=concatIterators.min.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/concatIterators.ts"],"sourcesContent":["/** Memory-efficient way to concat two or more iterators. */\nexport function* concatIterators<T>(...iterators: Generator<T>[]) {\n for (const iterator of iterators) {\n yield* iterator;\n }\n}\n"],"mappings":"AACO,SAAUA,KAAsBC,EAA2B,CAChE,QAAWC,KAAYD,EACrB,MAAOC,CAEX","names":["concatIterators","iterators","iterator"]}
1
+ {"version":3,"sources":["../src/concatIterators.ts"],"sourcesContent":["/** Memory-efficient way to concat two or more iterators. */\nexport function* concatIterators<T>(...iterators: Generator<T>[]) {\n for (const iterator of iterators) {\n yield* iterator;\n }\n}\n"],"mappings":"iCACO,SAAUA,KAAsBC,EAA2B,CAChE,QAAWC,KAAYD,EACrB,MAAOC,CAEX","names":["concatIterators","iterators","iterator"]}
@@ -1,3 +1,5 @@
1
+ import "./chunk-M6PYQYOX.mjs";
2
+
1
3
  // src/concatIterators.ts
2
4
  function* concatIterators(...iterators) {
3
5
  for (const iterator of iterators) {
package/dateTimeStr.cjs CHANGED
@@ -1,119 +1,31 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/dateTimeStr.ts
21
- var dateTimeStr_exports = {};
22
- __export(dateTimeStr_exports, {
23
- getDisplayDateTime: () => getDisplayDateTime,
24
- getLongMonthNameOneIndexed: () => getLongMonthNameOneIndexed,
25
- getLongMonthNameZeroIndexed: () => getLongMonthNameZeroIndexed,
26
- getShortMonthNameOneIndexed: () => getShortMonthNameOneIndexed,
27
- getShortMonthNameZeroIndexed: () => getShortMonthNameZeroIndexed,
28
- hhMm: () => hhMm,
29
- hhMmSs: () => hhMmSs,
30
- hhMmSsMs: () => hhMmSsMs,
31
- toDate: () => toDate,
32
- tzShort: () => tzShort,
33
- yyyyMm: () => yyyyMm,
34
- yyyyMmDd: () => yyyyMmDd
35
- });
36
- module.exports = __toCommonJS(dateTimeStr_exports);
37
- function isAllDigits(str) {
38
- return /^\d+$/.test(str);
39
- }
40
- function toDate(ts) {
41
- if (typeof ts === "number") {
42
- if (ts < 1e11) {
43
- return new Date(ts * 1e3);
44
- }
45
- return new Date(ts);
46
- }
47
- if (typeof ts === "string") {
48
- if (isAllDigits(ts)) {
49
- return toDate(Number(ts));
50
- }
51
- return new Date(ts);
52
- }
53
- return ts;
54
- }
55
- function yyyyMm(dt = /* @__PURE__ */ new Date(), separator = "-") {
56
- const yr = dt.getFullYear();
57
- const mth = dt.getMonth() + 1;
58
- return yr + separator + (mth < 10 ? "0" + mth : mth);
59
- }
60
- function yyyyMmDd(dt = /* @__PURE__ */ new Date(), separator = "-") {
61
- const day = dt.getDate();
62
- return yyyyMm(dt, separator) + separator + (day < 10 ? "0" + day : day);
63
- }
64
- function hhMm(dt = /* @__PURE__ */ new Date(), separator = ":") {
65
- const hr = dt.getHours();
66
- const min = dt.getMinutes();
67
- return (hr < 10 ? "0" + hr : hr) + separator + (min < 10 ? "0" + min : min);
68
- }
69
- function hhMmSs(dt = /* @__PURE__ */ new Date(), separator = ":") {
70
- const sec = dt.getSeconds();
71
- return hhMm(dt, separator) + separator + (sec < 10 ? "0" + sec : sec);
72
- }
73
- function hhMmSsMs(dt = /* @__PURE__ */ new Date(), timeSeparator = ":", msSeparator = ".") {
74
- const ms = dt.getMilliseconds();
75
- return hhMmSs(dt, timeSeparator) + msSeparator + (ms < 10 ? "00" + ms : ms < 100 ? "0" + ms : ms);
76
- }
77
- function tzShort(dt = /* @__PURE__ */ new Date()) {
78
- if (dt.getTimezoneOffset() === 0) {
79
- return "Z";
80
- }
81
- const tzHours = dt.getTimezoneOffset() / 60;
82
- return tzHours >= 0 ? "+" + tzHours : String(tzHours);
83
- }
84
- function getLongMonthNameZeroIndexed(month, locales = "default") {
85
- return new Date(2024, month, 15).toLocaleString(locales, {
86
- month: "long"
87
- });
88
- }
89
- function getLongMonthNameOneIndexed(month, locales = "default") {
90
- return getLongMonthNameZeroIndexed(month - 1, locales);
91
- }
92
- function getShortMonthNameZeroIndexed(month, locales = "default") {
93
- return new Date(2e3, month, 15).toLocaleString(locales, {
94
- month: "short"
95
- });
96
- }
97
- function getShortMonthNameOneIndexed(month, locales = "default") {
98
- return getShortMonthNameZeroIndexed(month - 1, locales);
99
- }
100
- function getDisplayDateTime(ts) {
101
- const iso = toDate(ts).toISOString();
102
- const noMs = iso.slice(0, 19) + "Z";
103
- return noMs.replace("T", " ");
104
- }
105
- // Annotate the CommonJS export names for ESM import in node:
106
- 0 && (module.exports = {
107
- getDisplayDateTime,
108
- getLongMonthNameOneIndexed,
109
- getLongMonthNameZeroIndexed,
110
- getShortMonthNameOneIndexed,
111
- getShortMonthNameZeroIndexed,
112
- hhMm,
113
- hhMmSs,
114
- hhMmSsMs,
115
- toDate,
116
- tzShort,
117
- yyyyMm,
118
- yyyyMmDd
119
- });
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ var _chunkCERFUU5Icjs = require('./chunk-CERFUU5I.cjs');
16
+ require('./chunk-ILGTU46T.cjs');
17
+ _chunkCERFUU5Icjs.init_dateTimeStr.call(void 0, );
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ exports.getDisplayDateTime = _chunkCERFUU5Icjs.getDisplayDateTime; exports.getLongMonthNameOneIndexed = _chunkCERFUU5Icjs.getLongMonthNameOneIndexed; exports.getLongMonthNameZeroIndexed = _chunkCERFUU5Icjs.getLongMonthNameZeroIndexed; exports.getShortMonthNameOneIndexed = _chunkCERFUU5Icjs.getShortMonthNameOneIndexed; exports.getShortMonthNameZeroIndexed = _chunkCERFUU5Icjs.getShortMonthNameZeroIndexed; exports.hhMm = _chunkCERFUU5Icjs.hhMm; exports.hhMmSs = _chunkCERFUU5Icjs.hhMmSs; exports.hhMmSsMs = _chunkCERFUU5Icjs.hhMmSsMs; exports.toDate = _chunkCERFUU5Icjs.toDate; exports.tzShort = _chunkCERFUU5Icjs.tzShort; exports.yyyyMm = _chunkCERFUU5Icjs.yyyyMm; exports.yyyyMmDd = _chunkCERFUU5Icjs.yyyyMmDd;
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var h=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},x=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of l(t))!D.call(e,o)&&o!==n&&i(e,o,{get:()=>t[o],enumerable:!(r=f(t,o))||r.enumerable});return e};var y=e=>x(i({},"__esModule",{value:!0}),e);var A={};h(A,{getDisplayDateTime:()=>b,getLongMonthNameOneIndexed:()=>S,getLongMonthNameZeroIndexed:()=>c,getShortMonthNameOneIndexed:()=>I,getShortMonthNameZeroIndexed:()=>m,hhMm:()=>g,hhMmSs:()=>a,hhMmSsMs:()=>d,toDate:()=>u,tzShort:()=>w,yyyyMm:()=>s,yyyyMmDd:()=>M});module.exports=y(A);function p(e){return/^\d+$/.test(e)}function u(e){return typeof e=="number"?e<1e11?new Date(e*1e3):new Date(e):typeof e=="string"?p(e)?u(Number(e)):new Date(e):e}function s(e=new Date,t="-"){let n=e.getFullYear(),r=e.getMonth()+1;return n+t+(r<10?"0"+r:r)}function M(e=new Date,t="-"){let n=e.getDate();return s(e,t)+t+(n<10?"0"+n:n)}function g(e=new Date,t=":"){let n=e.getHours(),r=e.getMinutes();return(n<10?"0"+n:n)+t+(r<10?"0"+r:r)}function a(e=new Date,t=":"){let n=e.getSeconds();return g(e,t)+t+(n<10?"0"+n:n)}function d(e=new Date,t=":",n="."){let r=e.getMilliseconds();return a(e,t)+n+(r<10?"00"+r:r<100?"0"+r:r)}function w(e=new Date){if(e.getTimezoneOffset()===0)return"Z";let t=e.getTimezoneOffset()/60;return t>=0?"+"+t:String(t)}function c(e,t="default"){return new Date(2024,e,15).toLocaleString(t,{month:"long"})}function S(e,t="default"){return c(e-1,t)}function m(e,t="default"){return new Date(2e3,e,15).toLocaleString(t,{month:"short"})}function I(e,t="default"){return m(e-1,t)}function b(e){return(u(e).toISOString().slice(0,19)+"Z").replace("T"," ")}0&&(module.exports={getDisplayDateTime,getLongMonthNameOneIndexed,getLongMonthNameZeroIndexed,getShortMonthNameOneIndexed,getShortMonthNameZeroIndexed,hhMm,hhMmSs,hhMmSsMs,toDate,tzShort,yyyyMm,yyyyMmDd});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkSJDJDNDNmincjs = require('./chunk-SJDJDNDN.min.cjs');require('./chunk-QNNJNLGK.min.cjs');_chunkSJDJDNDNmincjs.m.call(void 0, );exports.getDisplayDateTime = _chunkSJDJDNDNmincjs.l; exports.getLongMonthNameOneIndexed = _chunkSJDJDNDNmincjs.i; exports.getLongMonthNameZeroIndexed = _chunkSJDJDNDNmincjs.h; exports.getShortMonthNameOneIndexed = _chunkSJDJDNDNmincjs.k; exports.getShortMonthNameZeroIndexed = _chunkSJDJDNDNmincjs.j; exports.hhMm = _chunkSJDJDNDNmincjs.d; exports.hhMmSs = _chunkSJDJDNDNmincjs.e; exports.hhMmSsMs = _chunkSJDJDNDNmincjs.f; exports.toDate = _chunkSJDJDNDNmincjs.a; exports.tzShort = _chunkSJDJDNDNmincjs.g; exports.yyyyMm = _chunkSJDJDNDNmincjs.b; exports.yyyyMmDd = _chunkSJDJDNDNmincjs.c;
2
2
  //# sourceMappingURL=dateTimeStr.min.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dateTimeStr.ts"],"sourcesContent":["export type AnyDateTime = number | Date | string;\n\nfunction isAllDigits(str: string): boolean {\n return /^\\d+$/.test(str);\n}\n\n/**\n * Convert a number (epoch seconds or milliseconds), string (parseable\n * date/time or epoch seconds or milliseconds), or Date object (no conversion)\n * into a Date object.\n */\nexport function toDate(ts: AnyDateTime): Date {\n if (typeof ts === \"number\") {\n // Handle timestamp in seconds (less than 12 digits long).\n if (ts < 1_000_000_000_00) {\n return new Date(ts * 1000);\n }\n\n // Handle timestamp in milliseconds.\n return new Date(ts);\n }\n\n if (typeof ts === \"string\") {\n if (isAllDigits(ts)) {\n return toDate(Number(ts));\n }\n\n return new Date(ts);\n }\n\n return ts;\n}\n\n/**\n * Returns a date in yyyy-MM format. E.g. '2000-01'.\n *\n * @param dt Specify a date object or default to the current date.\n * @param separator Defaults to '-'.\n */\nexport function yyyyMm(dt = new Date(), separator = \"-\"): string {\n const yr = dt.getFullYear();\n const mth = dt.getMonth() + 1;\n\n return yr + separator + (mth < 10 ? \"0\" + mth : mth);\n}\n\n/**\n * Returns a date in yyyy-MM-dd format. E.g. '2000-01-02'.\n *\n * @param dt Specify a date object or default to the current date.\n * @param separator Defaults to '-'.\n */\nexport function yyyyMmDd(dt = new Date(), separator = \"-\"): string {\n const day = dt.getDate();\n\n return yyyyMm(dt, separator) + separator + (day < 10 ? \"0\" + day : day);\n}\n\n/**\n * Returns a date in hh:mm format. E.g. '01:02'.\n *\n * @param dt Specify a date object or default to the current date/time.\n * @param separator Defaults to ':'.\n */\nexport function hhMm(dt = new Date(), separator = \":\"): string {\n const hr = dt.getHours();\n const min = dt.getMinutes();\n\n return (hr < 10 ? \"0\" + hr : hr) + separator + (min < 10 ? \"0\" + min : min);\n}\n\n/**\n * Returns a date in hh:mm:ss format. E.g. '01:02:03'.\n *\n * @param dt Specify a date object or default to the current date/time.\n * @param separator Defaults to ':'.\n */\nexport function hhMmSs(dt = new Date(), separator = \":\"): string {\n const sec = dt.getSeconds();\n\n return hhMm(dt, separator) + separator + (sec < 10 ? \"0\" + sec : sec);\n}\n\n/**\n * Returns a date in hh:mm:ss.SSS format. E.g. '01:02:03.004'.\n *\n * @param dt Specify a date object or default to the current date/time.\n * @param timeSeparator Separator for hh/mm/ss. Defaults to ':'.\n * @param msSeparator Separator before SSS. Defaults to '.'.\n */\nexport function hhMmSsMs(\n dt = new Date(),\n timeSeparator = \":\",\n msSeparator = \".\",\n): string {\n const ms = dt.getMilliseconds();\n\n return (\n hhMmSs(dt, timeSeparator) +\n msSeparator +\n (ms < 10 ? \"00\" + ms : ms < 100 ? \"0\" + ms : ms)\n );\n}\n\n/**\n * Returns the timezone string for the given date. E.g. '+8', '-3.5'.\n * Returns 'Z' for UTC.\n *\n * @param dt Specify a date object or default to the current date/time.\n */\nexport function tzShort(dt = new Date()): string {\n if (dt.getTimezoneOffset() === 0) {\n return \"Z\";\n }\n\n const tzHours = dt.getTimezoneOffset() / 60;\n return tzHours >= 0 ? \"+\" + tzHours : String(tzHours);\n}\n\n/**\n * Returns the long month name, zero-indexed. E.g. 0 for 'January'.\n *\n * @param month Zero-indexed month.\n * @param locales Specify the locale, e.g. 'en-US', new Intl.Locale(\"en-US\").\n */\nexport function getLongMonthNameZeroIndexed(\n month: number,\n locales: Intl.LocalesArgument = \"default\",\n): string {\n return new Date(2024, month, 15).toLocaleString(locales, {\n month: \"long\",\n });\n}\n\n/**\n * Returns the long month name, one-indexed. E.g. 1 for 'January'.\n *\n * @param month One-indexed month.\n * @param locales Specify the locale, e.g. 'en-US', new Intl.Locale(\"en-US\").\n */\nexport function getLongMonthNameOneIndexed(\n month: number,\n locales: Intl.LocalesArgument = \"default\",\n): string {\n return getLongMonthNameZeroIndexed(month - 1, locales);\n}\n\n/**\n * Returns the short month name, zero-indexed. E.g. 0 for 'Jan'.\n *\n * @param month Zero-indexed month.\n * @param locales Specify the locale, e.g. 'en-US', new Intl.Locale(\"en-US\").\n */\nexport function getShortMonthNameZeroIndexed(\n month: number,\n locales: Intl.LocalesArgument = \"default\",\n): string {\n return new Date(2000, month, 15).toLocaleString(locales, {\n month: \"short\",\n });\n}\n\n/**\n * Returns the short month name, one-indexed. E.g. 1 for 'Jan'.\n *\n * @param month One-indexed month.\n * @param locales Specify the locale, e.g. 'en-US', new Intl.Locale(\"en-US\").\n */\nexport function getShortMonthNameOneIndexed(\n month: number,\n locales: Intl.LocalesArgument = \"default\",\n): string {\n return getShortMonthNameZeroIndexed(month - 1, locales);\n}\n\n/**\n * Returns a human-readable string date/time like '2025-01-01 22:31:16Z'.\n * Excludes the milliseconds assuming it is not necessary for display.\n */\nexport function getDisplayDateTime(ts: AnyDateTime) {\n const iso = toDate(ts).toISOString();\n const noMs = iso.slice(0, 19) + \"Z\";\n return noMs.replace(\"T\", \" \");\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,+BAAAC,EAAA,gCAAAC,EAAA,gCAAAC,EAAA,iCAAAC,EAAA,SAAAC,EAAA,WAAAC,EAAA,aAAAC,EAAA,WAAAC,EAAA,YAAAC,EAAA,WAAAC,EAAA,aAAAC,IAAA,eAAAC,EAAAd,GAEA,SAASe,EAAYC,EAAsB,CACzC,MAAO,QAAQ,KAAKA,CAAG,CACzB,CAOO,SAASN,EAAOO,EAAuB,CAC5C,OAAI,OAAOA,GAAO,SAEZA,EAAK,KACA,IAAI,KAAKA,EAAK,GAAI,EAIpB,IAAI,KAAKA,CAAE,EAGhB,OAAOA,GAAO,SACZF,EAAYE,CAAE,EACTP,EAAO,OAAOO,CAAE,CAAC,EAGnB,IAAI,KAAKA,CAAE,EAGbA,CACT,CAQO,SAASL,EAAOM,EAAK,IAAI,KAAQC,EAAY,IAAa,CAC/D,IAAMC,EAAKF,EAAG,YAAY,EACpBG,EAAMH,EAAG,SAAS,EAAI,EAE5B,OAAOE,EAAKD,GAAaE,EAAM,GAAK,IAAMA,EAAMA,EAClD,CAQO,SAASR,EAASK,EAAK,IAAI,KAAQC,EAAY,IAAa,CACjE,IAAMG,EAAMJ,EAAG,QAAQ,EAEvB,OAAON,EAAOM,EAAIC,CAAS,EAAIA,GAAaG,EAAM,GAAK,IAAMA,EAAMA,EACrE,CAQO,SAASf,EAAKW,EAAK,IAAI,KAAQC,EAAY,IAAa,CAC7D,IAAMI,EAAKL,EAAG,SAAS,EACjBM,EAAMN,EAAG,WAAW,EAE1B,OAAQK,EAAK,GAAK,IAAMA,EAAKA,GAAMJ,GAAaK,EAAM,GAAK,IAAMA,EAAMA,EACzE,CAQO,SAAShB,EAAOU,EAAK,IAAI,KAAQC,EAAY,IAAa,CAC/D,IAAMM,EAAMP,EAAG,WAAW,EAE1B,OAAOX,EAAKW,EAAIC,CAAS,EAAIA,GAAaM,EAAM,GAAK,IAAMA,EAAMA,EACnE,CASO,SAAShB,EACdS,EAAK,IAAI,KACTQ,EAAgB,IAChBC,EAAc,IACN,CACR,IAAMC,EAAKV,EAAG,gBAAgB,EAE9B,OACEV,EAAOU,EAAIQ,CAAa,EACxBC,GACCC,EAAK,GAAK,KAAOA,EAAKA,EAAK,IAAM,IAAMA,EAAKA,EAEjD,CAQO,SAASjB,EAAQO,EAAK,IAAI,KAAgB,CAC/C,GAAIA,EAAG,kBAAkB,IAAM,EAC7B,MAAO,IAGT,IAAMW,EAAUX,EAAG,kBAAkB,EAAI,GACzC,OAAOW,GAAW,EAAI,IAAMA,EAAU,OAAOA,CAAO,CACtD,CAQO,SAASzB,EACd0B,EACAC,EAAgC,UACxB,CACR,OAAO,IAAI,KAAK,KAAMD,EAAO,EAAE,EAAE,eAAeC,EAAS,CACvD,MAAO,MACT,CAAC,CACH,CAQO,SAAS5B,EACd2B,EACAC,EAAgC,UACxB,CACR,OAAO3B,EAA4B0B,EAAQ,EAAGC,CAAO,CACvD,CAQO,SAASzB,EACdwB,EACAC,EAAgC,UACxB,CACR,OAAO,IAAI,KAAK,IAAMD,EAAO,EAAE,EAAE,eAAeC,EAAS,CACvD,MAAO,OACT,CAAC,CACH,CAQO,SAAS1B,EACdyB,EACAC,EAAgC,UACxB,CACR,OAAOzB,EAA6BwB,EAAQ,EAAGC,CAAO,CACxD,CAMO,SAAS7B,EAAmBe,EAAiB,CAGlD,OAFYP,EAAOO,CAAE,EAAE,YAAY,EAClB,MAAM,EAAG,EAAE,EAAI,KACpB,QAAQ,IAAK,GAAG,CAC9B","names":["dateTimeStr_exports","__export","getDisplayDateTime","getLongMonthNameOneIndexed","getLongMonthNameZeroIndexed","getShortMonthNameOneIndexed","getShortMonthNameZeroIndexed","hhMm","hhMmSs","hhMmSsMs","toDate","tzShort","yyyyMm","yyyyMmDd","__toCommonJS","isAllDigits","str","ts","dt","separator","yr","mth","day","hr","min","sec","timeSeparator","msSeparator","ms","tzHours","month","locales"]}
1
+ {"version":3,"sources":["/Users/choksheaklau/src/ts-utils/dist/dateTimeStr.min.cjs"],"names":[],"mappings":"AAAA,wIAA+D,oCAAiC,oCAAE,CAAE,CAAC,8kBAA0P","file":"/Users/choksheaklau/src/ts-utils/dist/dateTimeStr.min.cjs"}
@@ -1,2 +1,2 @@
1
- function i(e){return/^\d+$/.test(e)}function o(e){return typeof e=="number"?e<1e11?new Date(e*1e3):new Date(e):typeof e=="string"?i(e)?o(Number(e)):new Date(e):e}function u(e=new Date,t="-"){let n=e.getFullYear(),r=e.getMonth()+1;return n+t+(r<10?"0"+r:r)}function m(e=new Date,t="-"){let n=e.getDate();return u(e,t)+t+(n<10?"0"+n:n)}function s(e=new Date,t=":"){let n=e.getHours(),r=e.getMinutes();return(n<10?"0"+n:n)+t+(r<10?"0"+r:r)}function g(e=new Date,t=":"){let n=e.getSeconds();return s(e,t)+t+(n<10?"0"+n:n)}function f(e=new Date,t=":",n="."){let r=e.getMilliseconds();return g(e,t)+n+(r<10?"00"+r:r<100?"0"+r:r)}function l(e=new Date){if(e.getTimezoneOffset()===0)return"Z";let t=e.getTimezoneOffset()/60;return t>=0?"+"+t:String(t)}function a(e,t="default"){return new Date(2024,e,15).toLocaleString(t,{month:"long"})}function D(e,t="default"){return a(e-1,t)}function c(e,t="default"){return new Date(2e3,e,15).toLocaleString(t,{month:"short"})}function h(e,t="default"){return c(e-1,t)}function x(e){return(o(e).toISOString().slice(0,19)+"Z").replace("T"," ")}export{x as getDisplayDateTime,D as getLongMonthNameOneIndexed,a as getLongMonthNameZeroIndexed,h as getShortMonthNameOneIndexed,c as getShortMonthNameZeroIndexed,s as hhMm,g as hhMmSs,f as hhMmSsMs,o as toDate,l as tzShort,u as yyyyMm,m as yyyyMmDd};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-SV35RBZ7.min.mjs";import"./chunk-UOU6IP3S.min.mjs";m();export{l as getDisplayDateTime,i as getLongMonthNameOneIndexed,h as getLongMonthNameZeroIndexed,k as getShortMonthNameOneIndexed,j as getShortMonthNameZeroIndexed,d as hhMm,e as hhMmSs,f as hhMmSsMs,a as toDate,g as tzShort,b as yyyyMm,c as yyyyMmDd};
2
2
  //# sourceMappingURL=dateTimeStr.min.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dateTimeStr.ts"],"sourcesContent":["export type AnyDateTime = number | Date | string;\n\nfunction isAllDigits(str: string): boolean {\n return /^\\d+$/.test(str);\n}\n\n/**\n * Convert a number (epoch seconds or milliseconds), string (parseable\n * date/time or epoch seconds or milliseconds), or Date object (no conversion)\n * into a Date object.\n */\nexport function toDate(ts: AnyDateTime): Date {\n if (typeof ts === \"number\") {\n // Handle timestamp in seconds (less than 12 digits long).\n if (ts < 1_000_000_000_00) {\n return new Date(ts * 1000);\n }\n\n // Handle timestamp in milliseconds.\n return new Date(ts);\n }\n\n if (typeof ts === \"string\") {\n if (isAllDigits(ts)) {\n return toDate(Number(ts));\n }\n\n return new Date(ts);\n }\n\n return ts;\n}\n\n/**\n * Returns a date in yyyy-MM format. E.g. '2000-01'.\n *\n * @param dt Specify a date object or default to the current date.\n * @param separator Defaults to '-'.\n */\nexport function yyyyMm(dt = new Date(), separator = \"-\"): string {\n const yr = dt.getFullYear();\n const mth = dt.getMonth() + 1;\n\n return yr + separator + (mth < 10 ? \"0\" + mth : mth);\n}\n\n/**\n * Returns a date in yyyy-MM-dd format. E.g. '2000-01-02'.\n *\n * @param dt Specify a date object or default to the current date.\n * @param separator Defaults to '-'.\n */\nexport function yyyyMmDd(dt = new Date(), separator = \"-\"): string {\n const day = dt.getDate();\n\n return yyyyMm(dt, separator) + separator + (day < 10 ? \"0\" + day : day);\n}\n\n/**\n * Returns a date in hh:mm format. E.g. '01:02'.\n *\n * @param dt Specify a date object or default to the current date/time.\n * @param separator Defaults to ':'.\n */\nexport function hhMm(dt = new Date(), separator = \":\"): string {\n const hr = dt.getHours();\n const min = dt.getMinutes();\n\n return (hr < 10 ? \"0\" + hr : hr) + separator + (min < 10 ? \"0\" + min : min);\n}\n\n/**\n * Returns a date in hh:mm:ss format. E.g. '01:02:03'.\n *\n * @param dt Specify a date object or default to the current date/time.\n * @param separator Defaults to ':'.\n */\nexport function hhMmSs(dt = new Date(), separator = \":\"): string {\n const sec = dt.getSeconds();\n\n return hhMm(dt, separator) + separator + (sec < 10 ? \"0\" + sec : sec);\n}\n\n/**\n * Returns a date in hh:mm:ss.SSS format. E.g. '01:02:03.004'.\n *\n * @param dt Specify a date object or default to the current date/time.\n * @param timeSeparator Separator for hh/mm/ss. Defaults to ':'.\n * @param msSeparator Separator before SSS. Defaults to '.'.\n */\nexport function hhMmSsMs(\n dt = new Date(),\n timeSeparator = \":\",\n msSeparator = \".\",\n): string {\n const ms = dt.getMilliseconds();\n\n return (\n hhMmSs(dt, timeSeparator) +\n msSeparator +\n (ms < 10 ? \"00\" + ms : ms < 100 ? \"0\" + ms : ms)\n );\n}\n\n/**\n * Returns the timezone string for the given date. E.g. '+8', '-3.5'.\n * Returns 'Z' for UTC.\n *\n * @param dt Specify a date object or default to the current date/time.\n */\nexport function tzShort(dt = new Date()): string {\n if (dt.getTimezoneOffset() === 0) {\n return \"Z\";\n }\n\n const tzHours = dt.getTimezoneOffset() / 60;\n return tzHours >= 0 ? \"+\" + tzHours : String(tzHours);\n}\n\n/**\n * Returns the long month name, zero-indexed. E.g. 0 for 'January'.\n *\n * @param month Zero-indexed month.\n * @param locales Specify the locale, e.g. 'en-US', new Intl.Locale(\"en-US\").\n */\nexport function getLongMonthNameZeroIndexed(\n month: number,\n locales: Intl.LocalesArgument = \"default\",\n): string {\n return new Date(2024, month, 15).toLocaleString(locales, {\n month: \"long\",\n });\n}\n\n/**\n * Returns the long month name, one-indexed. E.g. 1 for 'January'.\n *\n * @param month One-indexed month.\n * @param locales Specify the locale, e.g. 'en-US', new Intl.Locale(\"en-US\").\n */\nexport function getLongMonthNameOneIndexed(\n month: number,\n locales: Intl.LocalesArgument = \"default\",\n): string {\n return getLongMonthNameZeroIndexed(month - 1, locales);\n}\n\n/**\n * Returns the short month name, zero-indexed. E.g. 0 for 'Jan'.\n *\n * @param month Zero-indexed month.\n * @param locales Specify the locale, e.g. 'en-US', new Intl.Locale(\"en-US\").\n */\nexport function getShortMonthNameZeroIndexed(\n month: number,\n locales: Intl.LocalesArgument = \"default\",\n): string {\n return new Date(2000, month, 15).toLocaleString(locales, {\n month: \"short\",\n });\n}\n\n/**\n * Returns the short month name, one-indexed. E.g. 1 for 'Jan'.\n *\n * @param month One-indexed month.\n * @param locales Specify the locale, e.g. 'en-US', new Intl.Locale(\"en-US\").\n */\nexport function getShortMonthNameOneIndexed(\n month: number,\n locales: Intl.LocalesArgument = \"default\",\n): string {\n return getShortMonthNameZeroIndexed(month - 1, locales);\n}\n\n/**\n * Returns a human-readable string date/time like '2025-01-01 22:31:16Z'.\n * Excludes the milliseconds assuming it is not necessary for display.\n */\nexport function getDisplayDateTime(ts: AnyDateTime) {\n const iso = toDate(ts).toISOString();\n const noMs = iso.slice(0, 19) + \"Z\";\n return noMs.replace(\"T\", \" \");\n}\n"],"mappings":"AAEA,SAASA,EAAYC,EAAsB,CACzC,MAAO,QAAQ,KAAKA,CAAG,CACzB,CAOO,SAASC,EAAOC,EAAuB,CAC5C,OAAI,OAAOA,GAAO,SAEZA,EAAK,KACA,IAAI,KAAKA,EAAK,GAAI,EAIpB,IAAI,KAAKA,CAAE,EAGhB,OAAOA,GAAO,SACZH,EAAYG,CAAE,EACTD,EAAO,OAAOC,CAAE,CAAC,EAGnB,IAAI,KAAKA,CAAE,EAGbA,CACT,CAQO,SAASC,EAAOC,EAAK,IAAI,KAAQC,EAAY,IAAa,CAC/D,IAAMC,EAAKF,EAAG,YAAY,EACpBG,EAAMH,EAAG,SAAS,EAAI,EAE5B,OAAOE,EAAKD,GAAaE,EAAM,GAAK,IAAMA,EAAMA,EAClD,CAQO,SAASC,EAASJ,EAAK,IAAI,KAAQC,EAAY,IAAa,CACjE,IAAMI,EAAML,EAAG,QAAQ,EAEvB,OAAOD,EAAOC,EAAIC,CAAS,EAAIA,GAAaI,EAAM,GAAK,IAAMA,EAAMA,EACrE,CAQO,SAASC,EAAKN,EAAK,IAAI,KAAQC,EAAY,IAAa,CAC7D,IAAMM,EAAKP,EAAG,SAAS,EACjBQ,EAAMR,EAAG,WAAW,EAE1B,OAAQO,EAAK,GAAK,IAAMA,EAAKA,GAAMN,GAAaO,EAAM,GAAK,IAAMA,EAAMA,EACzE,CAQO,SAASC,EAAOT,EAAK,IAAI,KAAQC,EAAY,IAAa,CAC/D,IAAMS,EAAMV,EAAG,WAAW,EAE1B,OAAOM,EAAKN,EAAIC,CAAS,EAAIA,GAAaS,EAAM,GAAK,IAAMA,EAAMA,EACnE,CASO,SAASC,EACdX,EAAK,IAAI,KACTY,EAAgB,IAChBC,EAAc,IACN,CACR,IAAMC,EAAKd,EAAG,gBAAgB,EAE9B,OACES,EAAOT,EAAIY,CAAa,EACxBC,GACCC,EAAK,GAAK,KAAOA,EAAKA,EAAK,IAAM,IAAMA,EAAKA,EAEjD,CAQO,SAASC,EAAQf,EAAK,IAAI,KAAgB,CAC/C,GAAIA,EAAG,kBAAkB,IAAM,EAC7B,MAAO,IAGT,IAAMgB,EAAUhB,EAAG,kBAAkB,EAAI,GACzC,OAAOgB,GAAW,EAAI,IAAMA,EAAU,OAAOA,CAAO,CACtD,CAQO,SAASC,EACdC,EACAC,EAAgC,UACxB,CACR,OAAO,IAAI,KAAK,KAAMD,EAAO,EAAE,EAAE,eAAeC,EAAS,CACvD,MAAO,MACT,CAAC,CACH,CAQO,SAASC,EACdF,EACAC,EAAgC,UACxB,CACR,OAAOF,EAA4BC,EAAQ,EAAGC,CAAO,CACvD,CAQO,SAASE,EACdH,EACAC,EAAgC,UACxB,CACR,OAAO,IAAI,KAAK,IAAMD,EAAO,EAAE,EAAE,eAAeC,EAAS,CACvD,MAAO,OACT,CAAC,CACH,CAQO,SAASG,EACdJ,EACAC,EAAgC,UACxB,CACR,OAAOE,EAA6BH,EAAQ,EAAGC,CAAO,CACxD,CAMO,SAASI,EAAmBzB,EAAiB,CAGlD,OAFYD,EAAOC,CAAE,EAAE,YAAY,EAClB,MAAM,EAAG,EAAE,EAAI,KACpB,QAAQ,IAAK,GAAG,CAC9B","names":["isAllDigits","str","toDate","ts","yyyyMm","dt","separator","yr","mth","yyyyMmDd","day","hhMm","hr","min","hhMmSs","sec","hhMmSsMs","timeSeparator","msSeparator","ms","tzShort","tzHours","getLongMonthNameZeroIndexed","month","locales","getLongMonthNameOneIndexed","getShortMonthNameZeroIndexed","getShortMonthNameOneIndexed","getDisplayDateTime"]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dateTimeStr.mjs CHANGED
@@ -1,72 +1,20 @@
1
- // src/dateTimeStr.ts
2
- function isAllDigits(str) {
3
- return /^\d+$/.test(str);
4
- }
5
- function toDate(ts) {
6
- if (typeof ts === "number") {
7
- if (ts < 1e11) {
8
- return new Date(ts * 1e3);
9
- }
10
- return new Date(ts);
11
- }
12
- if (typeof ts === "string") {
13
- if (isAllDigits(ts)) {
14
- return toDate(Number(ts));
15
- }
16
- return new Date(ts);
17
- }
18
- return ts;
19
- }
20
- function yyyyMm(dt = /* @__PURE__ */ new Date(), separator = "-") {
21
- const yr = dt.getFullYear();
22
- const mth = dt.getMonth() + 1;
23
- return yr + separator + (mth < 10 ? "0" + mth : mth);
24
- }
25
- function yyyyMmDd(dt = /* @__PURE__ */ new Date(), separator = "-") {
26
- const day = dt.getDate();
27
- return yyyyMm(dt, separator) + separator + (day < 10 ? "0" + day : day);
28
- }
29
- function hhMm(dt = /* @__PURE__ */ new Date(), separator = ":") {
30
- const hr = dt.getHours();
31
- const min = dt.getMinutes();
32
- return (hr < 10 ? "0" + hr : hr) + separator + (min < 10 ? "0" + min : min);
33
- }
34
- function hhMmSs(dt = /* @__PURE__ */ new Date(), separator = ":") {
35
- const sec = dt.getSeconds();
36
- return hhMm(dt, separator) + separator + (sec < 10 ? "0" + sec : sec);
37
- }
38
- function hhMmSsMs(dt = /* @__PURE__ */ new Date(), timeSeparator = ":", msSeparator = ".") {
39
- const ms = dt.getMilliseconds();
40
- return hhMmSs(dt, timeSeparator) + msSeparator + (ms < 10 ? "00" + ms : ms < 100 ? "0" + ms : ms);
41
- }
42
- function tzShort(dt = /* @__PURE__ */ new Date()) {
43
- if (dt.getTimezoneOffset() === 0) {
44
- return "Z";
45
- }
46
- const tzHours = dt.getTimezoneOffset() / 60;
47
- return tzHours >= 0 ? "+" + tzHours : String(tzHours);
48
- }
49
- function getLongMonthNameZeroIndexed(month, locales = "default") {
50
- return new Date(2024, month, 15).toLocaleString(locales, {
51
- month: "long"
52
- });
53
- }
54
- function getLongMonthNameOneIndexed(month, locales = "default") {
55
- return getLongMonthNameZeroIndexed(month - 1, locales);
56
- }
57
- function getShortMonthNameZeroIndexed(month, locales = "default") {
58
- return new Date(2e3, month, 15).toLocaleString(locales, {
59
- month: "short"
60
- });
61
- }
62
- function getShortMonthNameOneIndexed(month, locales = "default") {
63
- return getShortMonthNameZeroIndexed(month - 1, locales);
64
- }
65
- function getDisplayDateTime(ts) {
66
- const iso = toDate(ts).toISOString();
67
- const noMs = iso.slice(0, 19) + "Z";
68
- return noMs.replace("T", " ");
69
- }
1
+ import {
2
+ getDisplayDateTime,
3
+ getLongMonthNameOneIndexed,
4
+ getLongMonthNameZeroIndexed,
5
+ getShortMonthNameOneIndexed,
6
+ getShortMonthNameZeroIndexed,
7
+ hhMm,
8
+ hhMmSs,
9
+ hhMmSsMs,
10
+ init_dateTimeStr,
11
+ toDate,
12
+ tzShort,
13
+ yyyyMm,
14
+ yyyyMmDd
15
+ } from "./chunk-ZZZB7NJX.mjs";
16
+ import "./chunk-M6PYQYOX.mjs";
17
+ init_dateTimeStr();
70
18
  export {
71
19
  getDisplayDateTime,
72
20
  getLongMonthNameOneIndexed,