zeed 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (575) hide show
  1. package/AGENTS.md +50 -211
  2. package/README.md +16 -0
  3. package/dist/_experiments/bitcask.cjs +243 -1
  4. package/dist/_experiments/bitcask.cjs.map +1 -1
  5. package/dist/_experiments/bitcask.mjs +230 -1
  6. package/dist/_experiments/bitcask.mjs.map +1 -1
  7. package/dist/bin-BAoS4qtm.mjs +593 -0
  8. package/dist/{bin-SPdenYkw.mjs.map → bin-BAoS4qtm.mjs.map} +1 -1
  9. package/dist/bin-Ddaz2lxM.cjs +862 -0
  10. package/dist/{bin-Ce3i6ABn.cjs.map → bin-Ddaz2lxM.cjs.map} +1 -1
  11. package/dist/browser/base64.cjs +14 -1
  12. package/dist/browser/base64.cjs.map +1 -1
  13. package/dist/browser/base64.mjs +12 -1
  14. package/dist/browser/base64.mjs.map +1 -1
  15. package/dist/browser/gravatar.cjs +186 -1
  16. package/dist/browser/gravatar.cjs.map +1 -1
  17. package/dist/browser/gravatar.mjs +184 -1
  18. package/dist/browser/gravatar.mjs.map +1 -1
  19. package/dist/browser/index.cjs +14 -1
  20. package/dist/browser/index.mjs +8 -1
  21. package/dist/browser/localstorage.cjs +46 -1
  22. package/dist/browser/localstorage.cjs.map +1 -1
  23. package/dist/browser/localstorage.mjs +45 -1
  24. package/dist/browser/localstorage.mjs.map +1 -1
  25. package/dist/browser/log/index.cjs +8 -1
  26. package/dist/browser/log/index.mjs +5 -1
  27. package/dist/browser/log/log-browser-factory.cjs +65 -1
  28. package/dist/browser/log/log-browser-factory.cjs.map +1 -1
  29. package/dist/browser/log/log-browser-factory.mjs +64 -1
  30. package/dist/browser/log/log-browser-factory.mjs.map +1 -1
  31. package/dist/browser/log/log-browser.cjs +72 -1
  32. package/dist/browser/log/log-browser.cjs.map +1 -1
  33. package/dist/browser/log/log-browser.mjs +71 -1
  34. package/dist/browser/log/log-browser.mjs.map +1 -1
  35. package/dist/browser/log/log-colors.cjs +11 -1
  36. package/dist/browser/log/log-colors.cjs.map +1 -1
  37. package/dist/browser/log/log-colors.mjs +9 -1
  38. package/dist/browser/log/log-colors.mjs.map +1 -1
  39. package/dist/browser/log/log-context-browser.cjs +25 -1
  40. package/dist/browser/log/log-context-browser.cjs.map +1 -1
  41. package/dist/browser/log/log-context-browser.mjs +23 -1
  42. package/dist/browser/log/log-context-browser.mjs.map +1 -1
  43. package/dist/chunk-DQk6qfdC.mjs +18 -0
  44. package/dist/chunk-uaV2rQ02.cjs +53 -0
  45. package/dist/common/assert.cjs +22 -1
  46. package/dist/common/assert.cjs.map +1 -1
  47. package/dist/common/assert.mjs +19 -1
  48. package/dist/common/assert.mjs.map +1 -1
  49. package/dist/common/bin/index.cjs +106 -1
  50. package/dist/common/bin/index.cjs.map +1 -1
  51. package/dist/common/bin/index.mjs +98 -1
  52. package/dist/common/bin/index.mjs.map +1 -1
  53. package/dist/common/bin/lib0/binary.cjs +146 -1
  54. package/dist/common/bin/lib0/binary.cjs.map +1 -1
  55. package/dist/common/bin/lib0/binary.mjs +80 -1
  56. package/dist/common/bin/lib0/binary.mjs.map +1 -1
  57. package/dist/common/bin/lib0/buffer.cjs +42 -1
  58. package/dist/common/bin/lib0/buffer.cjs.map +1 -1
  59. package/dist/common/bin/lib0/buffer.mjs +38 -1
  60. package/dist/common/bin/lib0/buffer.mjs.map +1 -1
  61. package/dist/common/bin/lib0/create.cjs +24 -1
  62. package/dist/common/bin/lib0/create.cjs.map +1 -1
  63. package/dist/common/bin/lib0/create.mjs +21 -1
  64. package/dist/common/bin/lib0/create.mjs.map +1 -1
  65. package/dist/common/bin/lib0/decoding.cjs +325 -1
  66. package/dist/common/bin/lib0/decoding.cjs.map +1 -1
  67. package/dist/common/bin/lib0/decoding.mjs +298 -1
  68. package/dist/common/bin/lib0/decoding.mjs.map +1 -1
  69. package/dist/common/bin/lib0/encoding.cjs +404 -1
  70. package/dist/common/bin/lib0/encoding.cjs.map +1 -1
  71. package/dist/common/bin/lib0/encoding.mjs +377 -1
  72. package/dist/common/bin/lib0/encoding.mjs.map +1 -1
  73. package/dist/common/bin/lib0/string.cjs +81 -1
  74. package/dist/common/bin/lib0/string.cjs.map +1 -1
  75. package/dist/common/bin/lib0/string.mjs +71 -1
  76. package/dist/common/bin/lib0/string.mjs.map +1 -1
  77. package/dist/common/crypto/aes-sealed.cjs +34 -1
  78. package/dist/common/crypto/aes-sealed.cjs.map +1 -1
  79. package/dist/common/crypto/aes-sealed.mjs +32 -1
  80. package/dist/common/crypto/aes-sealed.mjs.map +1 -1
  81. package/dist/common/crypto/crypto.cjs +91 -1
  82. package/dist/common/crypto/crypto.cjs.map +1 -1
  83. package/dist/common/crypto/crypto.mjs +80 -1
  84. package/dist/common/crypto/crypto.mjs.map +1 -1
  85. package/dist/common/crypto/index.cjs +23 -1
  86. package/dist/common/crypto/index.mjs +5 -1
  87. package/dist/common/crypto/xaes.cjs +128 -1
  88. package/dist/common/crypto/xaes.cjs.map +1 -1
  89. package/dist/common/crypto/xaes.mjs +123 -1
  90. package/dist/common/crypto/xaes.mjs.map +1 -1
  91. package/dist/common/csv.cjs +49 -4
  92. package/dist/common/csv.cjs.map +1 -1
  93. package/dist/common/csv.mjs +46 -4
  94. package/dist/common/csv.mjs.map +1 -1
  95. package/dist/common/data/array.cjs +299 -1
  96. package/dist/common/data/array.cjs.map +1 -1
  97. package/dist/common/data/array.mjs +274 -1
  98. package/dist/common/data/array.mjs.map +1 -1
  99. package/dist/common/data/basex-secure.cjs +30 -1
  100. package/dist/common/data/basex-secure.mjs +3 -1
  101. package/dist/common/data/basex.cjs +163 -1
  102. package/dist/common/data/basex.cjs.map +1 -1
  103. package/dist/common/data/basex.mjs +152 -1
  104. package/dist/common/data/basex.mjs.map +1 -1
  105. package/dist/common/data/bin-types.mjs +1 -1
  106. package/dist/common/data/bin.cjs +21 -1
  107. package/dist/common/data/bin.mjs +3 -1
  108. package/dist/common/data/camelcase.cjs +27 -1
  109. package/dist/common/data/camelcase.cjs.map +1 -1
  110. package/dist/common/data/camelcase.mjs +22 -1
  111. package/dist/common/data/camelcase.mjs.map +1 -1
  112. package/dist/common/data/convert.cjs +104 -1
  113. package/dist/common/data/convert.cjs.map +1 -1
  114. package/dist/common/data/convert.mjs +88 -1
  115. package/dist/common/data/convert.mjs.map +1 -1
  116. package/dist/common/data/datauri.cjs +32 -1
  117. package/dist/common/data/datauri.cjs.map +1 -1
  118. package/dist/common/data/datauri.mjs +27 -1
  119. package/dist/common/data/datauri.mjs.map +1 -1
  120. package/dist/common/data/day-legacy.cjs +148 -1
  121. package/dist/common/data/day-legacy.cjs.map +1 -1
  122. package/dist/common/data/day-legacy.mjs +143 -1
  123. package/dist/common/data/day-legacy.mjs.map +1 -1
  124. package/dist/common/data/day.cjs +335 -1
  125. package/dist/common/data/day.cjs.map +1 -1
  126. package/dist/common/data/day.mjs +305 -1
  127. package/dist/common/data/day.mjs.map +1 -1
  128. package/dist/common/data/decimal.cjs +28 -1
  129. package/dist/common/data/decimal.cjs.map +1 -1
  130. package/dist/common/data/decimal.mjs +23 -1
  131. package/dist/common/data/decimal.mjs.map +1 -1
  132. package/dist/common/data/deep.cjs +57 -1
  133. package/dist/common/data/deep.cjs.map +1 -1
  134. package/dist/common/data/deep.mjs +54 -1
  135. package/dist/common/data/deep.mjs.map +1 -1
  136. package/dist/common/data/diff.cjs +62 -1
  137. package/dist/common/data/diff.cjs.map +1 -1
  138. package/dist/common/data/diff.mjs +60 -1
  139. package/dist/common/data/diff.mjs.map +1 -1
  140. package/dist/common/data/distributed.cjs +24 -1
  141. package/dist/common/data/distributed.cjs.map +1 -1
  142. package/dist/common/data/distributed.mjs +22 -1
  143. package/dist/common/data/distributed.mjs.map +1 -1
  144. package/dist/common/data/format.cjs +63 -1
  145. package/dist/common/data/format.cjs.map +1 -1
  146. package/dist/common/data/format.mjs +59 -1
  147. package/dist/common/data/format.mjs.map +1 -1
  148. package/dist/common/data/html.cjs +13 -1
  149. package/dist/common/data/html.cjs.map +1 -1
  150. package/dist/common/data/html.mjs +10 -1
  151. package/dist/common/data/html.mjs.map +1 -1
  152. package/dist/common/data/index.cjs +296 -1
  153. package/dist/common/data/index.mjs +37 -1
  154. package/dist/common/data/is.cjs +106 -1
  155. package/dist/common/data/is.cjs.map +1 -1
  156. package/dist/common/data/is.mjs +85 -1
  157. package/dist/common/data/is.mjs.map +1 -1
  158. package/dist/common/data/json.cjs +70 -1
  159. package/dist/common/data/json.cjs.map +1 -1
  160. package/dist/common/data/json.mjs +65 -1
  161. package/dist/common/data/json.mjs.map +1 -1
  162. package/dist/common/data/list.cjs +32 -1
  163. package/dist/common/data/list.cjs.map +1 -1
  164. package/dist/common/data/list.mjs +27 -1
  165. package/dist/common/data/list.mjs.map +1 -1
  166. package/dist/common/data/lru.mjs +1 -1
  167. package/dist/common/data/math.cjs +79 -1
  168. package/dist/common/data/math.cjs.map +1 -1
  169. package/dist/common/data/math.mjs +65 -1
  170. package/dist/common/data/math.mjs.map +1 -1
  171. package/dist/common/data/message.cjs +30 -1
  172. package/dist/common/data/message.cjs.map +1 -1
  173. package/dist/common/data/message.mjs +28 -1
  174. package/dist/common/data/message.mjs.map +1 -1
  175. package/dist/common/data/object-changes.cjs +66 -1
  176. package/dist/common/data/object-changes.cjs.map +1 -1
  177. package/dist/common/data/object-changes.mjs +63 -1
  178. package/dist/common/data/object-changes.mjs.map +1 -1
  179. package/dist/common/data/object.cjs +112 -1
  180. package/dist/common/data/object.cjs.map +1 -1
  181. package/dist/common/data/object.mjs +104 -1
  182. package/dist/common/data/object.mjs.map +1 -1
  183. package/dist/common/data/orderby.cjs +42 -1
  184. package/dist/common/data/orderby.cjs.map +1 -1
  185. package/dist/common/data/orderby.mjs +37 -1
  186. package/dist/common/data/orderby.mjs.map +1 -1
  187. package/dist/common/data/path.cjs +26 -1
  188. package/dist/common/data/path.cjs.map +1 -1
  189. package/dist/common/data/path.mjs +25 -1
  190. package/dist/common/data/path.mjs.map +1 -1
  191. package/dist/common/data/regexp.cjs +12 -1
  192. package/dist/common/data/regexp.cjs.map +1 -1
  193. package/dist/common/data/regexp.mjs +10 -1
  194. package/dist/common/data/regexp.mjs.map +1 -1
  195. package/dist/common/data/rounding.cjs +107 -1
  196. package/dist/common/data/rounding.cjs.map +1 -1
  197. package/dist/common/data/rounding.mjs +95 -1
  198. package/dist/common/data/rounding.mjs.map +1 -1
  199. package/dist/common/data/signal.cjs +39 -1
  200. package/dist/common/data/signal.cjs.map +1 -1
  201. package/dist/common/data/signal.mjs +38 -1
  202. package/dist/common/data/signal.mjs.map +1 -1
  203. package/dist/common/data/sortable.cjs +35 -1
  204. package/dist/common/data/sortable.cjs.map +1 -1
  205. package/dist/common/data/sortable.mjs +31 -1
  206. package/dist/common/data/sortable.mjs.map +1 -1
  207. package/dist/common/data/sorted.cjs +54 -1
  208. package/dist/common/data/sorted.cjs.map +1 -1
  209. package/dist/common/data/sorted.mjs +53 -1
  210. package/dist/common/data/sorted.mjs.map +1 -1
  211. package/dist/common/data/string-deburr.cjs +240 -1
  212. package/dist/common/data/string-deburr.cjs.map +1 -1
  213. package/dist/common/data/string-deburr.mjs +238 -1
  214. package/dist/common/data/string-deburr.mjs.map +1 -1
  215. package/dist/common/data/string-hash-fnv.cjs +69 -1
  216. package/dist/common/data/string-hash-fnv.cjs.map +1 -1
  217. package/dist/common/data/string-hash-fnv.mjs +67 -1
  218. package/dist/common/data/string-hash-fnv.mjs.map +1 -1
  219. package/dist/common/data/string-hash-pool.cjs +28 -1
  220. package/dist/common/data/string-hash-pool.cjs.map +1 -1
  221. package/dist/common/data/string-hash-pool.mjs +27 -1
  222. package/dist/common/data/string-hash-pool.mjs.map +1 -1
  223. package/dist/common/data/url.cjs +98 -2
  224. package/dist/common/data/url.cjs.map +1 -1
  225. package/dist/common/data/url.mjs +91 -2
  226. package/dist/common/data/url.mjs.map +1 -1
  227. package/dist/common/data/utils.cjs +118 -1
  228. package/dist/common/data/utils.cjs.map +1 -1
  229. package/dist/common/data/utils.mjs +107 -1
  230. package/dist/common/data/utils.mjs.map +1 -1
  231. package/dist/common/data/wordlist.cjs +531 -1
  232. package/dist/common/data/wordlist.cjs.map +1 -1
  233. package/dist/common/data/wordlist.mjs +529 -1
  234. package/dist/common/data/wordlist.mjs.map +1 -1
  235. package/dist/common/data/xrx.cjs +96 -1
  236. package/dist/common/data/xrx.cjs.map +1 -1
  237. package/dist/common/data/xrx.mjs +92 -1
  238. package/dist/common/data/xrx.mjs.map +1 -1
  239. package/dist/common/dispose-defer.cjs +133 -1
  240. package/dist/common/dispose-defer.cjs.map +1 -1
  241. package/dist/common/dispose-defer.mjs +130 -1
  242. package/dist/common/dispose-defer.mjs.map +1 -1
  243. package/dist/common/dispose-types.mjs +1 -1
  244. package/dist/common/dispose-utils.cjs +113 -1
  245. package/dist/common/dispose-utils.cjs.map +1 -1
  246. package/dist/common/dispose-utils.mjs +106 -1
  247. package/dist/common/dispose-utils.mjs.map +1 -1
  248. package/dist/common/exec/index.cjs +24 -1
  249. package/dist/common/exec/index.d.cts +1 -1
  250. package/dist/common/exec/index.d.mts +1 -1
  251. package/dist/common/exec/index.mjs +8 -1
  252. package/dist/common/exec/mutex.cjs +44 -1
  253. package/dist/common/exec/mutex.cjs.map +1 -1
  254. package/dist/common/exec/mutex.mjs +42 -1
  255. package/dist/common/exec/mutex.mjs.map +1 -1
  256. package/dist/common/exec/pool.cjs +181 -1
  257. package/dist/common/exec/pool.cjs.map +1 -1
  258. package/dist/common/exec/pool.d.cts +1 -1
  259. package/dist/common/exec/pool.d.mts +1 -1
  260. package/dist/common/exec/pool.mjs +180 -1
  261. package/dist/common/exec/pool.mjs.map +1 -1
  262. package/dist/common/exec/progress.cjs +149 -1
  263. package/dist/common/exec/progress.cjs.map +1 -1
  264. package/dist/common/exec/progress.d.cts +1 -1
  265. package/dist/common/exec/progress.d.mts +1 -1
  266. package/dist/common/exec/progress.mjs +148 -1
  267. package/dist/common/exec/progress.mjs.map +1 -1
  268. package/dist/common/exec/promise.cjs +113 -1
  269. package/dist/common/exec/promise.cjs.map +1 -1
  270. package/dist/common/exec/promise.mjs +103 -1
  271. package/dist/common/exec/promise.mjs.map +1 -1
  272. package/dist/common/exec/queue.cjs +125 -1
  273. package/dist/common/exec/queue.cjs.map +1 -1
  274. package/dist/common/exec/queue.d.cts +1 -1
  275. package/dist/common/exec/queue.d.mts +1 -1
  276. package/dist/common/exec/queue.mjs +124 -1
  277. package/dist/common/exec/queue.mjs.map +1 -1
  278. package/dist/common/exec/throttle-debounce.cjs +114 -1
  279. package/dist/common/exec/throttle-debounce.cjs.map +1 -1
  280. package/dist/common/exec/throttle-debounce.mjs +112 -1
  281. package/dist/common/exec/throttle-debounce.mjs.map +1 -1
  282. package/dist/common/global.cjs +22 -1
  283. package/dist/common/global.cjs.map +1 -1
  284. package/dist/common/global.mjs +19 -1
  285. package/dist/common/global.mjs.map +1 -1
  286. package/dist/common/index.cjs +559 -1
  287. package/dist/common/index.d.cts +1 -1
  288. package/dist/common/index.d.mts +1 -1
  289. package/dist/common/index.mjs +89 -1
  290. package/dist/common/localhost.cjs +16 -1
  291. package/dist/common/localhost.cjs.map +1 -1
  292. package/dist/common/localhost.mjs +14 -1
  293. package/dist/common/localhost.mjs.map +1 -1
  294. package/dist/common/log/index.cjs +34 -1
  295. package/dist/common/log/index.mjs +11 -1
  296. package/dist/common/log/log-base.cjs +40 -1
  297. package/dist/common/log/log-base.cjs.map +1 -1
  298. package/dist/common/log/log-base.mjs +31 -1
  299. package/dist/common/log/log-base.mjs.map +1 -1
  300. package/dist/common/log/log-colors.cjs +92 -1
  301. package/dist/common/log/log-colors.cjs.map +1 -1
  302. package/dist/common/log/log-colors.mjs +90 -1
  303. package/dist/common/log/log-colors.mjs.map +1 -1
  304. package/dist/common/log/log-config.cjs +15 -1
  305. package/dist/common/log/log-config.cjs.map +1 -1
  306. package/dist/common/log/log-config.mjs +14 -1
  307. package/dist/common/log/log-config.mjs.map +1 -1
  308. package/dist/common/log/log-console-capture.cjs +33 -1
  309. package/dist/common/log/log-console-capture.cjs.map +1 -1
  310. package/dist/common/log/log-console-capture.mjs +32 -1
  311. package/dist/common/log/log-console-capture.mjs.map +1 -1
  312. package/dist/common/log/log-console-original.cjs +27 -1
  313. package/dist/common/log/log-console-original.cjs.map +1 -1
  314. package/dist/common/log/log-console-original.mjs +26 -1
  315. package/dist/common/log/log-console-original.mjs.map +1 -1
  316. package/dist/common/log/log-console.cjs +39 -1
  317. package/dist/common/log/log-console.cjs.map +1 -1
  318. package/dist/common/log/log-console.mjs +38 -1
  319. package/dist/common/log/log-console.mjs.map +1 -1
  320. package/dist/common/log/log-context.cjs +109 -1
  321. package/dist/common/log/log-context.cjs.map +1 -1
  322. package/dist/common/log/log-context.mjs +108 -1
  323. package/dist/common/log/log-context.mjs.map +1 -1
  324. package/dist/common/log/log-filter.cjs +80 -1
  325. package/dist/common/log/log-filter.cjs.map +1 -1
  326. package/dist/common/log/log-filter.mjs +75 -1
  327. package/dist/common/log/log-filter.mjs.map +1 -1
  328. package/dist/common/log/log-memory.cjs +45 -1
  329. package/dist/common/log/log-memory.cjs.map +1 -1
  330. package/dist/common/log/log-memory.mjs +43 -1
  331. package/dist/common/log/log-memory.mjs.map +1 -1
  332. package/dist/common/log/log-noop.cjs +17 -1
  333. package/dist/common/log/log-noop.cjs.map +1 -1
  334. package/dist/common/log/log-noop.mjs +15 -1
  335. package/dist/common/log/log-noop.mjs.map +1 -1
  336. package/dist/common/log/log.cjs +46 -1
  337. package/dist/common/log/log.cjs.map +1 -1
  338. package/dist/common/log/log.mjs +43 -1
  339. package/dist/common/log/log.mjs.map +1 -1
  340. package/dist/common/msg/channel-debug.cjs +17 -1
  341. package/dist/common/msg/channel-debug.cjs.map +1 -1
  342. package/dist/common/msg/channel-debug.d.cts +1 -1
  343. package/dist/common/msg/channel-debug.d.mts +1 -1
  344. package/dist/common/msg/channel-debug.mjs +16 -1
  345. package/dist/common/msg/channel-debug.mjs.map +1 -1
  346. package/dist/common/msg/channel-local.cjs +28 -1
  347. package/dist/common/msg/channel-local.cjs.map +1 -1
  348. package/dist/common/msg/channel-local.d.cts +1 -1
  349. package/dist/common/msg/channel-local.d.mts +1 -1
  350. package/dist/common/msg/channel-local.mjs +26 -1
  351. package/dist/common/msg/channel-local.mjs.map +1 -1
  352. package/dist/common/msg/channel-resilient.cjs +63 -1
  353. package/dist/common/msg/channel-resilient.cjs.map +1 -1
  354. package/dist/common/msg/channel-resilient.d.cts +1 -1
  355. package/dist/common/msg/channel-resilient.d.mts +1 -1
  356. package/dist/common/msg/channel-resilient.mjs +62 -1
  357. package/dist/common/msg/channel-resilient.mjs.map +1 -1
  358. package/dist/common/msg/channel-wkwebview.cjs +35 -1
  359. package/dist/common/msg/channel-wkwebview.cjs.map +1 -1
  360. package/dist/common/msg/channel-wkwebview.d.cts +2 -1
  361. package/dist/common/msg/channel-wkwebview.d.mts +2 -1
  362. package/dist/common/msg/channel-wkwebview.mjs +34 -1
  363. package/dist/common/msg/channel-wkwebview.mjs.map +1 -1
  364. package/dist/common/msg/channel.cjs +23 -1
  365. package/dist/common/msg/channel.cjs.map +1 -1
  366. package/dist/common/msg/channel.d.cts +1 -1
  367. package/dist/common/msg/channel.d.mts +1 -1
  368. package/dist/common/msg/channel.mjs +22 -1
  369. package/dist/common/msg/channel.mjs.map +1 -1
  370. package/dist/common/msg/emitter.cjs +141 -1
  371. package/dist/common/msg/emitter.cjs.map +1 -1
  372. package/dist/common/msg/emitter.d.cts +1 -1
  373. package/dist/common/msg/emitter.d.mts +1 -1
  374. package/dist/common/msg/emitter.mjs +139 -1
  375. package/dist/common/msg/emitter.mjs.map +1 -1
  376. package/dist/common/msg/encoder.cjs +38 -1
  377. package/dist/common/msg/encoder.cjs.map +1 -1
  378. package/dist/common/msg/encoder.mjs +35 -1
  379. package/dist/common/msg/encoder.mjs.map +1 -1
  380. package/dist/common/msg/index.cjs +28 -1
  381. package/dist/common/msg/index.d.cts +1 -1
  382. package/dist/common/msg/index.d.mts +1 -1
  383. package/dist/common/msg/index.mjs +11 -1
  384. package/dist/common/msg/messages.cjs +135 -1
  385. package/dist/common/msg/messages.cjs.map +1 -1
  386. package/dist/common/msg/messages.d.cts +1 -1
  387. package/dist/common/msg/messages.d.mts +1 -1
  388. package/dist/common/msg/messages.mjs +133 -1
  389. package/dist/common/msg/messages.mjs.map +1 -1
  390. package/dist/common/msg/pipe.mjs +1 -1
  391. package/dist/common/msg/pubsub.cjs +78 -1
  392. package/dist/common/msg/pubsub.cjs.map +1 -1
  393. package/dist/common/msg/pubsub.d.cts +1 -1
  394. package/dist/common/msg/pubsub.d.mts +1 -1
  395. package/dist/common/msg/pubsub.mjs +76 -1
  396. package/dist/common/msg/pubsub.mjs.map +1 -1
  397. package/dist/common/msg/rpc.cjs +142 -1
  398. package/dist/common/msg/rpc.cjs.map +1 -1
  399. package/dist/common/msg/rpc.mjs +139 -1
  400. package/dist/common/msg/rpc.mjs.map +1 -1
  401. package/dist/common/network.cjs +129 -1
  402. package/dist/common/network.cjs.map +1 -1
  403. package/dist/common/network.mjs +122 -1
  404. package/dist/common/network.mjs.map +1 -1
  405. package/dist/common/platform.cjs +92 -1
  406. package/dist/common/platform.cjs.map +1 -1
  407. package/dist/common/platform.mjs +84 -1
  408. package/dist/common/platform.mjs.map +1 -1
  409. package/dist/common/schema/_sandbox/sandbox-inherit.mjs +1 -1
  410. package/dist/common/schema/_sandbox/sandbox.mjs +1 -1
  411. package/dist/common/schema/_sandbox/sandbox.xspec.mjs +1 -1
  412. package/dist/common/schema/export-json-schema.cjs +54 -1
  413. package/dist/common/schema/export-json-schema.cjs.map +1 -1
  414. package/dist/common/schema/export-json-schema.mjs +52 -1
  415. package/dist/common/schema/export-json-schema.mjs.map +1 -1
  416. package/dist/common/schema/export-swift.cjs +30 -2
  417. package/dist/common/schema/export-swift.cjs.map +1 -1
  418. package/dist/common/schema/export-swift.mjs +29 -2
  419. package/dist/common/schema/export-swift.mjs.map +1 -1
  420. package/dist/common/schema/export-typescript.cjs +20 -2
  421. package/dist/common/schema/export-typescript.cjs.map +1 -1
  422. package/dist/common/schema/export-typescript.mjs +19 -2
  423. package/dist/common/schema/export-typescript.mjs.map +1 -1
  424. package/dist/common/schema/index.cjs +55 -1
  425. package/dist/common/schema/index.mjs +12 -1
  426. package/dist/common/schema/parse-args.cjs +62 -2
  427. package/dist/common/schema/parse-args.cjs.map +1 -1
  428. package/dist/common/schema/parse-args.mjs +60 -2
  429. package/dist/common/schema/parse-args.mjs.map +1 -1
  430. package/dist/common/schema/parse-env.cjs +48 -3
  431. package/dist/common/schema/parse-env.cjs.map +1 -1
  432. package/dist/common/schema/parse-env.mjs +46 -3
  433. package/dist/common/schema/parse-env.mjs.map +1 -1
  434. package/dist/common/schema/parse-object.cjs +122 -1
  435. package/dist/common/schema/parse-object.cjs.map +1 -1
  436. package/dist/common/schema/parse-object.mjs +119 -1
  437. package/dist/common/schema/parse-object.mjs.map +1 -1
  438. package/dist/common/schema/schema-standard.mjs +1 -1
  439. package/dist/common/schema/schema.cjs +423 -1
  440. package/dist/common/schema/schema.cjs.map +1 -1
  441. package/dist/common/schema/schema.mjs +404 -1
  442. package/dist/common/schema/schema.mjs.map +1 -1
  443. package/dist/common/schema/serialize.cjs +109 -1
  444. package/dist/common/schema/serialize.cjs.map +1 -1
  445. package/dist/common/schema/serialize.mjs +107 -1
  446. package/dist/common/schema/serialize.mjs.map +1 -1
  447. package/dist/common/schema/type-test.mjs +1 -1
  448. package/dist/common/schema/utils.cjs +25 -1
  449. package/dist/common/schema/utils.cjs.map +1 -1
  450. package/dist/common/schema/utils.mjs +19 -1
  451. package/dist/common/schema/utils.mjs.map +1 -1
  452. package/dist/common/schema/z-collection.cjs +51 -1
  453. package/dist/common/schema/z-collection.mjs +27 -1
  454. package/dist/common/schema/z.cjs +9 -1
  455. package/dist/common/schema/z.mjs +3 -1
  456. package/dist/common/storage/index.cjs +4 -1
  457. package/dist/common/storage/index.mjs +3 -1
  458. package/dist/common/storage/memstorage.cjs +26 -1
  459. package/dist/common/storage/memstorage.cjs.map +1 -1
  460. package/dist/common/storage/memstorage.mjs +25 -1
  461. package/dist/common/storage/memstorage.mjs.map +1 -1
  462. package/dist/common/test.cjs +14 -1
  463. package/dist/common/test.cjs.map +1 -1
  464. package/dist/common/test.mjs +13 -1
  465. package/dist/common/test.mjs.map +1 -1
  466. package/dist/common/time.cjs +220 -1
  467. package/dist/common/time.cjs.map +1 -1
  468. package/dist/common/time.mjs +194 -1
  469. package/dist/common/time.mjs.map +1 -1
  470. package/dist/common/timeout.cjs +27 -1
  471. package/dist/common/timeout.cjs.map +1 -1
  472. package/dist/common/timeout.mjs +25 -1
  473. package/dist/common/timeout.mjs.map +1 -1
  474. package/dist/common/types.mjs +1 -1
  475. package/dist/common/utils.cjs +7 -1
  476. package/dist/common/utils.cjs.map +1 -1
  477. package/dist/common/utils.mjs +5 -1
  478. package/dist/common/utils.mjs.map +1 -1
  479. package/dist/common/uuid.cjs +307 -1
  480. package/dist/common/uuid.cjs.map +1 -1
  481. package/dist/common/uuid.mjs +284 -1
  482. package/dist/common/uuid.mjs.map +1 -1
  483. package/dist/{index-DHXVOH8h.d.cts → index-CFkMqHvX.d.cts} +1 -2
  484. package/dist/{index-DMaPyx9O.d.mts → index-C_3Y_s6f.d.mts} +1 -2
  485. package/dist/index.all.cjs +641 -1
  486. package/dist/index.all.d.cts +1 -1
  487. package/dist/index.all.d.mts +1 -1
  488. package/dist/index.all.mjs +113 -1
  489. package/dist/index.browser.cjs +576 -1
  490. package/dist/index.browser.d.cts +1 -1
  491. package/dist/index.browser.d.mts +1 -1
  492. package/dist/index.browser.mjs +98 -1
  493. package/dist/index.jsr.cjs +57 -1
  494. package/dist/index.jsr.mjs +6 -1
  495. package/dist/index.node.cjs +628 -1
  496. package/dist/index.node.d.cts +1 -1
  497. package/dist/index.node.d.mts +1 -1
  498. package/dist/index.node.mjs +106 -1
  499. package/dist/node/args.cjs +56 -1
  500. package/dist/node/args.cjs.map +1 -1
  501. package/dist/node/args.mjs +53 -1
  502. package/dist/node/args.mjs.map +1 -1
  503. package/dist/node/clipboard.cjs +18 -1
  504. package/dist/node/clipboard.cjs.map +1 -1
  505. package/dist/node/clipboard.mjs +16 -1
  506. package/dist/node/clipboard.mjs.map +1 -1
  507. package/dist/node/crypto.cjs +28 -1
  508. package/dist/node/crypto.cjs.map +1 -1
  509. package/dist/node/crypto.mjs +24 -1
  510. package/dist/node/crypto.mjs.map +1 -1
  511. package/dist/node/env.cjs +100 -4
  512. package/dist/node/env.cjs.map +1 -1
  513. package/dist/node/env.mjs +90 -4
  514. package/dist/node/env.mjs.map +1 -1
  515. package/dist/node/files-async.cjs +66 -1
  516. package/dist/node/files-async.cjs.map +1 -1
  517. package/dist/node/files-async.mjs +60 -1
  518. package/dist/node/files-async.mjs.map +1 -1
  519. package/dist/node/files.cjs +52 -1
  520. package/dist/node/files.cjs.map +1 -1
  521. package/dist/node/files.mjs +46 -1
  522. package/dist/node/files.mjs.map +1 -1
  523. package/dist/node/filestorage.cjs +100 -1
  524. package/dist/node/filestorage.cjs.map +1 -1
  525. package/dist/node/filestorage.mjs +97 -1
  526. package/dist/node/filestorage.mjs.map +1 -1
  527. package/dist/node/fs.cjs +119 -1
  528. package/dist/node/fs.cjs.map +1 -1
  529. package/dist/node/fs.mjs +101 -1
  530. package/dist/node/fs.mjs.map +1 -1
  531. package/dist/node/glob.cjs +75 -1
  532. package/dist/node/glob.cjs.map +1 -1
  533. package/dist/node/glob.mjs +73 -1
  534. package/dist/node/glob.mjs.map +1 -1
  535. package/dist/node/index.cjs +66 -1
  536. package/dist/node/index.mjs +16 -1
  537. package/dist/node/log/index.cjs +20 -1
  538. package/dist/node/log/index.mjs +7 -1
  539. package/dist/node/log/log-context-node.cjs +39 -1
  540. package/dist/node/log/log-context-node.cjs.map +1 -1
  541. package/dist/node/log/log-context-node.mjs +35 -1
  542. package/dist/node/log/log-context-node.mjs.map +1 -1
  543. package/dist/node/log/log-file-rotation.cjs +71 -1
  544. package/dist/node/log/log-file-rotation.cjs.map +1 -1
  545. package/dist/node/log/log-file-rotation.mjs +68 -1
  546. package/dist/node/log/log-file-rotation.mjs.map +1 -1
  547. package/dist/node/log/log-file.cjs +57 -1
  548. package/dist/node/log/log-file.cjs.map +1 -1
  549. package/dist/node/log/log-file.mjs +54 -1
  550. package/dist/node/log/log-file.mjs.map +1 -1
  551. package/dist/node/log/log-node.cjs +162 -1
  552. package/dist/node/log/log-node.cjs.map +1 -1
  553. package/dist/node/log/log-node.mjs +155 -1
  554. package/dist/node/log/log-node.mjs.map +1 -1
  555. package/dist/node/log/log-rotation.cjs +543 -3
  556. package/dist/node/log/log-rotation.cjs.map +1 -1
  557. package/dist/node/log/log-rotation.mjs +538 -3
  558. package/dist/node/log/log-rotation.mjs.map +1 -1
  559. package/dist/node/log/log-util.cjs +69 -3
  560. package/dist/node/log/log-util.cjs.map +1 -1
  561. package/dist/node/log/log-util.mjs +63 -3
  562. package/dist/node/log/log-util.mjs.map +1 -1
  563. package/dist/node/open-browser.cjs +20 -1
  564. package/dist/node/open-browser.cjs.map +1 -1
  565. package/dist/node/open-browser.mjs +18 -1
  566. package/dist/node/open-browser.mjs.map +1 -1
  567. package/package.json +15 -15
  568. package/src/common/schema/README.md +247 -66
  569. package/src/eslint-defaults.js +4 -0
  570. package/src/index.spec.ts +6 -6
  571. package/dist/bin-Ce3i6ABn.cjs +0 -3
  572. package/dist/bin-SPdenYkw.mjs +0 -3
  573. package/dist/chunk-0Lt9GpW0.mjs +0 -1
  574. package/dist/chunk-D-qHiVGv.cjs +0 -1
  575. package/src/common/schema/README-SCHEMA.md +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"day.cjs","names":["TIME_DAY_MS"],"sources":["../../../src/common/data/day.ts"],"sourcesContent":["import { TIME_DAY_MS } from \"../time\"\n\n// Functionality variant\nlet testModeDay: number | undefined\n\n/**\n * Enable test mode for date functions by forcing \"today\" to a fixed day value.\n *\n * Use a numeric DayValue like 20000101 (YYYYMMDD). This is intended for tests\n * to make date-based logic deterministic. Call with no args to reset.\n *\n * @param ts - day to use as \"today\" in YYYYMMDD format (default: 20000101)\n */\nexport function setDayTest(ts = 20000101) {\n testModeDay = ts\n}\n\n/** \n * @deprecated use TIME_DAY_MS\n * Number of milliseconds in one calendar day (24 * 60 * 60 * 1000). */\nexport const DAY_MS = TIME_DAY_MS // 1000 * 60 * 60 * 24\n\n/** DayValue is a numeric date encoded as YYYYMMDD (for example 20250907). */\nexport type DayValue = number\n\n/**\n * Accepted inputs for day conversion helpers.\n * - DayValue or number: a YYYYMMDD numeric value\n * - string: a date string (parsed by digits)\n * - Date: JavaScript Date\n * - [year, month?, day?]: numeric parts\n */\nexport type DayInput =\n | DayValue\n | number\n | string\n | Date\n | [number, number?, number?]\n\n/**\n * Extract the year (YYYY) from a DayValue.\n *\n * @param day - day as YYYYMMDD\n * @returns year as number (e.g. 2025)\n */\nexport function dayYear(day: DayValue): DayValue {\n return Math.floor(day / 10000)\n}\n\n/**\n * Extract the month (1-12) from a DayValue.\n *\n * @param day - day as YYYYMMDD\n * @returns month number (1-12)\n */\nexport function dayMonth(day: DayValue): DayValue {\n return Math.floor((day / 100) % 100)\n}\n\n/**\n * Extract the day of month (1-31) from a DayValue.\n *\n * @param day - day as YYYYMMDD\n * @returns day of month (1-31)\n */\nexport function dayDay(day: DayValue): DayValue {\n return Math.floor(day % 100)\n}\n\n/**\n * Split a DayValue into [year, month, day].\n *\n * @param day - day as YYYYMMDD\n * @returns tuple [year, month, day]\n */\nexport function dayToParts(day: DayValue): [number, number, number] {\n return [dayYear(day), dayMonth(day), dayDay(day)]\n}\n\n/**\n * Convert a DayValue to a JavaScript Date.\n *\n * By default returns a local Date at midnight for the day. If `utc` is true\n * the returned Date represents midnight UTC for that day.\n *\n * @param day - day as YYYYMMDD\n * @param utc - whether to construct the Date in UTC (default: false)\n * @returns Date object for the given day\n */\nexport function dayToDate(day: DayValue, utc = false): Date {\n return utc\n ? new Date(`${dayToString(day)}T00:00:00.000Z`)\n : new Date(\n day / 10000, // year\n Math.max(0, ((day / 100) % 100) - 1), // month\n Math.max(1, day % 100), // day\n )\n}\n\n/**\n * Return today's day as a DayValue (YYYYMMDD).\n *\n * If test mode has been enabled via `setDayTest` this returns the forced\n * value instead. Otherwise it uses the current local date.\n */\nexport function dayFromToday(): DayValue {\n return testModeDay ?? dayFromDate(new Date())\n}\n\n/**\n * Convert multiple input types to a DayValue (YYYYMMDD).\n *\n * Supports numbers (DayValue), strings, Date objects and [year, month?, day?]\n * tuples. Returns undefined for invalid or unsupported values.\n *\n * @param value - input to convert\n * @param utc - when converting from Date, interpret as UTC if true\n */\nexport function dayFromAny(\n value: DayInput,\n utc = false,\n): DayValue | undefined {\n if (typeof value === 'number') {\n if (value < 100)\n return\n return value\n }\n else if (typeof value === 'string') {\n return dayFromString(value)\n }\n else if (Array.isArray(value) && value.length >= 1) {\n return dayFromParts(...value)\n }\n else if (value instanceof Date) {\n return dayFromDate(value, utc)\n // } else if (value instanceof Day) {\n // return value.days\n }\n}\n\n/** Convert a DayValue to a Date at midnight UTC. */\nexport function dayToDateUTC(day: DayValue): Date {\n return dayToDate(day, true)\n}\n\n/**\n * @deprecated use dayToDateUTC\n *\n * Kept for backwards compatibility; returns a Date for midnight UTC.\n */\nexport function dayToDateGMT(day: DayValue): Date {\n return dayToDate(day, true)\n}\n\n/**\n * Convert a JavaScript Date to a DayValue (YYYYMMDD).\n *\n * If `utc` is true the function uses the ISO string representation to\n * calculate the day in UTC. Otherwise it uses local date components.\n */\nexport function dayFromDate(date: Date, utc = false): DayValue {\n return (\n utc\n ? dayFromString(date.toISOString())\n : date.getFullYear() * 10000\n + (date.getMonth() + 1) * 100\n + date.getDate()\n )!\n}\n\n/** Convert a Date to DayValue using UTC. */\nexport function dayFromDateUTC(date: Date): DayValue {\n return dayFromDate(date, true)\n}\n\n/** @deprecated use dayFromDateUTC */\n/**\n * Deprecated: use `dayFromDateUTC`.\n *\n * Kept for backwards compatibility; converts a Date to a UTC DayValue.\n */\nexport function dayFromDateGMT(date: Date): DayValue {\n return dayFromDate(date, true)\n}\n\n\n/**\n * Convert a DayValue to a UNIX timestamp in seconds. Returns seconds since\n * epoch for midnight of the given day. Defaults to UTC.\n */\nexport function dayToTimestampSeconds(day: DayValue, utc = true): number {\n return Math.floor(dayToDate(day, utc).getTime() / 1000)\n}\n\n/**\n * Convert a DayValue to a timestamp in milliseconds for midnight of that day.\n * Defaults to UTC when constructing the Date.\n */\nexport function dayToTimestamp(day: DayValue, utc = true): number {\n return dayToDate(day, utc).getTime()\n}\n\n/**\n * Convert a timestamp in milliseconds to a DayValue. The timestamp is turned\n * into a Date and then converted; `utc` controls interpretation.\n */\nexport function dayFromTimestamp(ms: number, utc = true): DayValue {\n return dayFromDate(new Date(ms), utc)\n}\n\n/**\n * Convert a UNIX timestamp in seconds to a DayValue.\n *\n * @param ms - seconds since epoch\n */\nexport function dayFromTimestampSeconds(ms: number, utc = true): DayValue {\n return dayFromDate(new Date(Math.floor(ms * 1000)), utc)\n}\n\n/**\n * Format a DayValue as a string with an optional separator.\n *\n * Example: dayToString(20250907) -> \"2025-09-07\"\n */\nexport function dayToString(day: DayValue, sep = '-') {\n const baseString = String(day)\n return (\n baseString.slice(0, 4) + sep\n + baseString.slice(4, 6) + sep\n + baseString.slice(6, 8)\n )\n}\n\n/**\n * Build a DayValue from numeric parts. Returns undefined for invalid parts.\n *\n * @param year - full year (e.g. 2025)\n * @param month - 1-12 (default 1)\n * @param day - 1-31 (default 1)\n */\nexport function dayFromParts(\n year: number,\n month = 1,\n day = 1,\n): DayValue | undefined {\n if (month < 1 || month > 12 || day < 1 || day > 31)\n return\n return year * 10000 + month * 100 + day\n}\n \n/**\n * Parse a string into a DayValue by extracting up to 8 digits (YYYYMMDD).\n * Returns undefined for invalid results.\n * \n * Example:\n * dayValue === dayFromString(String(dayValue))\n */\nexport function dayFromString(value: string): DayValue | undefined {\n const string = String(value)\n .replace(/\\D/g, '')\n .slice(0, 8)\n if (string.length === 8)\n return +string\n}\n\n/**\n * Return the first day of the month for the given DayValue. An optional\n * `offset` (positive or negative) moves the result by months.\n *\n * @param day - source DayValue\n * @param offset - months to offset (default 0)\n */\nexport function dayMonthStart(day: DayValue, offset = 0): DayValue {\n let year = dayYear(day)\n let month = dayMonth(day)\n if (offset !== 0) {\n month += offset\n year += Math.floor((month - 1) / 12)\n month = Math.floor((month - 1) % 12) + 1\n if (month === 0)\n month = 12\n }\n return dayFromParts(year, month, 1)!\n}\n\n/**\n * Return the day offset by whole months, keeping the day-of-month when possible.\n * If the target month has fewer days, the result is clamped to the last day.\n *\n * @param day - source DayValue\n * @param offset - months to offset (positive or negative)\n */\nexport function dayMonthOffset(day: DayValue, offset: number): DayValue {\n let year = dayYear(day)\n let month = dayMonth(day)\n const dayOfMonth = dayDay(day)\n\n if (offset !== 0) {\n month += offset\n year += Math.floor((month - 1) / 12)\n month = Math.floor((month - 1) % 12) + 1\n if (month === 0)\n month = 12\n }\n\n const maxDay = dayDaysInMonth(year, month)\n return dayFromParts(year, month, Math.min(dayOfMonth, maxDay))!\n}\n\n/**\n * Return the first day of the year for the given DayValue. `offset` moves\n * the year by the given amount.\n */\nexport function dayYearStart(day: DayValue, offset = 0): DayValue {\n const year = dayYear(day)\n return dayFromParts(year + offset, 1, 1)!\n}\n\n/**\n * Return the day offset by whole years, keeping month and day when possible.\n * If the target month has fewer days, the result is clamped to the last day.\n *\n * @param day - source DayValue\n * @param offset - years to offset (positive or negative)\n */\nexport function dayYearOffset(day: DayValue, offset: number): DayValue {\n const year = dayYear(day) + offset\n const month = dayMonth(day)\n const dayOfMonth = dayDay(day)\n const maxDay = dayDaysInMonth(year, month)\n return dayFromParts(year, month, Math.min(dayOfMonth, maxDay))!\n}\n\n/** Return number of days in a given month. Month is 1-12. */\nexport function dayDaysInMonth(year: number, month: number): number {\n return new Date(Date.UTC(year, month, 0)).getUTCDate()\n}\n\n/**\n * Offset a DayValue by a number of days. Uses timestamp math to avoid local\n * DST issues.\n *\n * @param day - source DayValue\n * @param offset - days to add (negative to subtract)\n */\nexport function dayOffset(day: DayValue, offset: number): DayValue {\n // Important! Don't use local time here due to summer/winter time days can\n // be longer or shorter!\n return dayFromTimestamp(dayToTimestamp(day) + offset * TIME_DAY_MS)\n}\n\n/**\n * Compute the difference in whole days between two DayValues (right - left).\n */\nexport function dayDiff(left: DayValue, right: DayValue): number {\n return Math.round((dayToTimestamp(right) - dayToTimestamp(left)) / TIME_DAY_MS)\n}\n\n/**\n * Return an array of DayValues from left to right (inclusive).\n *\n * If `right` is omitted it defaults to today. If `left` is negative it is\n * interpreted as an offset relative to `right` (e.g. -7 means the last 7 days).\n */\nexport function dayRange(left: DayValue, right?: DayValue): number[] {\n const list: number[] = []\n\n if (right == null)\n right = dayFromToday()\n\n if (left < 0)\n left = dayOffset(right, left + 1)\n\n while (left <= right) {\n list.push(left)\n left = dayOffset(left, +1)\n }\n return list\n}\n\n/** Iterator, see dayRange */\n/**\n * Generator that yields DayValues from left to right (inclusive). Same rules\n * as `dayRange` regarding defaults and negative left values.\n */\nexport function* dayIterator(left: DayValue, right?: DayValue) {\n const list: number[] = []\n\n if (right == null)\n right = dayFromToday()\n\n if (left < 0)\n left = dayOffset(right, left + 1)\n\n while (left <= right) {\n yield left\n left = dayOffset(left, +1)\n }\n return list\n}\n\n"],"mappings":"kGAGA,IAAI,EAUJ,SAAgB,EAAW,EAAK,SAAU,CACxC,EAAc,EAMhB,MAAa,EAASA,EAAAA,YAyBtB,SAAgB,EAAQ,EAAyB,CAC/C,OAAO,KAAK,MAAM,EAAM,IAAM,CAShC,SAAgB,EAAS,EAAyB,CAChD,OAAO,KAAK,MAAO,EAAM,IAAO,IAAI,CAStC,SAAgB,EAAO,EAAyB,CAC9C,OAAO,KAAK,MAAM,EAAM,IAAI,CAS9B,SAAgB,EAAW,EAAyC,CAClE,MAAO,CAAC,EAAQ,EAAI,CAAE,EAAS,EAAI,CAAE,EAAO,EAAI,CAAC,CAanD,SAAgB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,EAAE,CAU1C,SAAgB,EAAc,EAAe,EAA0B,CACrE,IAAM,EAAO,EAAQ,EAAI,CAAG,EACtB,EAAQ,EAAS,EAAI,CACrB,EAAa,EAAO,EAAI,CACxB,EAAS,EAAe,EAAM,EAAM,CAC1C,OAAO,EAAa,EAAM,EAAO,KAAK,IAAI,EAAY,EAAO,CAAC,CAIhE,SAAgB,EAAe,EAAc,EAAuB,CAClE,OAAO,IAAI,KAAK,KAAK,IAAI,EAAM,EAAO,EAAE,CAAC,CAAC,YAAY,CAUxD,SAAgB,EAAU,EAAe,EAA0B,CAGjE,OAAO,EAAiB,EAAe,EAAI,CAAG,EAASA,EAAAA,YAAY,CAMrE,SAAgB,EAAQ,EAAgB,EAAyB,CAC/D,OAAO,KAAK,OAAO,EAAe,EAAM,CAAG,EAAe,EAAK,EAAIA,EAAAA,YAAY,CASjF,SAAgB,EAAS,EAAgB,EAA4B,CACnE,IAAM,EAAiB,EAAE,CAQzB,IANA,AACE,IAAQ,GAAc,CAEpB,EAAO,IACT,EAAO,EAAU,EAAO,EAAO,EAAE,EAE5B,GAAQ,GACb,EAAK,KAAK,EAAK,CACf,EAAO,EAAU,EAAM,EAAG,CAE5B,OAAO,EAQT,SAAiB,EAAY,EAAgB,EAAkB,CAC7D,IAAM,EAAiB,EAAE,CAQzB,IANA,AACE,IAAQ,GAAc,CAEpB,EAAO,IACT,EAAO,EAAU,EAAO,EAAO,EAAE,EAE5B,GAAQ,GACb,MAAM,EACN,EAAO,EAAU,EAAM,EAAG,CAE5B,OAAO"}
