umt 2.16.0 → 2.18.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 (303) hide show
  1. package/README.md +344 -308
  2. package/module/Array/chunk.js.map +1 -1
  3. package/module/Array/uniqBy.js.map +1 -1
  4. package/module/Async/debounceAsync.d.ts +18 -0
  5. package/module/Async/debounceAsync.js +59 -0
  6. package/module/Async/debounceAsync.js.map +1 -0
  7. package/module/Async/index.d.ts +5 -0
  8. package/module/Async/index.js +5 -0
  9. package/module/Async/index.js.map +1 -1
  10. package/module/Async/pSettled.d.ts +19 -0
  11. package/module/Async/pSettled.js +54 -0
  12. package/module/Async/pSettled.js.map +1 -0
  13. package/module/Async/retry.d.ts +22 -0
  14. package/module/Async/retry.js +49 -0
  15. package/module/Async/retry.js.map +1 -0
  16. package/module/Async/throttleAsync.d.ts +18 -0
  17. package/module/Async/throttleAsync.js +41 -0
  18. package/module/Async/throttleAsync.js.map +1 -0
  19. package/module/Async/waitFor.d.ts +18 -0
  20. package/module/Async/waitFor.js +32 -0
  21. package/module/Async/waitFor.js.map +1 -0
  22. package/module/Date/addDuration.d.ts +15 -0
  23. package/module/Date/addDuration.js +40 -0
  24. package/module/Date/addDuration.js.map +1 -0
  25. package/module/Date/diff.d.ts +14 -0
  26. package/module/Date/diff.js +45 -0
  27. package/module/Date/diff.js.map +1 -0
  28. package/module/Date/durationUnit.d.ts +12 -0
  29. package/module/Date/durationUnit.js +2 -0
  30. package/module/Date/durationUnit.js.map +1 -0
  31. package/module/Date/endOf.d.ts +13 -0
  32. package/module/Date/endOf.js +58 -0
  33. package/module/Date/endOf.js.map +1 -0
  34. package/module/Date/formatRelative.d.ts +13 -0
  35. package/module/Date/formatRelative.js +35 -0
  36. package/module/Date/formatRelative.js.map +1 -0
  37. package/module/Date/index.d.ts +10 -0
  38. package/module/Date/index.js +10 -0
  39. package/module/Date/index.js.map +1 -1
  40. package/module/Date/isBusinessDay.d.ts +10 -0
  41. package/module/Date/isBusinessDay.js +18 -0
  42. package/module/Date/isBusinessDay.js.map +1 -0
  43. package/module/Date/isSameDay.d.ts +10 -0
  44. package/module/Date/isSameDay.js +13 -0
  45. package/module/Date/isSameDay.js.map +1 -0
  46. package/module/Date/isWeekend.d.ts +9 -0
  47. package/module/Date/isWeekend.js +13 -0
  48. package/module/Date/isWeekend.js.map +1 -0
  49. package/module/Date/msByUnit.d.ts +2 -0
  50. package/module/Date/msByUnit.js +10 -0
  51. package/module/Date/msByUnit.js.map +1 -0
  52. package/module/Date/startOf.d.ts +13 -0
  53. package/module/Date/startOf.js +58 -0
  54. package/module/Date/startOf.js.map +1 -0
  55. package/module/Date/subDuration.d.ts +13 -0
  56. package/module/Date/subDuration.js +14 -0
  57. package/module/Date/subDuration.js.map +1 -0
  58. package/module/Error/index.d.ts +0 -1
  59. package/module/Error/index.js +0 -1
  60. package/module/Error/index.js.map +1 -1
  61. package/module/Object/deepClone.js.map +1 -1
  62. package/module/Object/flattenObject.d.ts +11 -0
  63. package/module/Object/flattenObject.js +29 -0
  64. package/module/Object/flattenObject.js.map +1 -0
  65. package/module/Object/get.d.ts +1 -0
  66. package/module/Object/get.js +26 -0
  67. package/module/Object/get.js.map +1 -0
  68. package/module/Object/has.d.ts +0 -19
  69. package/module/Object/has.js +4 -4
  70. package/module/Object/has.js.map +1 -1
  71. package/module/Object/index.d.ts +8 -0
  72. package/module/Object/index.js +8 -0
  73. package/module/Object/index.js.map +1 -1
  74. package/module/Object/invert.d.ts +12 -0
  75. package/module/Object/invert.js +20 -0
  76. package/module/Object/invert.js.map +1 -0
  77. package/module/Object/mergeDeep.js.map +1 -1
  78. package/module/Object/omitBy.d.ts +11 -0
  79. package/module/Object/omitBy.js +21 -0
  80. package/module/Object/omitBy.js.map +1 -0
  81. package/module/Object/pathSegments.d.ts +1 -0
  82. package/module/Object/pathSegments.js +2 -0
  83. package/module/Object/pathSegments.js.map +1 -0
  84. package/module/Object/pickBy.d.ts +11 -0
  85. package/module/Object/pickBy.js +21 -0
  86. package/module/Object/pickBy.js.map +1 -0
  87. package/module/Object/set.d.ts +19 -0
  88. package/module/Object/set.js +38 -0
  89. package/module/Object/set.js.map +1 -0
  90. package/module/Object/unflattenObject.d.ts +15 -0
  91. package/module/Object/unflattenObject.js +23 -0
  92. package/module/Object/unflattenObject.js.map +1 -0
  93. package/module/Random/index.d.ts +7 -0
  94. package/module/Random/index.js +8 -0
  95. package/module/Random/index.js.map +1 -0
  96. package/module/Random/randomBoolean.d.ts +9 -0
  97. package/module/Random/randomBoolean.js +10 -0
  98. package/module/Random/randomBoolean.js.map +1 -0
  99. package/module/Random/randomChoice.d.ts +9 -0
  100. package/module/Random/randomChoice.js +13 -0
  101. package/module/Random/randomChoice.js.map +1 -0
  102. package/module/Random/randomFloat.d.ts +9 -0
  103. package/module/Random/randomFloat.js +10 -0
  104. package/module/Random/randomFloat.js.map +1 -0
  105. package/module/Random/randomInt.d.ts +9 -0
  106. package/module/Random/randomInt.js +14 -0
  107. package/module/Random/randomInt.js.map +1 -0
  108. package/module/Random/randomUuid.d.ts +9 -0
  109. package/module/Random/randomUuid.js +31 -0
  110. package/module/Random/randomUuid.js.map +1 -0
  111. package/module/Random/seededRandom.d.ts +11 -0
  112. package/module/Random/seededRandom.js +31 -0
  113. package/module/Random/seededRandom.js.map +1 -0
  114. package/module/Random/weightedChoice.d.ts +15 -0
  115. package/module/Random/weightedChoice.js +34 -0
  116. package/module/Random/weightedChoice.js.map +1 -0
  117. package/module/String/capitalize.d.ts +12 -0
  118. package/module/String/capitalize.js +18 -0
  119. package/module/String/capitalize.js.map +1 -0
  120. package/module/String/capitalizeWord.d.ts +1 -0
  121. package/module/String/capitalizeWord.js +2 -0
  122. package/module/String/capitalizeWord.js.map +1 -0
  123. package/module/String/dedent.d.ts +19 -0
  124. package/module/String/dedent.js +56 -0
  125. package/module/String/dedent.js.map +1 -0
  126. package/module/String/index.d.ts +10 -0
  127. package/module/String/index.js +10 -0
  128. package/module/String/index.js.map +1 -1
  129. package/module/String/mask.d.ts +20 -0
  130. package/module/String/mask.js +24 -0
  131. package/module/String/mask.js.map +1 -0
  132. package/module/String/pascalCase.d.ts +9 -0
  133. package/module/String/pascalCase.js +14 -0
  134. package/module/String/pascalCase.js.map +1 -0
  135. package/module/String/snakeCase.d.ts +9 -0
  136. package/module/String/snakeCase.js +13 -0
  137. package/module/String/snakeCase.js.map +1 -0
  138. package/module/String/titleCase.d.ts +9 -0
  139. package/module/String/titleCase.js +14 -0
  140. package/module/String/titleCase.js.map +1 -0
  141. package/module/String/uncapitalize.d.ts +10 -0
  142. package/module/String/uncapitalize.js +16 -0
  143. package/module/String/uncapitalize.js.map +1 -0
  144. package/module/String/wordCount.d.ts +10 -0
  145. package/module/String/wordCount.js +12 -0
  146. package/module/String/wordCount.js.map +1 -0
  147. package/module/String/words.d.ts +12 -0
  148. package/module/String/words.js +21 -0
  149. package/module/String/words.js.map +1 -0
  150. package/module/Tool/createPipeline.d.ts +1 -1
  151. package/module/Tool/createPipeline.js +8 -6
  152. package/module/Tool/createPipeline.js.map +1 -1
  153. package/module/Tool/pipe.js.map +1 -1
  154. package/module/URL/buildUrl.d.ts +10 -0
  155. package/module/URL/buildUrl.js +10 -4
  156. package/module/URL/buildUrl.js.map +1 -1
  157. package/module/URL/parseQueryString.d.ts +6 -0
  158. package/module/URL/parseQueryString.js +6 -4
  159. package/module/URL/parseQueryString.js.map +1 -1
  160. package/module/Validate/isNumber.js.map +1 -1
  161. package/module/Validate/object/core.js +0 -1
  162. package/module/Validate/object/core.js.map +1 -1
  163. package/module/Validate/object/index.d.ts +1 -0
  164. package/module/Validate/object/index.js +1 -0
  165. package/module/Validate/object/index.js.map +1 -1
  166. package/module/Validate/object/intersection.d.ts +4 -2
  167. package/module/Validate/object/intersection.js.map +1 -1
  168. package/module/Validate/object/nullable.d.ts +8 -0
  169. package/module/Validate/object/nullable.js +21 -0
  170. package/module/Validate/object/nullable.js.map +1 -0
  171. package/module/Validate/object/union.d.ts +4 -2
  172. package/module/Validate/object/union.js.map +1 -1
  173. package/module/Validate/string/index.d.ts +1 -0
  174. package/module/Validate/string/index.js +1 -0
  175. package/module/Validate/string/index.js.map +1 -1
  176. package/module/Validate/string/oneOf.d.ts +32 -0
  177. package/module/Validate/string/oneOf.js +32 -0
  178. package/module/Validate/string/oneOf.js.map +1 -0
  179. package/module/es5/Async/debounceAsync.d.ts +18 -0
  180. package/module/es5/Async/debounceAsync.js +103 -0
  181. package/module/es5/Async/index.d.ts +5 -0
  182. package/module/es5/Async/index.js +55 -0
  183. package/module/es5/Async/pSettled.d.ts +19 -0
  184. package/module/es5/Async/pSettled.js +68 -0
  185. package/module/es5/Async/retry.d.ts +22 -0
  186. package/module/es5/Async/retry.js +106 -0
  187. package/module/es5/Async/throttleAsync.d.ts +18 -0
  188. package/module/es5/Async/throttleAsync.js +46 -0
  189. package/module/es5/Async/waitFor.d.ts +18 -0
  190. package/module/es5/{Error/retry.js → Async/waitFor.js} +68 -74
  191. package/module/es5/Date/addDuration.d.ts +15 -0
  192. package/module/es5/Date/addDuration.js +45 -0
  193. package/module/es5/Date/diff.d.ts +14 -0
  194. package/module/es5/Date/diff.js +40 -0
  195. package/module/es5/Date/durationUnit.d.ts +12 -0
  196. package/module/es5/Date/durationUnit.js +5 -0
  197. package/module/es5/Date/endOf.d.ts +13 -0
  198. package/module/es5/Date/endOf.js +72 -0
  199. package/module/es5/Date/formatRelative.d.ts +13 -0
  200. package/module/es5/Date/formatRelative.js +61 -0
  201. package/module/es5/Date/index.d.ts +10 -0
  202. package/module/es5/Date/index.js +110 -0
  203. package/module/es5/Date/isBusinessDay.d.ts +10 -0
  204. package/module/es5/Date/isBusinessDay.js +26 -0
  205. package/module/es5/Date/isSameDay.d.ts +10 -0
  206. package/module/es5/Date/isSameDay.js +18 -0
  207. package/module/es5/Date/isWeekend.d.ts +9 -0
  208. package/module/es5/Date/isWeekend.js +18 -0
  209. package/module/es5/Date/msByUnit.d.ts +2 -0
  210. package/module/es5/Date/msByUnit.js +15 -0
  211. package/module/es5/Date/startOf.d.ts +13 -0
  212. package/module/es5/Date/startOf.js +72 -0
  213. package/module/es5/Date/subDuration.d.ts +13 -0
  214. package/module/es5/Date/subDuration.js +21 -0
  215. package/module/es5/Error/index.d.ts +0 -1
  216. package/module/es5/Error/index.js +0 -11
  217. package/module/es5/Object/flattenObject.d.ts +11 -0
  218. package/module/es5/Object/flattenObject.js +35 -0
  219. package/module/es5/Object/get.d.ts +1 -0
  220. package/module/es5/Object/get.js +42 -0
  221. package/module/es5/Object/has.d.ts +0 -19
  222. package/module/es5/Object/has.js +4 -4
  223. package/module/es5/Object/index.d.ts +8 -0
  224. package/module/es5/Object/index.js +88 -0
  225. package/module/es5/Object/invert.d.ts +12 -0
  226. package/module/es5/Object/invert.js +26 -0
  227. package/module/es5/Object/omitBy.d.ts +11 -0
  228. package/module/es5/Object/omitBy.js +27 -0
  229. package/module/es5/Object/pathSegments.d.ts +1 -0
  230. package/module/es5/Object/pathSegments.js +9 -0
  231. package/module/es5/Object/pickBy.d.ts +11 -0
  232. package/module/es5/Object/pickBy.js +27 -0
  233. package/module/es5/Object/set.d.ts +19 -0
  234. package/module/es5/Object/set.js +44 -0
  235. package/module/es5/Object/unflattenObject.d.ts +15 -0
  236. package/module/es5/Object/unflattenObject.js +30 -0
  237. package/module/es5/Random/index.d.ts +7 -0
  238. package/module/es5/Random/index.js +82 -0
  239. package/module/es5/Random/randomBoolean.d.ts +9 -0
  240. package/module/es5/Random/randomBoolean.js +18 -0
  241. package/module/es5/Random/randomChoice.d.ts +9 -0
  242. package/module/es5/Random/randomChoice.js +18 -0
  243. package/module/es5/Random/randomFloat.d.ts +9 -0
  244. package/module/es5/Random/randomFloat.js +17 -0
  245. package/module/es5/Random/randomInt.d.ts +9 -0
  246. package/module/es5/Random/randomInt.js +19 -0
  247. package/module/es5/Random/randomUuid.d.ts +9 -0
  248. package/module/es5/Random/randomUuid.js +38 -0
  249. package/module/es5/Random/seededRandom.d.ts +11 -0
  250. package/module/es5/Random/seededRandom.js +46 -0
  251. package/module/es5/Random/weightedChoice.d.ts +15 -0
  252. package/module/es5/Random/weightedChoice.js +50 -0
  253. package/module/es5/String/capitalize.d.ts +12 -0
  254. package/module/es5/String/capitalize.js +35 -0
  255. package/module/es5/String/capitalizeWord.d.ts +1 -0
  256. package/module/es5/String/capitalizeWord.js +9 -0
  257. package/module/es5/String/dedent.d.ts +19 -0
  258. package/module/es5/String/dedent.js +82 -0
  259. package/module/es5/String/index.d.ts +10 -0
  260. package/module/es5/String/index.js +110 -0
  261. package/module/es5/String/mask.d.ts +20 -0
  262. package/module/es5/String/mask.js +39 -0
  263. package/module/es5/String/pascalCase.d.ts +9 -0
  264. package/module/es5/String/pascalCase.js +21 -0
  265. package/module/es5/String/snakeCase.d.ts +9 -0
  266. package/module/es5/String/snakeCase.js +20 -0
  267. package/module/es5/String/titleCase.d.ts +9 -0
  268. package/module/es5/String/titleCase.js +21 -0
  269. package/module/es5/String/uncapitalize.d.ts +10 -0
  270. package/module/es5/String/uncapitalize.js +33 -0
  271. package/module/es5/String/wordCount.d.ts +10 -0
  272. package/module/es5/String/wordCount.js +19 -0
  273. package/module/es5/String/words.d.ts +12 -0
  274. package/module/es5/String/words.js +25 -0
  275. package/module/es5/Tool/createPipeline.d.ts +1 -1
  276. package/module/es5/Tool/createPipeline.js +7 -10
  277. package/module/es5/URL/buildUrl.d.ts +10 -0
  278. package/module/es5/URL/buildUrl.js +10 -4
  279. package/module/es5/URL/parseQueryString.d.ts +6 -0
  280. package/module/es5/URL/parseQueryString.js +6 -4
  281. package/module/es5/Validate/object/core.js +0 -1
  282. package/module/es5/Validate/object/index.d.ts +1 -0
  283. package/module/es5/Validate/object/index.js +11 -0
  284. package/module/es5/Validate/object/intersection.d.ts +4 -2
  285. package/module/es5/Validate/object/intersection.js +6 -0
  286. package/module/es5/Validate/object/nullable.d.ts +8 -0
  287. package/module/es5/Validate/object/nullable.js +26 -0
  288. package/module/es5/Validate/object/union.d.ts +4 -2
  289. package/module/es5/Validate/object/union.js +6 -0
  290. package/module/es5/Validate/string/index.d.ts +1 -0
  291. package/module/es5/Validate/string/index.js +11 -0
  292. package/module/es5/Validate/string/oneOf.d.ts +32 -0
  293. package/module/es5/Validate/string/oneOf.js +45 -0
  294. package/module/es5/index.d.ts +1 -0
  295. package/module/es5/index.js +20 -9
  296. package/module/index.d.ts +1 -0
  297. package/module/index.js +1 -0
  298. package/module/index.js.map +1 -1
  299. package/package.json +33 -25
  300. package/module/Error/retry.d.ts +0 -37
  301. package/module/Error/retry.js +0 -47
  302. package/module/Error/retry.js.map +0 -1
  303. package/module/es5/Error/retry.d.ts +0 -37