1
+ {"version":3,"file":"day.cjs","names":["TIME_DAY_MS"],"sources":["../../../src/common/data/day.ts"],"sourcesContent":["import { TIME_DAY_MS } from \"../time\"\n\n// Functionality variant\nlet testModeDay: number | undefined\n\n/**\n * Enable test mode for date functions by forcing \"today\" to a fixed day value.\n *\n * Use a numeric DayValue like 20000101 (YYYYMMDD). This is intended for tests\n * to make date-based logic deterministic. Call with no args to reset.\n *\n * @param ts - day to use as \"today\" in YYYYMMDD format (default: 20000101)\n */\nexport function setDayTest(ts = 20000101) {\n testModeDay = ts\n}\n\n/** \n * @deprecated use TIME_DAY_MS\n * Number of milliseconds in one calendar day (24 * 60 * 60 * 1000). */\nexport const DAY_MS = TIME_DAY_MS // 1000 * 60 * 60 * 24\n\n/** DayValue is a numeric date encoded as YYYYMMDD (for example 20250907). */\nexport type DayValue = number\n\n/**\n * Accepted inputs for day conversion helpers.\n * - DayValue or number: a YYYYMMDD numeric value\n * - string: a date string (parsed by digits)\n * - Date: JavaScript Date\n * - [year, month?, day?]: numeric parts\n */\nexport type DayInput =\n | DayValue\n | number\n | string\n | Date\n | [number, number?, number?]\n\n/**\n * Extract the year (YYYY) from a DayValue.\n *\n * @param day - day as YYYYMMDD\n * @returns year as number (e.g. 2025)\n */\nexport function dayYear(day: DayValue): DayValue {\n return Math.floor(day / 10000)\n}\n\n/**\n * Extract the month (1-12) from a DayValue.\n *\n * @param day - day as YYYYMMDD\n * @returns month number (1-12)\n */\nexport function dayMonth(day: DayValue): DayValue {\n return Math.floor((day / 100) % 100)\n}\n\n/**\n * Extract the day of month (1-31) from a DayValue.\n *\n * @param day - day as YYYYMMDD\n * @returns day of month (1-31)\n */\nexport function dayDay(day: DayValue): DayValue {\n return Math.floor(day % 100)\n}\n\n/**\n * Split a DayValue into [year, month, day].\n *\n * @param day - day as YYYYMMDD\n * @returns tuple [year, month, day]\n */\nexport function dayToParts(day: DayValue): [number, number, number] {\n return [dayYear(day), dayMonth(day), dayDay(day)]\n}\n\n/**\n * Convert a DayValue to a JavaScript Date.\n *\n * By default returns a local Date at midnight for the day. If `utc` is true\n * the returned Date represents midnight UTC for that day.\n *\n * @param day - day as YYYYMMDD\n * @param utc - whether to construct the Date in UTC (default: false)\n * @returns Date object for the given day\n */\nexport function dayToDate(day: DayValue, utc = false): Date {\n return utc\n ? new Date(`${dayToString(day)}T00:00:00.000Z`)\n : new Date(\n day / 10000, // year\n Math.max(0, ((day / 100) % 100) - 1), // month\n Math.max(1, day % 100), // day\n )\n}\n\n/**\n * Return today's day as a DayValue (YYYYMMDD).\n *\n * If test mode has been enabled via `setDayTest` this returns the forced\n * value instead. Otherwise it uses the current local date.\n */\nexport function dayFromToday(): DayValue {\n return testModeDay ?? dayFromDate(new Date())\n}\n\n/**\n * Convert multiple input types to a DayValue (YYYYMMDD).\n *\n * Supports numbers (DayValue), strings, Date objects and [year, month?, day?]\n * tuples. Returns undefined for invalid or unsupported values.\n *\n * @param value - input to convert\n * @param utc - when converting from Date, interpret as UTC if true\n */\nexport function dayFromAny(\n value: DayInput,\n utc = false,\n): DayValue | undefined {\n if (typeof value === 'number') {\n if (value < 100)\n return\n return value\n }\n else if (typeof value === 'string') {\n return dayFromString(value)\n }\n else if (Array.isArray(value) && value.length >= 1) {\n return dayFromParts(...value)\n }\n else if (value instanceof Date) {\n return dayFromDate(value, utc)\n // } else if (value instanceof Day) {\n // return value.days\n }\n}\n\n/** Convert a DayValue to a Date at midnight UTC. */\nexport function dayToDateUTC(day: DayValue): Date {\n return dayToDate(day, true)\n}\n\n/**\n * @deprecated use dayToDateUTC\n *\n * Kept for backwards compatibility; returns a Date for midnight UTC.\n */\nexport function dayToDateGMT(day: DayValue): Date {\n return dayToDate(day, true)\n}\n\n/**\n * Convert a JavaScript Date to a DayValue (YYYYMMDD).\n *\n * If `utc` is true the function uses the ISO string representation to\n * calculate the day in UTC. Otherwise it uses local date components.\n */\nexport function dayFromDate(date: Date, utc = false): DayValue {\n return (\n utc\n ? dayFromString(date.toISOString())\n : date.getFullYear() * 10000\n + (date.getMonth() + 1) * 100\n + date.getDate()\n )!\n}\n\n/** Convert a Date to DayValue using UTC. */\nexport function dayFromDateUTC(date: Date): DayValue {\n return dayFromDate(date, true)\n}\n\n/** @deprecated use dayFromDateUTC */\n/**\n * Deprecated: use `dayFromDateUTC`.\n *\n * Kept for backwards compatibility; converts a Date to a UTC DayValue.\n */\nexport function dayFromDateGMT(date: Date): DayValue {\n return dayFromDate(date, true)\n}\n\n\n/**\n * Convert a DayValue to a UNIX timestamp in seconds. Returns seconds since\n * epoch for midnight of the given day. Defaults to UTC.\n */\nexport function dayToTimestampSeconds(day: DayValue, utc = true): number {\n return Math.floor(dayToDate(day, utc).getTime() / 1000)\n}\n\n/**\n * Convert a DayValue to a timestamp in milliseconds for midnight of that day.\n * Defaults to UTC when constructing the Date.\n */\nexport function dayToTimestamp(day: DayValue, utc = true): number {\n return dayToDate(day, utc).getTime()\n}\n\n/**\n * Convert a timestamp in milliseconds to a DayValue. The timestamp is turned\n * into a Date and then converted; `utc` controls interpretation.\n */\nexport function dayFromTimestamp(ms: number, utc = true): DayValue {\n return dayFromDate(new Date(ms), utc)\n}\n\n/**\n * Convert a UNIX timestamp in seconds to a DayValue.\n *\n * @param ms - seconds since epoch\n */\nexport function dayFromTimestampSeconds(ms: number, utc = true): DayValue {\n return dayFromDate(new Date(Math.floor(ms * 1000)), utc)\n}\n\n/**\n * Format a DayValue as a string with an optional separator.\n *\n * Example: dayToString(20250907) -> \"2025-09-07\"\n */\nexport function dayToString(day: DayValue, sep = '-') {\n const baseString = String(day)\n return (\n baseString.slice(0, 4) + sep\n + baseString.slice(4, 6) + sep\n + baseString.slice(6, 8)\n )\n}\n\n/**\n * Build a DayValue from numeric parts. Returns undefined for invalid parts.\n *\n * @param year - full year (e.g. 2025)\n * @param month - 1-12 (default 1)\n * @param day - 1-31 (default 1)\n */\nexport function dayFromParts(\n year: number,\n month = 1,\n day = 1,\n): DayValue | undefined {\n if (month < 1 || month > 12 || day < 1 || day > 31)\n return\n return year * 10000 + month * 100 + day\n}\n \n/**\n * Parse a string into a DayValue by extracting up to 8 digits (YYYYMMDD).\n * Returns undefined for invalid results.\n * \n * Example:\n * dayValue === dayFromString(String(dayValue))\n */\nexport function dayFromString(value: string): DayValue | undefined {\n const string = String(value)\n .replace(/\\D/g, '')\n .slice(0, 8)\n if (string.length === 8)\n return +string\n}\n\n/**\n * Return the first day of the month for the given DayValue. An optional\n * `offset` (positive or negative) moves the result by months.\n *\n * @param day - source DayValue\n * @param offset - months to offset (default 0)\n */\nexport function dayMonthStart(day: DayValue, offset = 0): DayValue {\n let year = dayYear(day)\n let month = dayMonth(day)\n if (offset !== 0) {\n month += offset\n year += Math.floor((month - 1) / 12)\n month = Math.floor((month - 1) % 12) + 1\n if (month === 0)\n month = 12\n }\n return dayFromParts(year, month, 1)!\n}\n\n/**\n * Return the day offset by whole months, keeping the day-of-month when possible.\n * If the target month has fewer days, the result is clamped to the last day.\n *\n * @param day - source DayValue\n * @param offset - months to offset (positive or negative)\n */\nexport function dayMonthOffset(day: DayValue, offset: number): DayValue {\n let year = dayYear(day)\n let month = dayMonth(day)\n const dayOfMonth = dayDay(day)\n\n if (offset !== 0) {\n month += offset\n year += Math.floor((month - 1) / 12)\n month = Math.floor((month - 1) % 12) + 1\n if (month === 0)\n month = 12\n }\n\n const maxDay = dayDaysInMonth(year, month)\n return dayFromParts(year, month, Math.min(dayOfMonth, maxDay))!\n}\n\n/**\n * Return the first day of the year for the given DayValue. `offset` moves\n * the year by the given amount.\n */\nexport function dayYearStart(day: DayValue, offset = 0): DayValue {\n const year = dayYear(day)\n return dayFromParts(year + offset, 1, 1)!\n}\n\n/**\n * Return the day offset by whole years, keeping month and day when possible.\n * If the target month has fewer days, the result is clamped to the last day.\n *\n * @param day - source DayValue\n * @param offset - years to offset (positive or negative)\n */\nexport function dayYearOffset(day: DayValue, offset: number): DayValue {\n const year = dayYear(day) + offset\n const month = dayMonth(day)\n const dayOfMonth = dayDay(day)\n const maxDay = dayDaysInMonth(year, month)\n return dayFromParts(year, month, Math.min(dayOfMonth, maxDay))!\n}\n\n/** Return number of days in a given month. Month is 1-12. */\nexport function dayDaysInMonth(year: number, month: number): number {\n return new Date(Date.UTC(year, month, 0)).getUTCDate()\n}\n\n/**\n * Offset a DayValue by a number of days. Uses timestamp math to avoid local\n * DST issues.\n *\n * @param day - source DayValue\n * @param offset - days to add (negative to subtract)\n */\nexport function dayOffset(day: DayValue, offset: number): DayValue {\n // Important! Don't use local time here due to summer/winter time days can\n // be longer or shorter!\n return dayFromTimestamp(dayToTimestamp(day) + offset * TIME_DAY_MS)\n}\n\n/**\n * Compute the difference in whole days between two DayValues (right - left).\n */\nexport function dayDiff(left: DayValue, right: DayValue): number {\n return Math.round((dayToTimestamp(right) - dayToTimestamp(left)) / TIME_DAY_MS)\n}\n\n/**\n * Return an array of DayValues from left to right (inclusive).\n *\n * If `right` is omitted it defaults to today. If `left` is negative it is\n * interpreted as an offset relative to `right` (e.g. -7 means the last 7 days).\n */\nexport function dayRange(left: DayValue, right?: DayValue): number[] {\n const list: number[] = []\n\n if (right == null)\n right = dayFromToday()\n\n if (left < 0)\n left = dayOffset(right, left + 1)\n\n while (left <= right) {\n list.push(left)\n left = dayOffset(left, +1)\n }\n return list\n}\n\n/** Iterator, see dayRange */\n/**\n * Generator that yields DayValues from left to right (inclusive). Same rules\n * as `dayRange` regarding defaults and negative left values.\n */\nexport function* dayIterator(left: DayValue, right?: DayValue) {\n const list: number[] = []\n\n if (right == null)\n right = dayFromToday()\n\n if (left < 0)\n left = dayOffset(right, left + 1)\n\n while (left <= right) {\n yield left\n left = dayOffset(left, +1)\n }\n return list\n}\n\n"],"mappings":";;;;AAGA,IAAI;;;;;;;;;AAUJ,SAAgB,WAAW,KAAK,UAAU;AACxC,eAAc;;;;;AAMhB,MAAa,SAASA;;;;;;;AAyBtB,SAAgB,QAAQ,KAAyB;AAC/C,QAAO,KAAK,MAAM,MAAM,IAAM;;;;;;;;AAShC,SAAgB,SAAS,KAAyB;AAChD,QAAO,KAAK,MAAO,MAAM,MAAO,IAAI;;;;;;;;AAStC,SAAgB,OAAO,KAAyB;AAC9C,QAAO,KAAK,MAAM,MAAM,IAAI;;;;;;;;AAS9B,SAAgB,WAAW,KAAyC;AAClE,QAAO;EAAC,QAAQ,IAAI;EAAE,SAAS,IAAI;EAAE,OAAO,IAAI;EAAC;;;;;;;;;;;;AAanD,SAAgB,UAAU,KAAe,MAAM,OAA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M,EAAG;;AAE5B,QAAO"}
@@ -1,2 +1,306 @@
1
- import{TIME_DAY_MS as e}from"../time.mjs";let t;function n(e=20000101){t=e}const r=e;function i(e){return Math.floor(e/1e4)}function a(e){return Math.floor(e/100%100)}function o(e){return Math.floor(e%100)}function s(e){return[i(e),a(e),o(e)]}function c(e,t=!1){return t?new Date(`${b(e)}T00:00:00.000Z`):new Date(e/1e4,Math.max(0,e/100%100-1),Math.max(1,e%100))}function l(){return t??p(new Date)}function u(e,t=!1){if(typeof e==`number`)return e<100?void 0:e;if(typeof e==`string`)return S(e);if(Array.isArray(e)&&e.length>=1)return x(...e);if(e instanceof Date)return p(e,t)}function d(e){return c(e,!0)}function f(e){return c(e,!0)}function p(e,t=!1){return t?S(e.toISOString()):e.getFullYear()*1e4+(e.getMonth()+1)*100+e.getDate()}function m(e){return p(e,!0)}function h(e){return p(e,!0)}function g(e,t=!0){return Math.floor(c(e,t).getTime()/1e3)}function _(e,t=!0){return c(e,t).getTime()}function v(e,t=!0){return p(new Date(e),t)}function y(e,t=!0){return p(new Date(Math.floor(e*1e3)),t)}function b(e,t=`-`){let n=String(e);return n.slice(0,4)+t+n.slice(4,6)+t+n.slice(6,8)}function x(e,t=1,n=1){if(!(t<1||t>12||n<1||n>31))return e*1e4+t*100+n}function S(e){let t=String(e).replace(/\D/g,``).slice(0,8);if(t.length===8)return+t}function C(e,t=0){let n=i(e),r=a(e);return t!==0&&(r+=t,n+=Math.floor((r-1)/12),r=Math.floor((r-1)%12)+1,r===0&&(r=12)),x(n,r,1)}function w(e,t){let n=i(e),r=a(e),s=o(e);t!==0&&(r+=t,n+=Math.floor((r-1)/12),r=Math.floor((r-1)%12)+1,r===0&&(r=12));let c=D(n,r);return x(n,r,Math.min(s,c))}function T(e,t=0){return x(i(e)+t,1,1)}function E(e,t){let n=i(e)+t,r=a(e),s=o(e),c=D(n,r);return x(n,r,Math.min(s,c))}function D(e,t){return new Date(Date.UTC(e,t,0)).getUTCDate()}function O(t,n){return v(_(t)+n*e)}function k(t,n){return Math.round((_(n)-_(t))/e)}function A(e,t){let n=[];for(t??=l(),e<0&&(e=O(t,e+1));e<=t;)n.push(e),e=O(e,1);return n}function*j(e,t){let n=[];for(t??=l(),e<0&&(e=O(t,e+1));e<=t;)yield e,e=O(e,1);return n}export{r as DAY_MS,o as dayDay,D as dayDaysInMonth,k as dayDiff,u as dayFromAny,p as dayFromDate,h as dayFromDateGMT,m as dayFromDateUTC,x as dayFromParts,S as dayFromString,v as dayFromTimestamp,y as dayFromTimestampSeconds,l as dayFromToday,j as dayIterator,a as dayMonth,w as dayMonthOffset,C as dayMonthStart,O as dayOffset,A as dayRange,c as dayToDate,f as dayToDateGMT,d as dayToDateUTC,s as dayToParts,b as dayToString,_ as dayToTimestamp,g as dayToTimestampSeconds,i as dayYear,E as dayYearOffset,T as dayYearStart,n as setDayTest};
1
+ import { TIME_DAY_MS } from "../time.mjs";
2
+
3
+ //#region src/common/data/day.ts
4
+ let testModeDay;
5
+ /**
6
+ * Enable test mode for date functions by forcing "today" to a fixed day value.
7
+ *
8
+ * Use a numeric DayValue like 20000101 (YYYYMMDD). This is intended for tests
9
+ * to make date-based logic deterministic. Call with no args to reset.
10
+ *
11
+ * @param ts - day to use as "today" in YYYYMMDD format (default: 20000101)
12
+ */
13
+ function setDayTest(ts = 20000101) {
14
+ testModeDay = ts;
15
+ }
16
+ /**
17
+ * @deprecated use TIME_DAY_MS
18
+ * Number of milliseconds in one calendar day (24 * 60 * 60 * 1000). */
19
+ const DAY_MS = TIME_DAY_MS;
20
+ /**
21
+ * Extract the year (YYYY) from a DayValue.
22
+ *
23
+ * @param day - day as YYYYMMDD
24
+ * @returns year as number (e.g. 2025)
25
+ */
26
+ function dayYear(day) {
27
+ return Math.floor(day / 1e4);
28
+ }
29
+ /**
30
+ * Extract the month (1-12) from a DayValue.
31
+ *
32
+ * @param day - day as YYYYMMDD
33
+ * @returns month number (1-12)
34
+ */
35
+ function dayMonth(day) {
36
+ return Math.floor(day / 100 % 100);
37
+ }
38
+ /**
39
+ * Extract the day of month (1-31) from a DayValue.
40
+ *
41
+ * @param day - day as YYYYMMDD
42
+ * @returns day of month (1-31)
43
+ */
44
+ function dayDay(day) {
45
+ return Math.floor(day % 100);
46
+ }
47
+ /**
48
+ * Split a DayValue into [year, month, day].
49
+ *
50
+ * @param day - day as YYYYMMDD
51
+ * @returns tuple [year, month, day]
52
+ */
53
+ function dayToParts(day) {
54
+ return [
55
+ dayYear(day),
56
+ dayMonth(day),
57
+ dayDay(day)
58
+ ];
59
+ }
60
+ /**
61
+ * Convert a DayValue to a JavaScript Date.
62
+ *
63
+ * By default returns a local Date at midnight for the day. If `utc` is true
64
+ * the returned Date represents midnight UTC for that day.
65
+ *
66
+ * @param day - day as YYYYMMDD
67
+ * @param utc - whether to construct the Date in UTC (default: false)
68
+ * @returns Date object for the given day
69
+ */
70
+ function dayToDate(day, utc = false) {
71
+ return utc ? /* @__PURE__ */ new Date(`${dayToString(day)}T00:00:00.000Z`) : new Date(day / 1e4, Math.max(0, day / 100 % 100 - 1), Math.max(1, day % 100));
72
+ }
73
+ /**
74
+ * Return today's day as a DayValue (YYYYMMDD).
75
+ *
76
+ * If test mode has been enabled via `setDayTest` this returns the forced
77
+ * value instead. Otherwise it uses the current local date.
78
+ */
79
+ function dayFromToday() {
80
+ return testModeDay ?? dayFromDate(/* @__PURE__ */ new Date());
81
+ }
82
+ /**
83
+ * Convert multiple input types to a DayValue (YYYYMMDD).
84
+ *
85
+ * Supports numbers (DayValue), strings, Date objects and [year, month?, day?]
86
+ * tuples. Returns undefined for invalid or unsupported values.
87
+ *
88
+ * @param value - input to convert
89
+ * @param utc - when converting from Date, interpret as UTC if true
90
+ */
91
+ function dayFromAny(value, utc = false) {
92
+ if (typeof value === "number") {
93
+ if (value < 100) return;
94
+ return value;
95
+ } else if (typeof value === "string") return dayFromString(value);
96
+ else if (Array.isArray(value) && value.length >= 1) return dayFromParts(...value);
97
+ else if (value instanceof Date) return dayFromDate(value, utc);
98
+ }
99
+ /** Convert a DayValue to a Date at midnight UTC. */
100
+ function dayToDateUTC(day) {
101
+ return dayToDate(day, true);
102
+ }
103
+ /**
104
+ * @deprecated use dayToDateUTC
105
+ *
106
+ * Kept for backwards compatibility; returns a Date for midnight UTC.
107
+ */
108
+ function dayToDateGMT(day) {
109
+ return dayToDate(day, true);
110
+ }
111
+ /**
112
+ * Convert a JavaScript Date to a DayValue (YYYYMMDD).
113
+ *
114
+ * If `utc` is true the function uses the ISO string representation to
115
+ * calculate the day in UTC. Otherwise it uses local date components.
116
+ */
117
+ function dayFromDate(date, utc = false) {
118
+ return utc ? dayFromString(date.toISOString()) : date.getFullYear() * 1e4 + (date.getMonth() + 1) * 100 + date.getDate();
119
+ }
120
+ /** Convert a Date to DayValue using UTC. */
121
+ function dayFromDateUTC(date) {
122
+ return dayFromDate(date, true);
123
+ }
124
+ /** @deprecated use dayFromDateUTC */
125
+ /**
126
+ * Deprecated: use `dayFromDateUTC`.
127
+ *
128
+ * Kept for backwards compatibility; converts a Date to a UTC DayValue.
129
+ */
130
+ function dayFromDateGMT(date) {
131
+ return dayFromDate(date, true);
132
+ }
133
+ /**
134
+ * Convert a DayValue to a UNIX timestamp in seconds. Returns seconds since
135
+ * epoch for midnight of the given day. Defaults to UTC.
136
+ */
137
+ function dayToTimestampSeconds(day, utc = true) {
138
+ return Math.floor(dayToDate(day, utc).getTime() / 1e3);
139
+ }
140
+ /**
141
+ * Convert a DayValue to a timestamp in milliseconds for midnight of that day.
142
+ * Defaults to UTC when constructing the Date.
143
+ */
144
+ function dayToTimestamp(day, utc = true) {
145
+ return dayToDate(day, utc).getTime();
146
+ }
147
+ /**
148
+ * Convert a timestamp in milliseconds to a DayValue. The timestamp is turned
149
+ * into a Date and then converted; `utc` controls interpretation.
150
+ */
151
+ function dayFromTimestamp(ms, utc = true) {
152
+ return dayFromDate(new Date(ms), utc);
153
+ }
154
+ /**
155
+ * Convert a UNIX timestamp in seconds to a DayValue.
156
+ *
157
+ * @param ms - seconds since epoch
158
+ */
159
+ function dayFromTimestampSeconds(ms, utc = true) {
160
+ return dayFromDate(new Date(Math.floor(ms * 1e3)), utc);
161
+ }
162
+ /**
163
+ * Format a DayValue as a string with an optional separator.
164
+ *
165
+ * Example: dayToString(20250907) -> "2025-09-07"
166
+ */
167
+ function dayToString(day, sep = "-") {
168
+ const baseString = String(day);
169
+ return baseString.slice(0, 4) + sep + baseString.slice(4, 6) + sep + baseString.slice(6, 8);
170
+ }
171
+ /**
172
+ * Build a DayValue from numeric parts. Returns undefined for invalid parts.
173
+ *
174
+ * @param year - full year (e.g. 2025)
175
+ * @param month - 1-12 (default 1)
176
+ * @param day - 1-31 (default 1)
177
+ */
178
+ function dayFromParts(year, month = 1, day = 1) {
179
+ if (month < 1 || month > 12 || day < 1 || day > 31) return;
180
+ return year * 1e4 + month * 100 + day;
181
+ }
182
+ /**
183
+ * Parse a string into a DayValue by extracting up to 8 digits (YYYYMMDD).
184
+ * Returns undefined for invalid results.
185
+ *
186
+ * Example:
187
+ * dayValue === dayFromString(String(dayValue))
188
+ */
189
+ function dayFromString(value) {
190
+ const string = String(value).replace(/\D/g, "").slice(0, 8);
191
+ if (string.length === 8) return +string;
192
+ }
193
+ /**
194
+ * Return the first day of the month for the given DayValue. An optional
195
+ * `offset` (positive or negative) moves the result by months.
196
+ *
197
+ * @param day - source DayValue
198
+ * @param offset - months to offset (default 0)
199
+ */
200
+ function dayMonthStart(day, offset = 0) {
201
+ let year = dayYear(day);
202
+ let month = dayMonth(day);
203
+ if (offset !== 0) {
204
+ month += offset;
205
+ year += Math.floor((month - 1) / 12);
206
+ month = Math.floor((month - 1) % 12) + 1;
207
+ if (month === 0) month = 12;
208
+ }
209
+ return dayFromParts(year, month, 1);
210
+ }
211
+ /**
212
+ * Return the day offset by whole months, keeping the day-of-month when possible.
213
+ * If the target month has fewer days, the result is clamped to the last day.
214
+ *
215
+ * @param day - source DayValue
216
+ * @param offset - months to offset (positive or negative)
217
+ */
218
+ function dayMonthOffset(day, offset) {
219
+ let year = dayYear(day);
220
+ let month = dayMonth(day);
221
+ const dayOfMonth = dayDay(day);
222
+ if (offset !== 0) {
223
+ month += offset;
224
+ year += Math.floor((month - 1) / 12);
225
+ month = Math.floor((month - 1) % 12) + 1;
226
+ if (month === 0) month = 12;
227
+ }
228
+ const maxDay = dayDaysInMonth(year, month);
229
+ return dayFromParts(year, month, Math.min(dayOfMonth, maxDay));
230
+ }
231
+ /**
232
+ * Return the first day of the year for the given DayValue. `offset` moves
233
+ * the year by the given amount.
234
+ */
235
+ function dayYearStart(day, offset = 0) {
236
+ return dayFromParts(dayYear(day) + offset, 1, 1);
237
+ }
238
+ /**
239
+ * Return the day offset by whole years, keeping month and day when possible.
240
+ * If the target month has fewer days, the result is clamped to the last day.
241
+ *
242
+ * @param day - source DayValue
243
+ * @param offset - years to offset (positive or negative)
244
+ */
245
+ function dayYearOffset(day, offset) {
246
+ const year = dayYear(day) + offset;
247
+ const month = dayMonth(day);
248
+ const dayOfMonth = dayDay(day);
249
+ const maxDay = dayDaysInMonth(year, month);
250
+ return dayFromParts(year, month, Math.min(dayOfMonth, maxDay));
251
+ }
252
+ /** Return number of days in a given month. Month is 1-12. */
253
+ function dayDaysInMonth(year, month) {
254
+ return new Date(Date.UTC(year, month, 0)).getUTCDate();
255
+ }
256
+ /**
257
+ * Offset a DayValue by a number of days. Uses timestamp math to avoid local
258
+ * DST issues.
259
+ *
260
+ * @param day - source DayValue
261
+ * @param offset - days to add (negative to subtract)
262
+ */
263
+ function dayOffset(day, offset) {
264
+ return dayFromTimestamp(dayToTimestamp(day) + offset * TIME_DAY_MS);
265
+ }
266
+ /**
267
+ * Compute the difference in whole days between two DayValues (right - left).
268
+ */
269
+ function dayDiff(left, right) {
270
+ return Math.round((dayToTimestamp(right) - dayToTimestamp(left)) / TIME_DAY_MS);
271
+ }
272
+ /**
273
+ * Return an array of DayValues from left to right (inclusive).
274
+ *
275
+ * If `right` is omitted it defaults to today. If `left` is negative it is
276
+ * interpreted as an offset relative to `right` (e.g. -7 means the last 7 days).
277
+ */
278
+ function dayRange(left, right) {
279
+ const list = [];
280
+ if (right == null) right = dayFromToday();
281
+ if (left < 0) left = dayOffset(right, left + 1);
282
+ while (left <= right) {
283
+ list.push(left);
284
+ left = dayOffset(left, 1);
285
+ }
286
+ return list;
287
+ }
288
+ /** Iterator, see dayRange */
289
+ /**
290
+ * Generator that yields DayValues from left to right (inclusive). Same rules
291
+ * as `dayRange` regarding defaults and negative left values.
292
+ */
293
+ function* dayIterator(left, right) {
294
+ const list = [];
295
+ if (right == null) right = dayFromToday();
296
+ if (left < 0) left = dayOffset(right, left + 1);
297
+ while (left <= right) {
298
+ yield left;
299
+ left = dayOffset(left, 1);
300
+ }
301
+ return list;
302
+ }
303
+
304
+ //#endregion
305
+ export { DAY_MS, dayDay, dayDaysInMonth, dayDiff, dayFromAny, dayFromDate, dayFromDateGMT, dayFromDateUTC, dayFromParts, dayFromString, dayFromTimestamp, dayFromTimestampSeconds, dayFromToday, dayIterator, dayMonth, dayMonthOffset, dayMonthStart, dayOffset, dayRange, dayToDate, dayToDateGMT, dayToDateUTC, dayToParts, dayToString, dayToTimestamp, dayToTimestampSeconds, dayYear, dayYearOffset, dayYearStart, setDayTest };
2
306
  //# sourceMappingURL=day.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"day.mjs","names":[],"sources":["../../../src/common/data/day.ts"],"sourcesContent":["import { TIME_DAY_MS } from \"../time\"\n\n// Functionality variant\nlet testModeDay: number | undefined\n\n/**\n * Enable test mode for date functions by forcing \"today\" to a fixed day value.\n *\n * Use a numeric DayValue like 20000101 (YYYYMMDD). This is intended for tests\n * to make date-based logic deterministic. Call with no args to reset.\n *\n * @param ts - day to use as \"today\" in YYYYMMDD format (default: 20000101)\n */\nexport function setDayTest(ts = 20000101) {\n testModeDay = ts\n}\n\n/** \n * @deprecated use TIME_DAY_MS\n * Number of milliseconds in one calendar day (24 * 60 * 60 * 1000). */\nexport const DAY_MS = TIME_DAY_MS // 1000 * 60 * 60 * 24\n\n/** DayValue is a numeric date encoded as YYYYMMDD (for example 20250907). */\nexport type DayValue = number\n\n/**\n * Accepted inputs for day conversion helpers.\n * - DayValue or number: a YYYYMMDD numeric value\n * - string: a date string (parsed by digits)\n * - Date: JavaScript Date\n * - [year, month?, day?]: numeric parts\n */\nexport type DayInput =\n | DayValue\n | number\n | string\n | Date\n | [number, number?, number?]\n\n/**\n * Extract the year (YYYY) from a DayValue.\n *\n * @param day - day as YYYYMMDD\n * @returns year as number (e.g. 2025)\n */\nexport function dayYear(day: DayValue): DayValue {\n return Math.floor(day / 10000)\n}\n\n/**\n * Extract the month (1-12) from a DayValue.\n *\n * @param day - day as YYYYMMDD\n * @returns month number (1-12)\n */\nexport function dayMonth(day: DayValue): DayValue {\n return Math.floor((day / 100) % 100)\n}\n\n/**\n * Extract the day of month (1-31) from a DayValue.\n *\n * @param day - day as YYYYMMDD\n * @returns day of month (1-31)\n */\nexport function dayDay(day: DayValue): DayValue {\n return Math.floor(day % 100)\n}\n\n/**\n * Split a DayValue into [year, month, day].\n *\n * @param day - day as YYYYMMDD\n * @returns tuple [year, month, day]\n */\nexport function dayToParts(day: DayValue): [number, number, number] {\n return [dayYear(day), dayMonth(day), dayDay(day)]\n}\n\n/**\n * Convert a DayValue to a JavaScript Date.\n *\n * By default returns a local Date at midnight for the day. If `utc` is true\n * the returned Date represents midnight UTC for that day.\n *\n * @param day - day as YYYYMMDD\n * @param utc - whether to construct the Date in UTC (default: false)\n * @returns Date object for the given day\n */\nexport function dayToDate(day: DayValue, utc = false): Date {\n return utc\n ? new Date(`${dayToString(day)}T00:00:00.000Z`)\n : new Date(\n day / 10000, // year\n Math.max(0, ((day / 100) % 100) - 1), // month\n Math.max(1, day % 100), // day\n )\n}\n\n/**\n * Return today's day as a DayValue (YYYYMMDD).\n *\n * If test mode has been enabled via `setDayTest` this returns the forced\n * value instead. Otherwise it uses the current local date.\n */\nexport function dayFromToday(): DayValue {\n return testModeDay ?? dayFromDate(new Date())\n}\n\n/**\n * Convert multiple input types to a DayValue (YYYYMMDD).\n *\n * Supports numbers (DayValue), strings, Date objects and [year, month?, day?]\n * tuples. Returns undefined for invalid or unsupported values.\n *\n * @param value - input to convert\n * @param utc - when converting from Date, interpret as UTC if true\n */\nexport function dayFromAny(\n value: DayInput,\n utc = false,\n): DayValue | undefined {\n if (typeof value === 'number') {\n if (value < 100)\n return\n return value\n }\n else if (typeof value === 'string') {\n return dayFromString(value)\n }\n else if (Array.isArray(value) && value.length >= 1) {\n return dayFromParts(...value)\n }\n else if (value instanceof Date) {\n return dayFromDate(value, utc)\n // } else if (value instanceof Day) {\n // return value.days\n }\n}\n\n/** Convert a DayValue to a Date at midnight UTC. */\nexport function dayToDateUTC(day: DayValue): Date {\n return dayToDate(day, true)\n}\n\n/**\n * @deprecated use dayToDateUTC\n *\n * Kept for backwards compatibility; returns a Date for midnight UTC.\n */\nexport function dayToDateGMT(day: DayValue): Date {\n return dayToDate(day, true)\n}\n\n/**\n * Convert a JavaScript Date to a DayValue (YYYYMMDD).\n *\n * If `utc` is true the function uses the ISO string representation to\n * calculate the day in UTC. Otherwise it uses local date components.\n */\nexport function dayFromDate(date: Date, utc = false): DayValue {\n return (\n utc\n ? dayFromString(date.toISOString())\n : date.getFullYear() * 10000\n + (date.getMonth() + 1) * 100\n + date.getDate()\n )!\n}\n\n/** Convert a Date to DayValue using UTC. */\nexport function dayFromDateUTC(date: Date): DayValue {\n return dayFromDate(date, true)\n}\n\n/** @deprecated use dayFromDateUTC */\n/**\n * Deprecated: use `dayFromDateUTC`.\n *\n * Kept for backwards compatibility; converts a Date to a UTC DayValue.\n */\nexport function dayFromDateGMT(date: Date): DayValue {\n return dayFromDate(date, true)\n}\n\n\n/**\n * Convert a DayValue to a UNIX timestamp in seconds. Returns seconds since\n * epoch for midnight of the given day. Defaults to UTC.\n */\nexport function dayToTimestampSeconds(day: DayValue, utc = true): number {\n return Math.floor(dayToDate(day, utc).getTime() / 1000)\n}\n\n/**\n * Convert a DayValue to a timestamp in milliseconds for midnight of that day.\n * Defaults to UTC when constructing the Date.\n */\nexport function dayToTimestamp(day: DayValue, utc = true): number {\n return dayToDate(day, utc).getTime()\n}\n\n/**\n * Convert a timestamp in milliseconds to a DayValue. The timestamp is turned\n * into a Date and then converted; `utc` controls interpretation.\n */\nexport function dayFromTimestamp(ms: number, utc = true): DayValue {\n return dayFromDate(new Date(ms), utc)\n}\n\n/**\n * Convert a UNIX timestamp in seconds to a DayValue.\n *\n * @param ms - seconds since epoch\n */\nexport function dayFromTimestampSeconds(ms: number, utc = true): DayValue {\n return dayFromDate(new Date(Math.floor(ms * 1000)), utc)\n}\n\n/**\n * Format a DayValue as a string with an optional separator.\n *\n * Example: dayToString(20250907) -> \"2025-09-07\"\n */\nexport function dayToString(day: DayValue, sep = '-') {\n const baseString = String(day)\n return (\n baseString.slice(0, 4) + sep\n + baseString.slice(4, 6) + sep\n + baseString.slice(6, 8)\n )\n}\n\n/**\n * Build a DayValue from numeric parts. Returns undefined for invalid parts.\n *\n * @param year - full year (e.g. 2025)\n * @param month - 1-12 (default 1)\n * @param day - 1-31 (default 1)\n */\nexport function dayFromParts(\n year: number,\n month = 1,\n day = 1,\n): DayValue | undefined {\n if (month < 1 || month > 12 || day < 1 || day > 31)\n return\n return year * 10000 + month * 100 + day\n}\n \n/**\n * Parse a string into a DayValue by extracting up to 8 digits (YYYYMMDD).\n * Returns undefined for invalid results.\n * \n * Example:\n * dayValue === dayFromString(String(dayValue))\n */\nexport function dayFromString(value: string): DayValue | undefined {\n const string = String(value)\n .replace(/\\D/g, '')\n .slice(0, 8)\n if (string.length === 8)\n return +string\n}\n\n/**\n * Return the first day of the month for the given DayValue. An optional\n * `offset` (positive or negative) moves the result by months.\n *\n * @param day - source DayValue\n * @param offset - months to offset (default 0)\n */\nexport function dayMonthStart(day: DayValue, offset = 0): DayValue {\n let year = dayYear(day)\n let month = dayMonth(day)\n if (offset !== 0) {\n month += offset\n year += Math.floor((month - 1) / 12)\n month = Math.floor((month - 1) % 12) + 1\n if (month === 0)\n month = 12\n }\n return dayFromParts(year, month, 1)!\n}\n\n/**\n * Return the day offset by whole months, keeping the day-of-month when possible.\n * If the target month has fewer days, the result is clamped to the last day.\n *\n * @param day - source DayValue\n * @param offset - months to offset (positive or negative)\n */\nexport function dayMonthOffset(day: DayValue, offset: number): DayValue {\n let year = dayYear(day)\n let month = dayMonth(day)\n const dayOfMonth = dayDay(day)\n\n if (offset !== 0) {\n month += offset\n year += Math.floor((month - 1) / 12)\n month = Math.floor((month - 1) % 12) + 1\n if (month === 0)\n month = 12\n }\n\n const maxDay = dayDaysInMonth(year, month)\n return dayFromParts(year, month, Math.min(dayOfMonth, maxDay))!\n}\n\n/**\n * Return the first day of the year for the given DayValue. `offset` moves\n * the year by the given amount.\n */\nexport function dayYearStart(day: DayValue, offset = 0): DayValue {\n const year = dayYear(day)\n return dayFromParts(year + offset, 1, 1)!\n}\n\n/**\n * Return the day offset by whole years, keeping month and day when possible.\n * If the target month has fewer days, the result is clamped to the last day.\n *\n * @param day - source DayValue\n * @param offset - years to offset (positive or negative)\n */\nexport function dayYearOffset(day: DayValue, offset: number): DayValue {\n const year = dayYear(day) + offset\n const month = dayMonth(day)\n const dayOfMonth = dayDay(day)\n const maxDay = dayDaysInMonth(year, month)\n return dayFromParts(year, month, Math.min(dayOfMonth, maxDay))!\n}\n\n/** Return number of days in a given month. Month is 1-12. */\nexport function dayDaysInMonth(year: number, month: number): number {\n return new Date(Date.UTC(year, month, 0)).getUTCDate()\n}\n\n/**\n * Offset a DayValue by a number of days. Uses timestamp math to avoid local\n * DST issues.\n *\n * @param day - source DayValue\n * @param offset - days to add (negative to subtract)\n */\nexport function dayOffset(day: DayValue, offset: number): DayValue {\n // Important! Don't use local time here due to summer/winter time days can\n // be longer or shorter!\n return dayFromTimestamp(dayToTimestamp(day) + offset * TIME_DAY_MS)\n}\n\n/**\n * Compute the difference in whole days between two DayValues (right - left).\n */\nexport function dayDiff(left: DayValue, right: DayValue): number {\n return Math.round((dayToTimestamp(right) - dayToTimestamp(left)) / TIME_DAY_MS)\n}\n\n/**\n * Return an array of DayValues from left to right (inclusive).\n *\n * If `right` is omitted it defaults to today. If `left` is negative it is\n * interpreted as an offset relative to `right` (e.g. -7 means the last 7 days).\n */\nexport function dayRange(left: DayValue, right?: DayValue): number[] {\n const list: number[] = []\n\n if (right == null)\n right = dayFromToday()\n\n if (left < 0)\n left = dayOffset(right, left + 1)\n\n while (left <= right) {\n list.push(left)\n left = dayOffset(left, +1)\n }\n return list\n}\n\n/** Iterator, see dayRange */\n/**\n * Generator that yields DayValues from left to right (inclusive). Same rules\n * as `dayRange` regarding defaults and negative left values.\n */\nexport function* dayIterator(left: DayValue, right?: DayValue) {\n const list: number[] = []\n\n if (right == null)\n right = dayFromToday()\n\n if (left < 0)\n left = dayOffset(right, left + 1)\n\n while (left <= right) {\n yield left\n left = dayOffset(left, +1)\n }\n return list\n}\n\n"],"mappings":"0CAGA,IAAI,EAUJ,SAAgB,EAAW,EAAK,SAAU,CACxC,EAAc,EAMhB,MAAa,EAAS,EAyBtB,SAAgB,EAAQ,EAAyB,CAC/C,OAAO,KAAK,MAAM,EAAM,IAAM,CAShC,SAAgB,EAAS,EAAyB,CAChD,OAAO,KAAK,MAAO,EAAM,IAAO,IAAI,CAStC,SAAgB,EAAO,EAAyB,CAC9C,OAAO,KAAK,MAAM,EAAM,IAAI,CAS9B,SAAgB,EAAW,EAAyC,CAClE,MAAO,CAAC,EAAQ,EAAI,CAAE,EAAS,EAAI,CAAE,EAAO,EAAI,CAAC,CAanD,SAAgB,EAAU,EAAe,EAAM,GAAa,CAC1D,OAAO,EACH,IAAI,KAAK,GAAG,EAAY,EAAI,CAAC,gBAAgB,CAC7C,IAAI,KACJ,EAAM,IACN,KAAK,IAAI,EAAK,EAAM,IAAO,IAAO,EAAE,CACpC,KAAK,IAAI,EAAG,EAAM,IAAI,CACvB,CASL,SAAgB,GAAyB,CACvC,OAAO,G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AAe,EAAc,EAAuB,CAClE,OAAO,IAAI,KAAK,KAAK,IAAI,EAAM,EAAO,EAAE,CAAC,CAAC,YAAY,CAUxD,SAAgB,EAAU,EAAe,EAA0B,CAGjE,OAAO,EAAiB,EAAe,EAAI,CAAG,EAAS,EAAY,CAMrE,SAAgB,EAAQ,EAAgB,EAAyB,CAC/D,OAAO,KAAK,OAAO,EAAe,EAAM,CAAG,EAAe,EAAK,EAAI,EAAY,CASjF,SAAgB,EAAS,EAAgB,EAA4B,CACnE,IAAM,EAAiB,EAAE,CAQzB,IANA,AACE,IAAQ,GAAc,CAEpB,EAAO,IACT,EAAO,EAAU,EAAO,EAAO,EAAE,EAE5B,GAAQ,GACb,EAAK,KAAK,EAAK,CACf,EAAO,EAAU,EAAM,EAAG,CAE5B,OAAO,EAQT,SAAiB,EAAY,EAAgB,EAAkB,CAC7D,IAAM,EAAiB,EAAE,CAQzB,IANA,AACE,IAAQ,GAAc,CAEpB,EAAO,IACT,EAAO,EAAU,EAAO,EAAO,EAAE,EAE5B,GAAQ,GACb,MAAM,EACN,EAAO,EAAU,EAAM,EAAG,CAE5B,OAAO"}
1
+ {"version":3,"file":"day.mjs","names":[],"sources":["../../../src/common/data/day.ts"],"sourcesContent":["import { TIME_DAY_MS } from \"../time\"\n\n// Functionality variant\nlet testModeDay: number | undefined\n\n/**\n * Enable test mode for date functions by forcing \"today\" to a fixed day value.\n *\n * Use a numeric DayValue like 20000101 (YYYYMMDD). This is intended for tests\n * to make date-based logic deterministic. Call with no args to reset.\n *\n * @param ts - day to use as \"today\" in YYYYMMDD format (default: 20000101)\n */\nexport function setDayTest(ts = 20000101) {\n testModeDay = ts\n}\n\n/** \n * @deprecated use TIME_DAY_MS\n * Number of milliseconds in one calendar day (24 * 60 * 60 * 1000). */\nexport const DAY_MS = TIME_DAY_MS // 1000 * 60 * 60 * 24\n\n/** DayValue is a numeric date encoded as YYYYMMDD (for example 20250907). */\nexport type DayValue = number\n\n/**\n * Accepted inputs for day conversion helpers.\n * - DayValue or number: a YYYYMMDD numeric value\n * - string: a date string (parsed by digits)\n * - Date: JavaScript Date\n * - [year, month?, day?]: numeric parts\n */\nexport type DayInput =\n | DayValue\n | number\n | string\n | Date\n | [number, number?, number?]\n\n/**\n * Extract the year (YYYY) from a DayValue.\n *\n * @param day - day as YYYYMMDD\n * @returns year as number (e.g. 2025)\n */\nexport function dayYear(day: DayValue): DayValue {\n return Math.floor(day / 10000)\n}\n\n/**\n * Extract the month (1-12) from a DayValue.\n *\n * @param day - day as YYYYMMDD\n * @returns month number (1-12)\n */\nexport function dayMonth(day: DayValue): DayValue {\n return Math.floor((day / 100) % 100)\n}\n\n/**\n * Extract the day of month (1-31) from a DayValue.\n *\n * @param day - day as YYYYMMDD\n * @returns day of month (1-31)\n */\nexport function dayDay(day: DayValue): DayValue {\n return Math.floor(day % 100)\n}\n\n/**\n * Split a DayValue into [year, month, day].\n *\n * @param day - day as YYYYMMDD\n * @returns tuple [year, month, day]\n */\nexport function dayToParts(day: DayValue): [number, number, number] {\n return [dayYear(day), dayMonth(day), dayDay(day)]\n}\n\n/**\n * Convert a DayValue to a JavaScript Date.\n *\n * By default returns a local Date at midnight for the day. If `utc` is true\n * the returned Date represents midnight UTC for that day.\n *\n * @param day - day as YYYYMMDD\n * @param utc - whether to construct the Date in UTC (default: false)\n * @returns Date object for the given day\n */\nexport function dayToDate(day: DayValue, utc = false): Date {\n return utc\n ? new Date(`${dayToString(day)}T00:00:00.000Z`)\n : new Date(\n day / 10000, // year\n Math.max(0, ((day / 100) % 100) - 1), // month\n Math.max(1, day % 100), // day\n )\n}\n\n/**\n * Return today's day as a DayValue (YYYYMMDD).\n *\n * If test mode has been enabled via `setDayTest` this returns the forced\n * value instead. Otherwise it uses the current local date.\n */\nexport function dayFromToday(): DayValue {\n return testModeDay ?? dayFromDate(new Date())\n}\n\n/**\n * Convert multiple input types to a DayValue (YYYYMMDD).\n *\n * Supports numbers (DayValue), strings, Date objects and [year, month?, day?]\n * tuples. Returns undefined for invalid or unsupported values.\n *\n * @param value - input to convert\n * @param utc - when converting from Date, interpret as UTC if true\n */\nexport function dayFromAny(\n value: DayInput,\n utc = false,\n): DayValue | undefined {\n if (typeof value === 'number') {\n if (value < 100)\n return\n return value\n }\n else if (typeof value === 'string') {\n return dayFromString(value)\n }\n else if (Array.isArray(value) && value.length >= 1) {\n return dayFromParts(...value)\n }\n else if (value instanceof Date) {\n return dayFromDate(value, utc)\n // } else if (value instanceof Day) {\n // return value.days\n }\n}\n\n/** Convert a DayValue to a Date at midnight UTC. */\nexport function dayToDateUTC(day: DayValue): Date {\n return dayToDate(day, true)\n}\n\n/**\n * @deprecated use dayToDateUTC\n *\n * Kept for backwards compatibility; returns a Date for midnight UTC.\n */\nexport function dayToDateGMT(day: DayValue): Date {\n return dayToDate(day, true)\n}\n\n/**\n * Convert a JavaScript Date to a DayValue (YYYYMMDD).\n *\n * If `utc` is true the function uses the ISO string representation to\n * calculate the day in UTC. Otherwise it uses local date components.\n */\nexport function dayFromDate(date: Date, utc = false): DayValue {\n return (\n utc\n ? dayFromString(date.toISOString())\n : date.getFullYear() * 10000\n + (date.getMonth() + 1) * 100\n + date.getDate()\n )!\n}\n\n/** Convert a Date to DayValue using UTC. */\nexport function dayFromDateUTC(date: Date): DayValue {\n return dayFromDate(date, true)\n}\n\n/** @deprecated use dayFromDateUTC */\n/**\n * Deprecated: use `dayFromDateUTC`.\n *\n * Kept for backwards compatibility; converts a Date to a UTC DayValue.\n */\nexport function dayFromDateGMT(date: Date): DayValue {\n return dayFromDate(date, true)\n}\n\n\n/**\n * Convert a DayValue to a UNIX timestamp in seconds. Returns seconds since\n * epoch for midnight of the given day. Defaults to UTC.\n */\nexport function dayToTimestampSeconds(day: DayValue, utc = true): number {\n return Math.floor(dayToDate(day, utc).getTime() / 1000)\n}\n\n/**\n * Convert a DayValue to a timestamp in milliseconds for midnight of that day.\n * Defaults to UTC when constructing the Date.\n */\nexport function dayToTimestamp(day: DayValue, utc = true): number {\n return dayToDate(day, utc).getTime()\n}\n\n/**\n * Convert a timestamp in milliseconds to a DayValue. The timestamp is turned\n * into a Date and then converted; `utc` controls interpretation.\n */\nexport function dayFromTimestamp(ms: number, utc = true): DayValue {\n return dayFromDate(new Date(ms), utc)\n}\n\n/**\n * Convert a UNIX timestamp in seconds to a DayValue.\n *\n * @param ms - seconds since epoch\n */\nexport function dayFromTimestampSeconds(ms: number, utc = true): DayValue {\n return dayFromDate(new Date(Math.floor(ms * 1000)), utc)\n}\n\n/**\n * Format a DayValue as a string with an optional separator.\n *\n * Example: dayToString(20250907) -> \"2025-09-07\"\n */\nexport function dayToString(day: DayValue, sep = '-') {\n const baseString = String(day)\n return (\n baseString.slice(0, 4) + sep\n + baseString.slice(4, 6) + sep\n + baseString.slice(6, 8)\n )\n}\n\n/**\n * Build a DayValue from numeric parts. Returns undefined for invalid parts.\n *\n * @param year - full year (e.g. 2025)\n * @param month - 1-12 (default 1)\n * @param day - 1-31 (default 1)\n */\nexport function dayFromParts(\n year: number,\n month = 1,\n day = 1,\n): DayValue | undefined {\n if (month < 1 || month > 12 || day < 1 || day > 31)\n return\n return year * 10000 + month * 100 + day\n}\n \n/**\n * Parse a string into a DayValue by extracting up to 8 digits (YYYYMMDD).\n * Returns undefined for invalid results.\n * \n * Example:\n * dayValue === dayFromString(String(dayValue))\n */\nexport function dayFromString(value: string): DayValue | undefined {\n const string = String(value)\n .replace(/\\D/g, '')\n .slice(0, 8)\n if (string.length === 8)\n return +string\n}\n\n/**\n * Return the first day of the month for the given DayValue. An optional\n * `offset` (positive or negative) moves the result by months.\n *\n * @param day - source DayValue\n * @param offset - months to offset (default 0)\n */\nexport function dayMonthStart(day: DayValue, offset = 0): DayValue {\n let year = dayYear(day)\n let month = dayMonth(day)\n if (offset !== 0) {\n month += offset\n year += Math.floor((month - 1) / 12)\n month = Math.floor((month - 1) % 12) + 1\n if (month === 0)\n month = 12\n }\n return dayFromParts(year, month, 1)!\n}\n\n/**\n * Return the day offset by whole months, keeping the day-of-month when possible.\n * If the target month has fewer days, the result is clamped to the last day.\n *\n * @param day - source DayValue\n * @param offset - months to offset (positive or negative)\n */\nexport function dayMonthOffset(day: DayValue, offset: number): DayValue {\n let year = dayYear(day)\n let month = dayMonth(day)\n const dayOfMonth = dayDay(day)\n\n if (offset !== 0) {\n month += offset\n year += Math.floor((month - 1) / 12)\n month = Math.floor((month - 1) % 12) + 1\n if (month === 0)\n month = 12\n }\n\n const maxDay = dayDaysInMonth(year, month)\n return dayFromParts(year, month, Math.min(dayOfMonth, maxDay))!\n}\n\n/**\n * Return the first day of the year for the given DayValue. `offset` moves\n * the year by the given amount.\n */\nexport function dayYearStart(day: DayValue, offset = 0): DayValue {\n const year = dayYear(day)\n return dayFromParts(year + offset, 1, 1)!\n}\n\n/**\n * Return the day offset by whole years, keeping month and day when possible.\n * If the target month has fewer days, the result is clamped to the last day.\n *\n * @param day - source DayValue\n * @param offset - years to offset (positive or negative)\n */\nexport function dayYearOffset(day: DayValue, offset: number): DayValue {\n const year = dayYear(day) + offset\n const month = dayMonth(day)\n const dayOfMonth = dayDay(day)\n const maxDay = dayDaysInMonth(year, month)\n return dayFromParts(year, month, Math.min(dayOfMonth, maxDay))!\n}\n\n/** Return number of days in a given month. Month is 1-12. */\nexport function dayDaysInMonth(year: number, month: number): number {\n return new Date(Date.UTC(year, month, 0)).getUTCDate()\n}\n\n/**\n * Offset a DayValue by a number of days. Uses timestamp math to avoid local\n * DST issues.\n *\n * @param day - source DayValue\n * @param offset - days to add (negative to subtract)\n */\nexport function dayOffset(day: DayValue, offset: number): DayValue {\n // Important! Don't use local time here due to summer/winter time days can\n // be longer or shorter!\n return dayFromTimestamp(dayToTimestamp(day) + offset * TIME_DAY_MS)\n}\n\n/**\n * Compute the difference in whole days between two DayValues (right - left).\n */\nexport function dayDiff(left: DayValue, right: DayValue): number {\n return Math.round((dayToTimestamp(right) - dayToTimestamp(left)) / TIME_DAY_MS)\n}\n\n/**\n * Return an array of DayValues from left to right (inclusive).\n *\n * If `right` is omitted it defaults to today. If `left` is negative it is\n * interpreted as an offset relative to `right` (e.g. -7 means the last 7 days).\n */\nexport function dayRange(left: DayValue, right?: DayValue): number[] {\n const list: number[] = []\n\n if (right == null)\n right = dayFromToday()\n\n if (left < 0)\n left = dayOffset(right, left + 1)\n\n while (left <= right) {\n list.push(left)\n left = dayOffset(left, +1)\n }\n return list\n}\n\n/** Iterator, see dayRange */\n/**\n * Generator that yields DayValues from left to right (inclusive). Same rules\n * as `dayRange` regarding defaults and negative left values.\n */\nexport function* dayIterator(left: DayValue, right?: DayValue) {\n const list: number[] = []\n\n if (right == null)\n right = dayFromToday()\n\n if (left < 0)\n left = dayOffset(right, left + 1)\n\n while (left <= right) {\n yield left\n left = dayOffset(left, +1)\n }\n return list\n}\n\n"],"mappings":";;;AAGA,IAAI;;;;;;;;;AAUJ,SAAgB,WAAW,KAAK,UAAU;AACxC,eAAc;;;;;AAMhB,MAAa,SAAS;;;;;;;AAyBtB,SAAgB,QAAQ,KAAyB;AAC/C,QAAO,KAAK,MAAM,MAAM,IAAM;;;;;;;;AAShC,SAAgB,SAAS,KAAyB;AAChD,QAAO,KAAK,MAAO,MAAM,MAAO,IAAI;;;;;;;;AAStC,SAAgB,OAAO,KAAyB;AAC9C,QAAO,KAAK,MAAM,MAAM,IAAI;;;;;;;;AAS9B,SAAgB,WAAW,KAAyC;AAClE,QAAO;EAAC,QAAQ,IAAI;EAAE,SAAS,IAAI;EAAE,OAAO,IAAI;EAAC;;;;;;;;;;;;AAanD,SAAgB,UAAU,KAAe,MAAM,OAAa;AAC1D,QAAO,sBACH,IAAI,KAAK,GAAG,YAAY,IAAI,CAAC,gBAAgB,GAC7C,IAAI,KACJ,MAAM,KACN,KAAK,IAAI,GAAK,MAAM,MAAO,MAAO,EAAE,EACpC,KAAK,IAAI,GAAG,MAAM,IAAI,CACvB;;;;;;;;AASL,SAAgB,eAAyB;AACvC,QAAO,eAAe,4BAAY,IAAI,MAAM,CAAC;;;;;;;;;;;A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O,QAAQ,IAAI,GAAG;CAC5B,MAAM,QAAQ,SAAS,IAAI;CAC3B,MAAM,aAAa,OAAO,IAAI;CAC9B,MAAM,SAAS,eAAe,MAAM,MAAM;AAC1C,QAAO,aAAa,MAAM,OAAO,KAAK,IAAI,YAAY,OAAO,CAAC;;;AAIhE,SAAgB,eAAe,MAAc,OAAuB;AAClE,QAAO,IAAI,KAAK,KAAK,IAAI,MAAM,OAAO,EAAE,CAAC,CAAC,YAAY;;;;;;;;;AAUxD,SAAgB,UAAU,KAAe,QAA0B;AAGjE,QAAO,iBAAiB,eAAe,IAAI,GAAG,SAAS,YAAY;;;;;AAMrE,SAAgB,QAAQ,MAAgB,OAAyB;AAC/D,QAAO,KAAK,OAAO,eAAe,MAAM,GAAG,eAAe,KAAK,IAAI,YAAY;;;;;;;;AASjF,SAAgB,SAAS,MAAgB,OAA4B;CACnE,MAAM,OAAiB,EAAE;AAEzB,KAAI,SAAS,KACX,SAAQ,cAAc;AAExB,KAAI,OAAO,EACT,QAAO,UAAU,OAAO,OAAO,EAAE;AAEnC,QAAO,QAAQ,OAAO;AACpB,OAAK,KAAK,KAAK;AACf,SAAO,UAAU,MAAM,EAAG;;AAE5B,QAAO;;;;;;;AAQT,UAAiB,YAAY,MAAgB,OAAkB;CAC7D,MAAM,OAAiB,EAAE;AAEzB,KAAI,SAAS,KACX,SAAQ,cAAc;AAExB,KAAI,OAAO,EACT,QAAO,UAAU,OAAO,OAAO,EAAE;AAEnC,QAAO,QAAQ,OAAO;AACpB,QAAM;AACN,SAAO,UAAU,MAAM,EAAG;;AAE5B,QAAO"}
@@ -1,2 +1,29 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e,t=2){return+(+e).toFixed(t)}function t(e,t=2){return+(e/10**t).toFixed(t)}function n(e,t=2){return Math.round(e*10**t)}function r(t,n=2){return 10**n*(e(t,n)%1)}exports.decimal=e,exports.decimalCentsPart=r,exports.decimalFromCents=t,exports.decimalToCents=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/common/data/decimal.ts
4
+ /**
5
+ * The float returned is guaraneteed to have only the `decimalPlaces` length,
6
+ * no rounding errors or float arithmetic artefacts.
7
+ */
8
+ function decimal(value, decimalPlaces = 2) {
9
+ return +(+value).toFixed(decimalPlaces);
10
+ }
11
+ /** `123` becomes `1.23` */
12
+ function decimalFromCents(value, decimalPlaces = 2) {
13
+ return +(+value / 10 ** decimalPlaces).toFixed(decimalPlaces);
14
+ }
15
+ /** `1.23` becomes `123` */
16
+ function decimalToCents(value, decimalPlaces = 2) {
17
+ return Math.round(+value * 10 ** decimalPlaces);
18
+ }
19
+ /** `1.23` becomes `23` */
20
+ function decimalCentsPart(value, decimalPlaces = 2) {
21
+ return 10 ** decimalPlaces * (decimal(value, decimalPlaces) % 1);
22
+ }
23
+
24
+ //#endregion
25
+ exports.decimal = decimal;
26
+ exports.decimalCentsPart = decimalCentsPart;
27
+ exports.decimalFromCents = decimalFromCents;
28
+ exports.decimalToCents = decimalToCents;
2
29
  //# sourceMappingURL=decimal.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"decimal.cjs","names":[],"sources":["../../../src/common/data/decimal.ts"],"sourcesContent":["export type DecimalValue = number\nexport type DecimalInput = number | string | DecimalValue\n\n/** \n * The float returned is guaraneteed to have only the `decimalPlaces` length,\n * no rounding errors or float arithmetic artefacts. \n */\nexport function decimal(\n value: DecimalInput,\n decimalPlaces = 2,\n): DecimalValue {\n return +(+value).toFixed(decimalPlaces)\n}\n\n/** `123` becomes `1.23` */\nexport function decimalFromCents(\n value: DecimalInput,\n decimalPlaces = 2,\n): DecimalValue {\n return +(+value / 10 ** decimalPlaces).toFixed(decimalPlaces)\n}\n\n/** `1.23` becomes `123` */\nexport function decimalToCents(\n value: DecimalInput,\n decimalPlaces = 2,\n): number {\n return Math.round(+value * 10 ** decimalPlaces)\n}\n\n/** `1.23` becomes `23` */\nexport function decimalCentsPart(\n value: DecimalInput,\n decimalPlaces = 2,\n): DecimalValue {\n return 10 ** decimalPlaces * (decimal(value, decimalPlaces) % 1)\n}\n"],"mappings":"mEAOA,SAAgB,EACd,EACA,EAAgB,EACF,CACd,MAAO,EAAE,CAAC,GAAO,QAAQ,EAAc,CAIzC,SAAgB,EACd,EACA,EAAgB,EACF,CACd,MAAO,EAAG,EAAQ,IAAM,GAAe,QAAQ,EAAc,CAI/D,SAAgB,EACd,EACA,EAAgB,EACR,CACR,OAAO,KAAK,MAAO,EAAQ,IAAM,EAAc,CAIjD,SAAgB,EACd,EACA,EAAgB,EACF,CACd,MAAO,KAAM,GAAiB,EAAQ,EAAO,EAAc,CAAG"}