@@ -3,86 +3,80 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.retry = void 0;
6
+ exports.waitFor = void 0;
7
+ var _sleep = require("./sleep");
7
8
  function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
8
9
  function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
9
10
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
10
11
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
11
12
  /**
12
- * Retries a given async function with configurable retry logic
13
- *
14
- * @template T - The return type of the function
15
- * @param function_ - The async function to retry
16
- * @param options - Configuration options for retry behavior
17
- * @param options.retries - Maximum number of retry attempts (default: 3)
18
- * @param options.delay - Delay between retries in milliseconds (default: 1000)
19
- * @param options.shouldRetry - Function to determine if an error should trigger a retry (default: always retry)
20
- * @returns Promise that resolves with the function result or rejects with the final error
13
+ * Repeatedly evaluates a condition until it returns a truthy value or the
14
+ * timeout elapses. Resolves with the final truthy value.
21
15
  *
16
+ * @template T - Truthy result type
17
+ * @param {() => T | Promise<T>} condition - Condition predicate
18
+ * @param {WaitForOptions} [options] - Polling configuration
19
+ * @returns {Promise<NonNullable<T>>} The first truthy value
20
+ * @throws {Error} When the timeout elapses or the signal aborts
22
21
  * @example
23
- * ```typescript
24
- * // Basic usage with default options
25
- * const result = await retry(async () => {
26
- * const response = await fetch('/api/data');
27
- * if (!response.ok) throw new Error('Failed to fetch');
28
- * return response.json();
29
- * });
30
- *
31
- * // Custom retry configuration
32
- * const result = await retry(
33
- * () => riskyOperation(),
34
- * {
35
- * retries: 5,
36
- * delay: 2000,
37
- * shouldRetry: (error) => error instanceof NetworkError
38
- * }
39
- * );
40
- * ```
22
+ * await waitFor(() => document.querySelector("#root"), { interval: 100 });
41
23
  */
42
- var retry = exports.retry = function retry(function_) {
43
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
44
- var _options$retries = options.retries,
45
- retries = _options$retries === void 0 ? 3 : _options$retries,
46
- _options$delay = options.delay,
47
- delay = _options$delay === void 0 ? 1000 : _options$delay,
48
- _options$shouldRetry = options.shouldRetry,
49
- shouldRetry = _options$shouldRetry === void 0 ? function () {
50
- return true;
51
- } : _options$shouldRetry;
52
- var _attempt = /*#__PURE__*/function () {
53
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(remainingAttempts) {
54
- var _t;
55
- return _regenerator().w(function (_context) {
56
- while (1) switch (_context.p = _context.n) {
57
- case 0:
58
- _context.p = 0;
59
- _context.n = 1;
60
- return function_();
61
- case 1:
62
- return _context.a(2, _context.v);
63
- case 2:
64
- _context.p = 2;
65
- _t = _context.v;
66
- if (!(remainingAttempts <= 0 || !shouldRetry(_t))) {
67
- _context.n = 3;
68
- break;
69
- }
70
- throw _t;
71
- case 3:
24
+ var waitFor = exports.waitFor = /*#__PURE__*/function () {
25
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(condition) {
26
+ var options,
27
+ _options$timeout,
28
+ timeout,
29
+ _options$interval,
30
+ interval,
31
+ signal,
32
+ startTime,
33
+ _signal$reason,
34
+ value,
35
+ _args = arguments;
36
+ return _regenerator().w(function (_context) {
37
+ while (1) switch (_context.n) {
38
+ case 0:
39
+ options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
40
+ _options$timeout = options.timeout, timeout = _options$timeout === void 0 ? 5000 : _options$timeout, _options$interval = options.interval, interval = _options$interval === void 0 ? 100 : _options$interval, signal = options.signal;
41
+ startTime = Date.now();
42
+ case 1:
43
+ if (!true) {
44
+ _context.n = 7;
45
+ break;
46
+ }
47
+ if (!(signal !== null && signal !== void 0 && signal.aborted)) {
48
+ _context.n = 2;
49
+ break;
50
+ }
51
+ throw (_signal$reason = signal.reason) !== null && _signal$reason !== void 0 ? _signal$reason : new Error("Aborted");
52
+ case 2:
53
+ _context.n = 3;
54
+ return condition();
55
+ case 3:
56
+ value = _context.v;
57
+ if (!value) {
72
58
  _context.n = 4;
73
- return new Promise(function (resolve) {
74
- return setTimeout(function () {
75
- return resolve(_attempt(remainingAttempts - 1));
76
- }, delay);
77
- });
78
- case 4:
79
- return _context.a(2, _context.v);
80
- }
81
- }, _callee, null, [[0, 2]]);
82
- }));
83
- return function attempt(_x) {
84
- return _ref.apply(this, arguments);
85
- };
86
- }();
87
- return _attempt(retries);
88
- };
59
+ break;
60
+ }
61
+ return _context.a(2, value);
62
+ case 4:
63
+ if (!(Date.now() - startTime >= timeout)) {
64
+ _context.n = 5;
65
+ break;
66
+ }
67
+ throw new Error("waitFor timed out after ".concat(timeout, "ms"));
68
+ case 5:
69
+ _context.n = 6;
70
+ return (0, _sleep.sleep)(interval);
71
+ case 6:
72
+ _context.n = 1;
73
+ break;
74
+ case 7:
75
+ return _context.a(2);
76
+ }
77
+ }, _callee);
78
+ }));
79
+ return function waitFor(_x) {
80
+ return _ref.apply(this, arguments);
81
+ };
82
+ }();
@@ -0,0 +1,15 @@
1
+ import type { DurationUnit } from "./durationUnit";
2
+ /**
3
+ * Adds a duration to a date and returns a new Date.
4
+ * Calendar-aware for "M" (months) and "y" (years), so end-of-month
5
+ * is preserved (e.g. Jan 31 + 1 month = Feb 28/29).
6
+ *
7
+ * @param {Date} date - Base date
8
+ * @param {number} amount - Amount to add (can be negative)
9
+ * @param {DurationUnit} unit - Unit of the amount
10
+ * @returns {Date} A new Date with the duration added
11
+ * @example
12
+ * addDuration(new Date("2025-01-31"), 1, "M"); // 2025-02-28
13
+ * addDuration(new Date("2025-01-01"), 7, "d"); // 2025-01-08
14
+ */
15
+ export declare const addDuration: (date: Date, amount: number, unit: DurationUnit) => Date;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.addDuration = void 0;
7
+ var _msByUnit = require("./msByUnit");
8
+ /**
9
+ * Adds a duration to a date and returns a new Date.
10
+ * Calendar-aware for "M" (months) and "y" (years), so end-of-month
11
+ * is preserved (e.g. Jan 31 + 1 month = Feb 28/29).
12
+ *
13
+ * @param {Date} date - Base date
14
+ * @param {number} amount - Amount to add (can be negative)
15
+ * @param {DurationUnit} unit - Unit of the amount
16
+ * @returns {Date} A new Date with the duration added
17
+ * @example
18
+ * addDuration(new Date("2025-01-31"), 1, "M"); // 2025-02-28
19
+ * addDuration(new Date("2025-01-01"), 7, "d"); // 2025-01-08
20
+ */
21
+ var addDuration = exports.addDuration = function addDuration(date, amount, unit) {
22
+ var ms = _msByUnit.msByUnit[unit];
23
+ if (ms !== undefined) {
24
+ return new Date(date.getTime() + amount * ms);
25
+ }
26
+ var result = new Date(date);
27
+ if (unit === "M") {
28
+ var targetMonth = result.getMonth() + amount;
29
+ var _day = result.getDate();
30
+ result.setDate(1);
31
+ result.setMonth(targetMonth);
32
+ var _lastDayOfTargetMonth = new Date(result.getFullYear(), result.getMonth() + 1, 0).getDate();
33
+ result.setDate(Math.min(_day, _lastDayOfTargetMonth));
34
+ return result;
35
+ }
36
+ var targetYear = result.getFullYear() + amount;
37
+ var month = result.getMonth();
38
+ var day = result.getDate();
39
+ result.setDate(1);
40
+ result.setFullYear(targetYear);
41
+ result.setMonth(month);
42
+ var lastDayOfTargetMonth = new Date(targetYear, month + 1, 0).getDate();
43
+ result.setDate(Math.min(day, lastDayOfTargetMonth));
44
+ return result;
45
+ };
@@ -0,0 +1,14 @@
1
+ import type { DurationUnit } from "./durationUnit";
2
+ /**
3
+ * Returns the difference between two dates in the given unit, truncated toward zero.
4
+ * Calendar-aware for "M" (months) and "y" (years).
5
+ *
6
+ * @param {Date} left - End date
7
+ * @param {Date} right - Start date
8
+ * @param {DurationUnit} unit - Unit of the result
9
+ * @returns {number} The difference, truncated toward zero
10
+ * @example
11
+ * diff(new Date("2025-12-31"), new Date("2025-01-01"), "d"); // 364
12
+ * diff(new Date("2026-01-01"), new Date("2025-01-01"), "y"); // 1
13
+ */
14
+ export declare const diff: (left: Date, right: Date, unit: DurationUnit) => number;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.diff = void 0;
7
+ var _clock = require("../Consts/clock");
8
+ var _msByUnit = require("./msByUnit");
9
+ /**
10
+ * Returns the difference between two dates in the given unit, truncated toward zero.
11
+ * Calendar-aware for "M" (months) and "y" (years).
12
+ *
13
+ * @param {Date} left - End date
14
+ * @param {Date} right - Start date
15
+ * @param {DurationUnit} unit - Unit of the result
16
+ * @returns {number} The difference, truncated toward zero
17
+ * @example
18
+ * diff(new Date("2025-12-31"), new Date("2025-01-01"), "d"); // 364
19
+ * diff(new Date("2026-01-01"), new Date("2025-01-01"), "y"); // 1
20
+ */
21
+ var diff = exports.diff = function diff(left, right, unit) {
22
+ var ms = _msByUnit.msByUnit[unit];
23
+ if (ms !== undefined) {
24
+ return Math.trunc((left.getTime() - right.getTime()) / ms);
25
+ }
26
+ var yearsDelta = left.getFullYear() - right.getFullYear();
27
+ var monthsDelta = left.getMonth() - right.getMonth();
28
+ var dayDelta = left.getDate() - right.getDate();
29
+ var subDayDelta = left.getHours() * _clock.OneHourMs + left.getMinutes() * _clock.OneMinuteMs + left.getSeconds() * _clock.OneSecondMs + left.getMilliseconds() - (right.getHours() * _clock.OneHourMs + right.getMinutes() * _clock.OneMinuteMs + right.getSeconds() * _clock.OneSecondMs + right.getMilliseconds());
30
+ var calendarMonths = yearsDelta * 12 + monthsDelta;
31
+ if (calendarMonths > 0 && (dayDelta < 0 || dayDelta === 0 && subDayDelta < 0)) {
32
+ calendarMonths -= 1;
33
+ } else if (calendarMonths < 0 && (dayDelta > 0 || dayDelta === 0 && subDayDelta > 0)) {
34
+ calendarMonths += 1;
35
+ }
36
+ if (unit === "M") {
37
+ return calendarMonths;
38
+ }
39
+ return Math.trunc(calendarMonths / 12);
40
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Supported duration units for date arithmetic.
3
+ * - ms: milliseconds
4
+ * - s: seconds
5
+ * - m: minutes
6
+ * - h: hours
7
+ * - d: days
8
+ * - w: weeks
9
+ * - M: months (calendar-aware)
10
+ * - y: years (calendar-aware)
11
+ */
12
+ export type DurationUnit = "ms" | "s" | "m" | "h" | "d" | "w" | "M" | "y";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,13 @@
1
+ import type { DateBoundaryUnit } from "./startOf";
2
+ /**
3
+ * Returns a new Date set to the end of the given unit.
4
+ * Week ends on Saturday at 23:59:59.999.
5
+ *
6
+ * @param {Date} date - Base date
7
+ * @param {DateBoundaryUnit} unit - Boundary unit
8
+ * @returns {Date} A new Date at the end of the specified unit
9
+ * @example
10
+ * endOf(new Date("2025-04-15T10:30:00"), "day"); // 2025-04-15T23:59:59.999
11
+ * endOf(new Date("2025-04-15"), "month"); // 2025-04-30T23:59:59.999
12
+ */
13
+ export declare const endOf: (date: Date, unit: DateBoundaryUnit) => Date;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.endOf = void 0;
7
+ /**
8
+ * Returns a new Date set to the end of the given unit.
9
+ * Week ends on Saturday at 23:59:59.999.
10
+ *
11
+ * @param {Date} date - Base date
12
+ * @param {DateBoundaryUnit} unit - Boundary unit
13
+ * @returns {Date} A new Date at the end of the specified unit
14
+ * @example
15
+ * endOf(new Date("2025-04-15T10:30:00"), "day"); // 2025-04-15T23:59:59.999
16
+ * endOf(new Date("2025-04-15"), "month"); // 2025-04-30T23:59:59.999
17
+ */
18
+ var endOf = exports.endOf = function endOf(date, unit) {
19
+ var result = new Date(date);
20
+ switch (unit) {
21
+ case "second":
22
+ {
23
+ result.setMilliseconds(999);
24
+ return result;
25
+ }
26
+ case "minute":
27
+ {
28
+ result.setSeconds(59, 999);
29
+ return result;
30
+ }
31
+ case "hour":
32
+ {
33
+ result.setMinutes(59, 59, 999);
34
+ return result;
35
+ }
36
+ case "day":
37
+ {
38
+ result.setHours(23, 59, 59, 999);
39
+ return result;
40
+ }
41
+ case "week":
42
+ {
43
+ var dayOfWeek = result.getDay();
44
+ result.setDate(result.getDate() + (6 - dayOfWeek));
45
+ result.setHours(23, 59, 59, 999);
46
+ return result;
47
+ }
48
+ case "month":
49
+ {
50
+ result.setMonth(result.getMonth() + 1, 0);
51
+ result.setHours(23, 59, 59, 999);
52
+ return result;
53
+ }
54
+ case "quarter":
55
+ {
56
+ var quarterEndMonth = Math.floor(result.getMonth() / 3) * 3 + 2;
57
+ result.setMonth(quarterEndMonth + 1, 0);
58
+ result.setHours(23, 59, 59, 999);
59
+ return result;
60
+ }
61
+ case "year":
62
+ {
63
+ result.setMonth(11, 31);
64
+ result.setHours(23, 59, 59, 999);
65
+ return result;
66
+ }
67
+ default:
68
+ {
69
+ return result;
70
+ }
71
+ }
72
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Formats a date relative to a base date using Intl.RelativeTimeFormat.
3
+ * Picks the largest unit that fits the absolute delta.
4
+ *
5
+ * @param {Date} date - The target date
6
+ * @param {Date} [baseDate=new Date()] - Reference date (defaults to now)
7
+ * @param {string} [locale] - BCP 47 locale tag; uses system locale if omitted
8
+ * @returns {string} Localized relative-time string
9
+ * @example
10
+ * formatRelative(new Date(Date.now() - 3600_000), new Date(), "en"); // "1 hour ago"
11
+ * formatRelative(new Date(Date.now() + 86_400_000), new Date(), "ja"); // "1 日後"
12
+ */
13
+ export declare const formatRelative: (date: Date, baseDate?: Date, locale?: string) => string;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatRelative = void 0;
7
+ var _clock = require("../Consts/clock");
8
+ var THRESHOLDS = [{
9
+ unit: "year",
10
+ ms: _clock.OneYearMs
11
+ }, {
12
+ unit: "month",
13
+ ms: _clock.OneMonthMs
14
+ }, {
15
+ unit: "week",
16
+ ms: _clock.OneWeekMs
17
+ }, {
18
+ unit: "day",
19
+ ms: _clock.OneDayMs
20
+ }, {
21
+ unit: "hour",
22
+ ms: _clock.OneHourMs
23
+ }, {
24
+ unit: "minute",
25
+ ms: _clock.OneMinuteMs
26
+ }, {
27
+ unit: "second",
28
+ ms: _clock.OneSecondMs
29
+ }];
30
+
31
+ /**
32
+ * Formats a date relative to a base date using Intl.RelativeTimeFormat.
33
+ * Picks the largest unit that fits the absolute delta.
34
+ *
35
+ * @param {Date} date - The target date
36
+ * @param {Date} [baseDate=new Date()] - Reference date (defaults to now)
37
+ * @param {string} [locale] - BCP 47 locale tag; uses system locale if omitted
38
+ * @returns {string} Localized relative-time string
39
+ * @example
40
+ * formatRelative(new Date(Date.now() - 3600_000), new Date(), "en"); // "1 hour ago"
41
+ * formatRelative(new Date(Date.now() + 86_400_000), new Date(), "ja"); // "1 日後"
42
+ */
43
+ var formatRelative = exports.formatRelative = function formatRelative(date) {
44
+ var baseDate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Date();
45
+ var locale = arguments.length > 2 ? arguments[2] : undefined;
46
+ var deltaMs = date.getTime() - baseDate.getTime();
47
+ var absDelta = Math.abs(deltaMs);
48
+ var formatter = new Intl.RelativeTimeFormat(locale, {
49
+ numeric: "auto"
50
+ });
51
+ for (var _i = 0, _THRESHOLDS = THRESHOLDS; _i < _THRESHOLDS.length; _i++) {
52
+ var _THRESHOLDS$_i = _THRESHOLDS[_i],
53
+ unit = _THRESHOLDS$_i.unit,
54
+ ms = _THRESHOLDS$_i.ms;
55
+ if (absDelta >= ms) {
56
+ var value = Math.round(deltaMs / ms);
57
+ return formatter.format(value, unit);
58
+ }
59
+ }
60
+ return formatter.format(0, "second");
61
+ };
@@ -1,9 +1,19 @@
1
+ export * from "./addDuration";
1
2
  export * from "./birthday";
2
3
  export * from "./dateRange";
3
4
  export * from "./dayOfWeek";
5
+ export * from "./diff";
6
+ export * from "./durationUnit";
7
+ export * from "./endOf";
4
8
  export * from "./format";
9
+ export * from "./formatRelative";
5
10
  export * from "./getDay";
6
11
  export * from "./getTimezoneOffsetString";
12
+ export * from "./isBusinessDay";
7
13
  export * from "./isLeapYear";
14
+ export * from "./isSameDay";
15
+ export * from "./isWeekend";
8
16
  export * from "./new";
9
17
  export * from "./now";
18
+ export * from "./startOf";
19
+ export * from "./subDuration";
@@ -3,6 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _addDuration = require("./addDuration");
7
+ Object.keys(_addDuration).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _addDuration[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _addDuration[key];
14
+ }
15
+ });
16
+ });
6
17
  var _birthday = require("./birthday");