1
+ {"version":3,"file":"decimal.cjs","names":[],"sources":["../../../src/common/data/decimal.ts"],"sourcesContent":["export type DecimalValue = number\nexport type DecimalInput = number | string | DecimalValue\n\n/** \n * The float returned is guaraneteed to have only the `decimalPlaces` length,\n * no rounding errors or float arithmetic artefacts. \n */\nexport function decimal(\n value: DecimalInput,\n decimalPlaces = 2,\n): DecimalValue {\n return +(+value).toFixed(decimalPlaces)\n}\n\n/** `123` becomes `1.23` */\nexport function decimalFromCents(\n value: DecimalInput,\n decimalPlaces = 2,\n): DecimalValue {\n return +(+value / 10 ** decimalPlaces).toFixed(decimalPlaces)\n}\n\n/** `1.23` becomes `123` */\nexport function decimalToCents(\n value: DecimalInput,\n decimalPlaces = 2,\n): number {\n return Math.round(+value * 10 ** decimalPlaces)\n}\n\n/** `1.23` becomes `23` */\nexport function decimalCentsPart(\n value: DecimalInput,\n decimalPlaces = 2,\n): DecimalValue {\n return 10 ** decimalPlaces * (decimal(value, decimalPlaces) % 1)\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,QACd,OACA,gBAAgB,GACF;AACd,QAAO,EAAE,CAAC,OAAO,QAAQ,cAAc;;;AAIzC,SAAgB,iBACd,OACA,gBAAgB,GACF;AACd,QAAO,EAAE,CAAC,QAAQ,MAAM,eAAe,QAAQ,cAAc;;;AAI/D,SAAgB,eACd,OACA,gBAAgB,GACR;AACR,QAAO,KAAK,MAAM,CAAC,QAAQ,MAAM,cAAc;;;AAIjD,SAAgB,iBACd,OACA,gBAAgB,GACF;AACd,QAAO,MAAM,iBAAiB,QAAQ,OAAO,cAAc,GAAG"}
@@ -1,2 +1,24 @@
1
- function e(e,t=2){return+(+e).toFixed(t)}function t(e,t=2){return+(e/10**t).toFixed(t)}function n(e,t=2){return Math.round(e*10**t)}function r(t,n=2){return 10**n*(e(t,n)%1)}export{e as decimal,r as decimalCentsPart,t as decimalFromCents,n as decimalToCents};
1
+ //#region src/common/data/decimal.ts
2
+ /**
3
+ * The float returned is guaraneteed to have only the `decimalPlaces` length,
4
+ * no rounding errors or float arithmetic artefacts.
5
+ */
6
+ function decimal(value, decimalPlaces = 2) {
7
+ return +(+value).toFixed(decimalPlaces);
8
+ }
9
+ /** `123` becomes `1.23` */
10
+ function decimalFromCents(value, decimalPlaces = 2) {
11
+ return +(+value / 10 ** decimalPlaces).toFixed(decimalPlaces);
12
+ }
13
+ /** `1.23` becomes `123` */
14
+ function decimalToCents(value, decimalPlaces = 2) {
15
+ return Math.round(+value * 10 ** decimalPlaces);
16
+ }
17
+ /** `1.23` becomes `23` */
18
+ function decimalCentsPart(value, decimalPlaces = 2) {
19
+ return 10 ** decimalPlaces * (decimal(value, decimalPlaces) % 1);
20
+ }
21
+
22
+ //#endregion
23
+ export { decimal, decimalCentsPart, decimalFromCents, decimalToCents };
2
24
  //# sourceMappingURL=decimal.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"decimal.mjs","names":[],"sources":["../../../src/common/data/decimal.ts"],"sourcesContent":["export type DecimalValue = number\nexport type DecimalInput = number | string | DecimalValue\n\n/** \n * The float returned is guaraneteed to have only the `decimalPlaces` length,\n * no rounding errors or float arithmetic artefacts. \n */\nexport function decimal(\n value: DecimalInput,\n decimalPlaces = 2,\n): DecimalValue {\n return +(+value).toFixed(decimalPlaces)\n}\n\n/** `123` becomes `1.23` */\nexport function decimalFromCents(\n value: DecimalInput,\n decimalPlaces = 2,\n): DecimalValue {\n return +(+value / 10 ** decimalPlaces).toFixed(decimalPlaces)\n}\n\n/** `1.23` becomes `123` */\nexport function decimalToCents(\n value: DecimalInput,\n decimalPlaces = 2,\n): number {\n return Math.round(+value * 10 ** decimalPlaces)\n}\n\n/** `1.23` becomes `23` */\nexport function decimalCentsPart(\n value: DecimalInput,\n decimalPlaces = 2,\n): DecimalValue {\n return 10 ** decimalPlaces * (decimal(value, decimalPlaces) % 1)\n}\n"],"mappings":"AAOA,SAAgB,EACd,EACA,EAAgB,EACF,CACd,MAAO,EAAE,CAAC,GAAO,QAAQ,EAAc,CAIzC,SAAgB,EACd,EACA,EAAgB,EACF,CACd,MAAO,EAAG,EAAQ,IAAM,GAAe,QAAQ,EAAc,CAI/D,SAAgB,EACd,EACA,EAAgB,EACR,CACR,OAAO,KAAK,MAAO,EAAQ,IAAM,EAAc,CAIjD,SAAgB,EACd,EACA,EAAgB,EACF,CACd,MAAO,KAAM,GAAiB,EAAQ,EAAO,EAAc,CAAG"}
1
+ {"version":3,"file":"decimal.mjs","names":[],"sources":["../../../src/common/data/decimal.ts"],"sourcesContent":["export type DecimalValue = number\nexport type DecimalInput = number | string | DecimalValue\n\n/** \n * The float returned is guaraneteed to have only the `decimalPlaces` length,\n * no rounding errors or float arithmetic artefacts. \n */\nexport function decimal(\n value: DecimalInput,\n decimalPlaces = 2,\n): DecimalValue {\n return +(+value).toFixed(decimalPlaces)\n}\n\n/** `123` becomes `1.23` */\nexport function decimalFromCents(\n value: DecimalInput,\n decimalPlaces = 2,\n): DecimalValue {\n return +(+value / 10 ** decimalPlaces).toFixed(decimalPlaces)\n}\n\n/** `1.23` becomes `123` */\nexport function decimalToCents(\n value: DecimalInput,\n decimalPlaces = 2,\n): number {\n return Math.round(+value * 10 ** decimalPlaces)\n}\n\n/** `1.23` becomes `23` */\nexport function decimalCentsPart(\n value: DecimalInput,\n decimalPlaces = 2,\n): DecimalValue {\n return 10 ** decimalPlaces * (decimal(value, decimalPlaces) % 1)\n}\n"],"mappings":";;;;;AAOA,SAAgB,QACd,OACA,gBAAgB,GACF;AACd,QAAO,EAAE,CAAC,OAAO,QAAQ,cAAc;;;AAIzC,SAAgB,iBACd,OACA,gBAAgB,GACF;AACd,QAAO,EAAE,CAAC,QAAQ,MAAM,eAAe,QAAQ,cAAc;;;AAI/D,SAAgB,eACd,OACA,gBAAgB,GACR;AACR,QAAO,KAAK,MAAM,CAAC,QAAQ,MAAM,cAAc;;;AAIjD,SAAgB,iBACd,OACA,gBAAgB,GACF;AACd,QAAO,MAAM,iBAAiB,QAAQ,OAAO,cAAc,GAAG"}
@@ -1,2 +1,58 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./is.cjs`);function t(n,r,i=new WeakSet){if(n===r)return!0;if(i.has(r)||(e.isPrimitive(r)||i.add(r),!(n instanceof Object)||!(r instanceof Object))||n.constructor!==r.constructor||n.length!==r.length)return!1;for(let e in n){if(!n.hasOwnProperty(e))continue;if(!r.hasOwnProperty(e))return!1;let a=n[e],o=r[e];if(!t(a,o,i))return!1}for(let e in r)if(r.hasOwnProperty(e)&&!n.hasOwnProperty(e))return!1;return!0}function n(t,r=new WeakSet){if(r.has(t))return`[Circular ~]`;if(e.isPrimitive(t)||r.add(t),e.isRecord(t)){for(let e in t)if(t.hasOwnProperty(e)){if(t[e]===void 0){delete t[e];continue}n(t[e],r)}}else if(e.isArray(t))for(let e=t.length-1;e>=0;e--)t[e]===void 0&&t.splice(e,1);return t}function r(t,...n){for(let i of n)e.isObject(t)||(t={}),!(i==null||!e.isObject(i))&&Object.keys(i).forEach(n=>{let a=t[n],o=i[n];Array.isArray(a)&&Array.isArray(o)?t[n]=a.concat(o):e.isObject(a)&&e.isObject(o)?t[n]=r(Object.assign({},a),o):t[n]=o});return t}exports.deepEqual=t,exports.deepMerge=r,exports.deepStripUndefinedInPlace=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_common_data_is = require('./is.cjs');
3
+
4
+ //#region src/common/data/deep.ts
5
+ function deepEqual(a, b, hash = /* @__PURE__ */ new WeakSet()) {
6
+ if (a === b) return true;
7
+ if (hash.has(b)) return false;
8
+ if (!require_common_data_is.isPrimitive(b)) hash.add(b);
9
+ if (!(a instanceof Object) || !(b instanceof Object)) return false;
10
+ if (a.constructor !== b.constructor) return false;
11
+ if (a.length !== b.length) return false;
12
+ for (const p in a) {
13
+ if (!a.hasOwnProperty(p)) continue;
14
+ if (!b.hasOwnProperty(p)) return false;
15
+ const aa = a[p];
16
+ const bb = b[p];
17
+ if (!deepEqual(aa, bb, hash)) return false;
18
+ }
19
+ for (const p in b) if (b.hasOwnProperty(p) && !a.hasOwnProperty(p)) return false;
20
+ return true;
21
+ }
22
+ /** Strip properties with value `undefined` in place */
23
+ function deepStripUndefinedInPlace(a, hash = /* @__PURE__ */ new WeakSet()) {
24
+ if (hash.has(a)) return "[Circular ~]";
25
+ if (!require_common_data_is.isPrimitive(a)) hash.add(a);
26
+ if (require_common_data_is.isRecord(a)) for (const p in a) {
27
+ if (!a.hasOwnProperty(p)) continue;
28
+ if (a[p] === void 0) {
29
+ delete a[p];
30
+ continue;
31
+ }
32
+ deepStripUndefinedInPlace(a[p], hash);
33
+ }
34
+ else if (require_common_data_is.isArray(a)) {
35
+ for (let i = a.length - 1; i >= 0; i--) if (a[i] === void 0) a.splice(i, 1);
36
+ }
37
+ return a;
38
+ }
39
+ function deepMerge(target, ...sources) {
40
+ for (const source of sources) {
41
+ if (!require_common_data_is.isObject(target)) target = {};
42
+ if (source == null || !require_common_data_is.isObject(source)) continue;
43
+ Object.keys(source).forEach((key) => {
44
+ const targetValue = target[key];
45
+ const sourceValue = source[key];
46
+ if (Array.isArray(targetValue) && Array.isArray(sourceValue)) target[key] = targetValue.concat(sourceValue);
47
+ else if (require_common_data_is.isObject(targetValue) && require_common_data_is.isObject(sourceValue)) target[key] = deepMerge(Object.assign({}, targetValue), sourceValue);
48
+ else target[key] = sourceValue;
49
+ });
50
+ }
51
+ return target;
52
+ }
53
+
54
+ //#endregion
55
+ exports.deepEqual = deepEqual;
56
+ exports.deepMerge = deepMerge;
57
+ exports.deepStripUndefinedInPlace = deepStripUndefinedInPlace;
2
58
  //# sourceMappingURL=deep.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"deep.cjs","names":["isPrimitive","isRecord","isArray","isObject"],"sources":["../../../src/common/data/deep.ts"],"sourcesContent":["/* eslint-disable no-prototype-builtins */\n\nimport { isArray, isObject, isPrimitive, isRecord } from './is'\n\nexport function deepEqual(a: any, b: any, hash = new WeakSet()) {\n // if both x and y are null or undefined and exactly the same\n if (a === b)\n return true\n\n // Cyclic\n if (hash.has(b)) {\n // console.log('cyclic')\n return false\n }\n\n if (!isPrimitive(b))\n hash.add(b)\n\n // if they are not strictly equal, they both need to be Objects\n if (!(a instanceof Object) || !(b instanceof Object))\n return false\n\n // they must have the exact same prototype chain, the closest we can do is\n // test there constructor.\n if (a.constructor !== b.constructor)\n return false\n\n // Shortcut to avoid to many loops\n if (a.length !== b.length)\n return false\n\n for (const p in a) {\n // other properties were tested using x.constructor === y.constructor\n if (!a.hasOwnProperty(p))\n continue\n\n // allows to compare x[ p ] and y[ p ] when set to undefined\n if (!b.hasOwnProperty(p))\n return false\n\n const aa = a[p]\n const bb = b[p]\n\n // if they have the same strict value or identity then they are equal\n // if (aa === bb) {\n // console.log('eq', typeof bb)\n // if (bb != null) hash.set(bb, true)\n // continue\n // }\n //\n // // Numbers, Strings, Functions, Booleans must be strictly equal\n // if (typeof (aa) !== 'object') {\n // return false\n // }\n\n // Objects and Arrays must be tested recursively\n if (!deepEqual(aa, bb, hash))\n return false\n }\n\n // allows x[ p ] to be set to undefined\n for (const p in b) {\n if (b.hasOwnProperty(p) && !a.hasOwnProperty(p))\n return false\n }\n\n return true\n}\n\n/** Strip properties with value `undefined` in place */\nexport function deepStripUndefinedInPlace(a: any, hash:WeakSet<object> = new WeakSet()) {\n // Cyclic\n if (hash.has(a))\n return '[Circular ~]'\n if (!isPrimitive(a))\n hash.add(a)\n\n if (isRecord(a)) {\n for (const p in a) {\n if (!a.hasOwnProperty(p))\n continue\n if (a[p] === undefined) {\n delete a[p]\n continue\n }\n deepStripUndefinedInPlace(a[p], hash)\n }\n }\n else if (isArray(a)) {\n for (let i = a.length - 1; i >= 0; i--) {\n if (a[i] === undefined)\n a.splice(i, 1)\n }\n }\n // else ignore\n\n return a\n}\n\nexport function deepMerge(target: any, ...sources: any[]) {\n // todo cyclic protection\n for (const source of sources) {\n if (!isObject(target))\n target = {}\n\n if (source == null || !isObject(source))\n continue\n\n Object.keys(source).forEach((key) => {\n const targetValue = target[key]\n const sourceValue = (source as any)[key]\n\n if (Array.isArray(targetValue) && Array.isArray(sourceValue))\n target[key] = targetValue.concat(sourceValue)\n else if (isObject(targetValue) && isObject(sourceValue))\n target[key] = deepMerge(Object.assign({}, targetValue), sourceValue)\n else\n target[key] = sourceValue\n })\n }\n\n return target\n}\n\n// // https://stackoverflow.com/a/40294058/140927\n// // Handles cyclic references\n// export function deepClonePrimitives(obj, hash = new WeakMap()) {\n//\n// // primitives\n// if (Object(obj) !== obj) {\n// // log('Primitive', obj)\n// return obj\n// }\n//\n// // cyclic reference\n// if (hash.has(obj)) {\n// return hash.get(obj)\n// }\n//\n// let result\n//\n// // primitives as objects like new String(), new Number()\n// if (\n// obj instanceof String ||\n// obj instanceof Number ||\n// obj instanceof BigInt ||\n// obj instanceof Boolean ||\n// obj instanceof Symbol\n// ) {\n// result = new obj.constructor(obj.valueOf())\n// // hash.set(obj, result)\n// return result\n// }\n//\n// // log('Obj', obj)\n//\n// if (obj instanceof Set) {\n// result = new Set(obj)\n// } else if (obj instanceof Map) {\n// result = new Map(Array.from(obj, ([key, val]) => [key, deepClonePrimitives(val, hash)]))\n// } else if (obj instanceof Date) {\n// result = new Date(obj)\n// } else if (obj instanceof RegExp) {\n// result = new RegExp(obj.source, obj.flags)\n// } else if (Array.isArray(obj)) {\n// result = Array.from(obj, val => deepClonePrimitives(val, hash))\n// } else if (obj.constructor) {\n// result = new obj.constructor()\n// log('bj object', result)\n// } else if (obj instanceof Function || typeof obj === 'function') {\n// log('Keep object', obj, Object.getPrototypeOf(obj))\n// result = obj\n// } else {\n// result = Object.create(null)\n// }\n//\n// hash.set(obj, result)\n//\n// return Object.assign(result, ...Object.keys(obj).map(key => ({\n// [key]: deepClonePrimitives(obj[key], hash),\n// })))\n// }\n"],"mappings":"+FAIA,SAAgB,EAAU,EAAQ,EAAQ,EAAO,IAAI,QAAW,CAE9D,GAAI,IAAM,EACR,MAAO,GAqBT,GAlBI,EAAK,IAAI,EAAE,GAKVA,EAAAA,YAAY,EAAE,EACjB,EAAK,IAAI,EAAE,CAGT,EAAE,aAAa,SAAW,EAAE,aAAa,UAKzC,EAAE,cAAgB,EAAE,aAIpB,EAAE,SAAW,EAAE,OACjB,MAAO,GAET,IAAK,IAAM,KAAK,EAAG,CAEjB,GAAI,CAAC,EAAE,eAAe,EAAE,CACtB,SAGF,GAAI,CAAC,EAAE,eAAe,EAAE,CACtB,MAAO,GAET,IAAM,EAAK,EAAE,GACP,EAAK,EAAE,GAeb,GAAI,CAAC,EAAU,EAAI,EAAI,EAAK,CAC1B,MAAO,GAIX,IAAK,IAAM,KAAK,EACd,GAAI,EAAE,eAAe,EAAE,EAAI,CAAC,EAAE,eAAe,EAAE,CAC7C,MAAO,GAGX,MAAO,GAIT,SAAgB,EAA0B,EAAQ,EAAuB,IAAI,QAAW,CAEtF,GAAI,EAAK,IAAI,EAAE,CACb,MAAO,eAIT,GAHKA,EAAAA,YAAY,EAAE,EACjB,EAAK,IAAI,EAAE,CAETC,EAAAA,SAAS,EAAE,CACb,KAAK,IAAM,KAAK,EACT,KAAE,eAAe,EAAE,CAExB,IAAI,EAAE,KAAO,IAAA,GAAW,CACtB,OAAO,EAAE,GACT,SAEF,EAA0B,EAAE,GAAI,EAAK,UAGhCC,EAAAA,QAAQ,EAAE,KACZ,IAAI,EAAI,EAAE,OAAS,EAAG,GAAK,EAAG,IAC7B,EAAE,KAAO,IAAA,IACX,EAAE,OAAO,EAAG,EAAE,CAKpB,OAAO,EAGT,SAAgB,EAAU,EAAa,GAAG,EAAgB,CAExD,IAAK,IAAM,KAAU,EACdC,EAAAA,SAAS,EAAO,GACnB,EAAS,EAAE,EAET,KAAU,MAAQ,CAACA,EAAAA,SAAS,EAAO,GAGvC,OAAO,KAAK,EAAO,CAAC,QAAS,GAAQ,CACnC,IAAM,EAAc,EAAO,GACrB,EAAe,EAAe,GAEhC,MAAM,QAAQ,EAAY,EAAI,MAAM,QAAQ,EAAY,CAC1D,EAAO,GAAO,EAAY,OAAO,EAAY,CACtCA,EAAAA,SAAS,EAAY,EAAIA,EAAAA,SAAS,EAAY,CACrD,EAAO,GAAO,EAAU,OAAO,OAAO,EAAE,CAAE,EAAY,CAAE,EAAY,CAEpE,EAAO,GAAO,GAChB,CAGJ,OAAO"}
1
+ {"version":3,"file":"deep.cjs","names":["isPrimitive","isRecord","isArray","isObject"],"sources":["../../../src/common/data/deep.ts"],"sourcesContent":["/* eslint-disable no-prototype-builtins */\n\nimport { isArray, isObject, isPrimitive, isRecord } from './is'\n\nexport function deepEqual(a: any, b: any, hash = new WeakSet()) {\n // if both x and y are null or undefined and exactly the same\n if (a === b)\n return true\n\n // Cyclic\n if (hash.has(b)) {\n // console.log('cyclic')\n return false\n }\n\n if (!isPrimitive(b))\n hash.add(b)\n\n // if they are not strictly equal, they both need to be Objects\n if (!(a instanceof Object) || !(b instanceof Object))\n return false\n\n // they must have the exact same prototype chain, the closest we can do is\n // test there constructor.\n if (a.constructor !== b.constructor)\n return false\n\n // Shortcut to avoid to many loops\n if (a.length !== b.length)\n return false\n\n for (const p in a) {\n // other properties were tested using x.constructor === y.constructor\n if (!a.hasOwnProperty(p))\n continue\n\n // allows to compare x[ p ] and y[ p ] when set to undefined\n if (!b.hasOwnProperty(p))\n return false\n\n const aa = a[p]\n const bb = b[p]\n\n // if they have the same strict value or identity then they are equal\n // if (aa === bb) {\n // console.log('eq', typeof bb)\n // if (bb != null) hash.set(bb, true)\n // continue\n // }\n //\n // // Numbers, Strings, Functions, Booleans must be strictly equal\n // if (typeof (aa) !== 'object') {\n // return false\n // }\n\n // Objects and Arrays must be tested recursively\n if (!deepEqual(aa, bb, hash))\n return false\n }\n\n // allows x[ p ] to be set to undefined\n for (const p in b) {\n if (b.hasOwnProperty(p) && !a.hasOwnProperty(p))\n return false\n }\n\n return true\n}\n\n/** Strip properties with value `undefined` in place */\nexport function deepStripUndefinedInPlace(a: any, hash:WeakSet<object> = new WeakSet()) {\n // Cyclic\n if (hash.has(a))\n return '[Circular ~]'\n if (!isPrimitive(a))\n hash.add(a)\n\n if (isRecord(a)) {\n for (const p in a) {\n if (!a.hasOwnProperty(p))\n continue\n if (a[p] === undefined) {\n delete a[p]\n continue\n }\n deepStripUndefinedInPlace(a[p], hash)\n }\n }\n else if (isArray(a)) {\n for (let i = a.length - 1; i >= 0; i--) {\n if (a[i] === undefined)\n a.splice(i, 1)\n }\n }\n // else ignore\n\n return a\n}\n\nexport function deepMerge(target: any, ...sources: any[]) {\n // todo cyclic protection\n for (const source of sources) {\n if (!isObject(target))\n target = {}\n\n if (source == null || !isObject(source))\n continue\n\n Object.keys(source).forEach((key) => {\n const targetValue = target[key]\n const sourceValue = (source as any)[key]\n\n if (Array.isArray(targetValue) && Array.isArray(sourceValue))\n target[key] = targetValue.concat(sourceValue)\n else if (isObject(targetValue) && isObject(sourceValue))\n target[key] = deepMerge(Object.assign({}, targetValue), sourceValue)\n else\n target[key] = sourceValue\n })\n }\n\n return target\n}\n\n// // https://stackoverflow.com/a/40294058/140927\n// // Handles cyclic references\n// export function deepClonePrimitives(obj, hash = new WeakMap()) {\n//\n// // primitives\n// if (Object(obj) !== obj) {\n// // log('Primitive', obj)\n// return obj\n// }\n//\n// // cyclic reference\n// if (hash.has(obj)) {\n// return hash.get(obj)\n// }\n//\n// let result\n//\n// // primitives as objects like new String(), new Number()\n// if (\n// obj instanceof String ||\n// obj instanceof Number ||\n// obj instanceof BigInt ||\n// obj instanceof Boolean ||\n// obj instanceof Symbol\n// ) {\n// result = new obj.constructor(obj.valueOf())\n// // hash.set(obj, result)\n// return result\n// }\n//\n// // log('Obj', obj)\n//\n// if (obj instanceof Set) {\n// result = new Set(obj)\n// } else if (obj instanceof Map) {\n// result = new Map(Array.from(obj, ([key, val]) => [key, deepClonePrimitives(val, hash)]))\n// } else if (obj instanceof Date) {\n// result = new Date(obj)\n// } else if (obj instanceof RegExp) {\n// result = new RegExp(obj.source, obj.flags)\n// } else if (Array.isArray(obj)) {\n// result = Array.from(obj, val => deepClonePrimitives(val, hash))\n// } else if (obj.constructor) {\n// result = new obj.constructor()\n// log('bj object', result)\n// } else if (obj instanceof Function || typeof obj === 'function') {\n// log('Keep object', obj, Object.getPrototypeOf(obj))\n// result = obj\n// } else {\n// result = Object.create(null)\n// }\n//\n// hash.set(obj, result)\n//\n// return Object.assign(result, ...Object.keys(obj).map(key => ({\n// [key]: deepClonePrimitives(obj[key], hash),\n// })))\n// }\n"],"mappings":";;;;AAIA,SAAgB,UAAU,GAAQ,GAAQ,uBAAO,IAAI,SAAS,EAAE;AAE9D,KAAI,MAAM,EACR,QAAO;AAGT,KAAI,KAAK,IAAI,EAAE,CAEb,QAAO;AAGT,KAAI,CAACA,mCAAY,EAAE,CACjB,MAAK,IAAI,EAAE;AAGb,KAAI,EAAE,aAAa,WAAW,EAAE,aAAa,QAC3C,QAAO;AAIT,KAAI,EAAE,gBAAgB,EAAE,YACtB,QAAO;AAGT,KAAI,EAAE,WAAW,EAAE,OACjB,QAAO;AAET,MAAK,MAAM,KAAK,GAAG;AAEjB,MAAI,CAAC,EAAE,eAAe,EAAE,CACtB;AAGF,MAAI,CAAC,EAAE,eAAe,EAAE,CACtB,QAAO;EAET,MAAM,KAAK,EAAE;EACb,MAAM,KAAK,EAAE;AAeb,MAAI,CAAC,UAAU,IAAI,IAA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