7
18
  Object.keys(_birthday).forEach(function (key) {
8
19
  if (key === "default" || key === "__esModule") return;
@@ -36,6 +47,39 @@ Object.keys(_dayOfWeek).forEach(function (key) {
36
47
  }
37
48
  });
38
49
  });
50
+ var _diff = require("./diff");
51
+ Object.keys(_diff).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _diff[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function get() {
57
+ return _diff[key];
58
+ }
59
+ });
60
+ });
61
+ var _durationUnit = require("./durationUnit");
62
+ Object.keys(_durationUnit).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _durationUnit[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function get() {
68
+ return _durationUnit[key];
69
+ }
70
+ });
71
+ });
72
+ var _endOf = require("./endOf");
73
+ Object.keys(_endOf).forEach(function (key) {
74
+ if (key === "default" || key === "__esModule") return;
75
+ if (key in exports && exports[key] === _endOf[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function get() {
79
+ return _endOf[key];
80
+ }
81
+ });
82
+ });
39
83
  var _format = require("./format");
40
84
  Object.keys(_format).forEach(function (key) {
41
85
  if (key === "default" || key === "__esModule") return;
@@ -47,6 +91,17 @@ Object.keys(_format).forEach(function (key) {
47
91
  }
48
92
  });
49
93
  });
94
+ var _formatRelative = require("./formatRelative");
95
+ Object.keys(_formatRelative).forEach(function (key) {
96
+ if (key === "default" || key === "__esModule") return;
97
+ if (key in exports && exports[key] === _formatRelative[key]) return;
98
+ Object.defineProperty(exports, key, {
99
+ enumerable: true,
100
+ get: function get() {
101
+ return _formatRelative[key];
102
+ }
103
+ });
104
+ });
50
105
  var _getDay = require("./getDay");
51
106
  Object.keys(_getDay).forEach(function (key) {
52
107
  if (key === "default" || key === "__esModule") return;
@@ -69,6 +124,17 @@ Object.keys(_getTimezoneOffsetString).forEach(function (key) {
69
124
  }
70
125
  });
71
126
  });
127
+ var _isBusinessDay = require("./isBusinessDay");
128
+ Object.keys(_isBusinessDay).forEach(function (key) {
129
+ if (key === "default" || key === "__esModule") return;
130
+ if (key in exports && exports[key] === _isBusinessDay[key]) return;
131
+ Object.defineProperty(exports, key, {
132
+ enumerable: true,
133
+ get: function get() {
134
+ return _isBusinessDay[key];
135
+ }
136
+ });
137
+ });
72
138
  var _isLeapYear = require("./isLeapYear");
73
139
  Object.keys(_isLeapYear).forEach(function (key) {
74
140
  if (key === "default" || key === "__esModule") return;
@@ -80,6 +146,28 @@ Object.keys(_isLeapYear).forEach(function (key) {
80
146
  }
81
147
  });
82
148
  });
149
+ var _isSameDay = require("./isSameDay");
150
+ Object.keys(_isSameDay).forEach(function (key) {
151
+ if (key === "default" || key === "__esModule") return;
152
+ if (key in exports && exports[key] === _isSameDay[key]) return;
153
+ Object.defineProperty(exports, key, {
154
+ enumerable: true,
155
+ get: function get() {
156
+ return _isSameDay[key];
157
+ }
158
+ });
159
+ });
160
+ var _isWeekend = require("./isWeekend");
161
+ Object.keys(_isWeekend).forEach(function (key) {
162
+ if (key === "default" || key === "__esModule") return;
163
+ if (key in exports && exports[key] === _isWeekend[key]) return;
164
+ Object.defineProperty(exports, key, {
165
+ enumerable: true,
166
+ get: function get() {
167
+ return _isWeekend[key];
168
+ }
169
+ });
170
+ });
83
171
  var _new = require("./new");
84
172
  Object.keys(_new).forEach(function (key) {
85
173
  if (key === "default" || key === "__esModule") return;
@@ -101,4 +189,26 @@ Object.keys(_now).forEach(function (key) {
101
189
  return _now[key];
102
190
  }
103
191
  });
192
+ });
193
+ var _startOf = require("./startOf");
194
+ Object.keys(_startOf).forEach(function (key) {
195
+ if (key === "default" || key === "__esModule") return;
196
+ if (key in exports && exports[key] === _startOf[key]) return;
197
+ Object.defineProperty(exports, key, {
198
+ enumerable: true,
199
+ get: function get() {
200
+ return _startOf[key];
201
+ }
202
+ });
203
+ });
204
+ var _subDuration = require("./subDuration");
205
+ Object.keys(_subDuration).forEach(function (key) {
206
+ if (key === "default" || key === "__esModule") return;
207
+ if (key in exports && exports[key] === _subDuration[key]) return;
208
+ Object.defineProperty(exports, key, {
209
+ enumerable: true,
210
+ get: function get() {
211
+ return _subDuration[key];
212
+ }
213
+ });
104
214
  });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns true when the given date is a weekday and not in the holidays list.
3
+ * @param {Date} date - The date to check
4
+ * @param {Date[]} [holidays=[]] - Optional list of holiday dates
5
+ * @returns {boolean} True when weekday and not a listed holiday
6
+ * @example
7
+ * isBusinessDay(new Date("2025-04-21")); // true (Monday)
8
+ * isBusinessDay(new Date("2025-04-21"), [new Date("2025-04-21")]); // false
9
+ */
10
+ export declare const isBusinessDay: (date: Date, holidays?: Date[]) => boolean;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isBusinessDay = void 0;
7
+ var _isSameDay = require("./isSameDay");
8
+ var _isWeekend = require("./isWeekend");
9
+ /**
10
+ * Returns true when the given date is a weekday and not in the holidays list.
11
+ * @param {Date} date - The date to check
12
+ * @param {Date[]} [holidays=[]] - Optional list of holiday dates
13
+ * @returns {boolean} True when weekday and not a listed holiday
14
+ * @example
15
+ * isBusinessDay(new Date("2025-04-21")); // true (Monday)
16
+ * isBusinessDay(new Date("2025-04-21"), [new Date("2025-04-21")]); // false
17
+ */
18
+ var isBusinessDay = exports.isBusinessDay = function isBusinessDay(date) {
19
+ var holidays = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
20
+ if ((0, _isWeekend.isWeekend)(date)) {
21
+ return false;
22
+ }
23
+ return !holidays.some(function (holiday) {
24
+ return (0, _isSameDay.isSameDay)(holiday, date);
25
+ });
26
+ };