@naturalcycles/js-lib 14.276.0 → 15.0.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 (353) hide show
  1. package/cfg/frontend/tsconfig.json +3 -3
  2. package/dist/abort.js +1 -4
  3. package/dist/array/array.util.d.ts +1 -1
  4. package/dist/array/array.util.js +47 -88
  5. package/dist/array/range.d.ts +2 -2
  6. package/dist/array/range.js +7 -12
  7. package/dist/bot.js +6 -10
  8. package/dist/browser/adminService.d.ts +1 -1
  9. package/dist/browser/adminService.js +10 -14
  10. package/dist/browser/analytics.util.js +10 -15
  11. package/dist/browser/i18n/fetchTranslationLoader.d.ts +3 -3
  12. package/dist/browser/i18n/fetchTranslationLoader.js +1 -5
  13. package/dist/browser/i18n/translation.service.d.ts +1 -1
  14. package/dist/browser/i18n/translation.service.js +5 -10
  15. package/dist/browser/imageFitter.js +1 -5
  16. package/dist/browser/script.util.js +8 -12
  17. package/dist/browser/topbar.js +7 -10
  18. package/dist/datetime/dateInterval.d.ts +2 -2
  19. package/dist/datetime/dateInterval.js +7 -11
  20. package/dist/datetime/localDate.d.ts +3 -3
  21. package/dist/datetime/localDate.js +40 -44
  22. package/dist/datetime/localTime.d.ts +3 -3
  23. package/dist/datetime/localTime.js +36 -40
  24. package/dist/datetime/timeInterval.d.ts +2 -2
  25. package/dist/datetime/timeInterval.js +6 -10
  26. package/dist/datetime/wallTime.d.ts +3 -3
  27. package/dist/datetime/wallTime.js +5 -9
  28. package/dist/decorators/asyncMemo.decorator.d.ts +3 -3
  29. package/dist/decorators/asyncMemo.decorator.js +12 -17
  30. package/dist/decorators/createPromiseDecorator.js +3 -6
  31. package/dist/decorators/debounce.d.ts +1 -1
  32. package/dist/decorators/debounce.decorator.d.ts +1 -1
  33. package/dist/decorators/debounce.decorator.js +5 -9
  34. package/dist/decorators/debounce.js +2 -6
  35. package/dist/decorators/decorator.util.d.ts +1 -1
  36. package/dist/decorators/decorator.util.js +3 -8
  37. package/dist/decorators/logMethod.decorator.d.ts +1 -1
  38. package/dist/decorators/logMethod.decorator.js +11 -14
  39. package/dist/decorators/memo.decorator.d.ts +3 -3
  40. package/dist/decorators/memo.decorator.js +11 -16
  41. package/dist/decorators/memo.util.d.ts +2 -2
  42. package/dist/decorators/memo.util.js +11 -17
  43. package/dist/decorators/memoFn.d.ts +3 -3
  44. package/dist/decorators/memoFn.js +3 -6
  45. package/dist/decorators/memoFnAsync.d.ts +3 -3
  46. package/dist/decorators/memoFnAsync.js +5 -8
  47. package/dist/decorators/memoSimple.decorator.d.ts +1 -1
  48. package/dist/decorators/memoSimple.decorator.js +6 -10
  49. package/dist/decorators/retry.decorator.d.ts +1 -1
  50. package/dist/decorators/retry.decorator.js +3 -6
  51. package/dist/decorators/swarmSafe.decorator.js +3 -7
  52. package/dist/decorators/timeout.decorator.d.ts +1 -1
  53. package/dist/decorators/timeout.decorator.js +7 -10
  54. package/dist/define.d.ts +1 -1
  55. package/dist/define.js +11 -19
  56. package/dist/deviceIdService.js +7 -11
  57. package/dist/enum.util.d.ts +1 -1
  58. package/dist/enum.util.js +20 -42
  59. package/dist/env/buildInfo.d.ts +1 -1
  60. package/dist/env/buildInfo.js +3 -6
  61. package/dist/env.js +2 -6
  62. package/dist/error/assert.d.ts +3 -3
  63. package/dist/error/assert.js +30 -44
  64. package/dist/error/error.model.d.ts +2 -2
  65. package/dist/error/error.model.js +1 -2
  66. package/dist/error/error.util.d.ts +1 -1
  67. package/dist/error/error.util.js +25 -44
  68. package/dist/error/errorMode.js +2 -5
  69. package/dist/error/try.d.ts +2 -2
  70. package/dist/error/try.js +15 -23
  71. package/dist/error/tryCatch.d.ts +2 -2
  72. package/dist/error/tryCatch.js +6 -11
  73. package/dist/form.util.d.ts +1 -1
  74. package/dist/form.util.js +2 -6
  75. package/dist/http/fetcher.d.ts +3 -3
  76. package/dist/http/fetcher.js +48 -53
  77. package/dist/http/fetcher.model.d.ts +5 -5
  78. package/dist/http/fetcher.model.js +1 -2
  79. package/dist/http/http.model.js +1 -4
  80. package/dist/index.d.ts +96 -96
  81. package/dist/index.js +96 -99
  82. package/dist/is.util.d.ts +2 -2
  83. package/dist/is.util.js +12 -27
  84. package/dist/iter/asyncIterable2.d.ts +3 -3
  85. package/dist/iter/asyncIterable2.js +8 -12
  86. package/dist/iter/iterable2.d.ts +2 -2
  87. package/dist/iter/iterable2.js +8 -12
  88. package/dist/json-schema/from-data/generateJsonSchemaFromData.d.ts +1 -1
  89. package/dist/json-schema/from-data/generateJsonSchemaFromData.js +4 -7
  90. package/dist/json-schema/jsonSchema.cnst.d.ts +1 -1
  91. package/dist/json-schema/jsonSchema.cnst.js +1 -4
  92. package/dist/json-schema/jsonSchema.model.d.ts +1 -1
  93. package/dist/json-schema/jsonSchema.model.js +1 -2
  94. package/dist/json-schema/jsonSchema.util.d.ts +2 -2
  95. package/dist/json-schema/jsonSchema.util.js +5 -8
  96. package/dist/json-schema/jsonSchemaBuilder.d.ts +2 -2
  97. package/dist/json-schema/jsonSchemaBuilder.js +16 -25
  98. package/dist/json-schema/jsonSchemas.d.ts +2 -2
  99. package/dist/json-schema/jsonSchemas.js +5 -8
  100. package/dist/log/commonLogger.js +14 -21
  101. package/dist/math/accumulatingAverage.js +1 -5
  102. package/dist/math/math.util.js +11 -19
  103. package/dist/math/sma.js +1 -5
  104. package/dist/math/stack.util.js +11 -16
  105. package/dist/nanoid.js +2 -6
  106. package/dist/number/createDeterministicRandom.js +1 -4
  107. package/dist/number/number.util.d.ts +1 -1
  108. package/dist/number/number.util.js +9 -20
  109. package/dist/object/deepEquals.js +3 -8
  110. package/dist/object/map2.js +1 -5
  111. package/dist/object/object.util.d.ts +2 -2
  112. package/dist/object/object.util.js +40 -70
  113. package/dist/object/set2.js +1 -5
  114. package/dist/object/sortObject.d.ts +1 -1
  115. package/dist/object/sortObject.js +1 -4
  116. package/dist/object/sortObjectDeep.js +1 -4
  117. package/dist/polyfill.js +1 -4
  118. package/dist/promise/abortable.d.ts +1 -1
  119. package/dist/promise/abortable.js +2 -7
  120. package/dist/promise/pDefer.js +1 -4
  121. package/dist/promise/pDelay.d.ts +2 -2
  122. package/dist/promise/pDelay.js +4 -8
  123. package/dist/promise/pFilter.d.ts +1 -1
  124. package/dist/promise/pFilter.js +1 -4
  125. package/dist/promise/pHang.js +1 -4
  126. package/dist/promise/pMap.d.ts +2 -2
  127. package/dist/promise/pMap.js +17 -20
  128. package/dist/promise/pProps.js +1 -4
  129. package/dist/promise/pQueue.d.ts +2 -2
  130. package/dist/promise/pQueue.js +7 -11
  131. package/dist/promise/pRetry.d.ts +1 -1
  132. package/dist/promise/pRetry.js +8 -12
  133. package/dist/promise/pState.js +1 -4
  134. package/dist/promise/pTimeout.d.ts +3 -3
  135. package/dist/promise/pTimeout.js +7 -11
  136. package/dist/semver.d.ts +1 -1
  137. package/dist/semver.js +13 -18
  138. package/dist/string/case.js +9 -14
  139. package/dist/string/escape.js +2 -6
  140. package/dist/string/hash.util.d.ts +1 -1
  141. package/dist/string/hash.util.js +4 -10
  142. package/dist/string/json.util.d.ts +1 -1
  143. package/dist/string/json.util.js +5 -10
  144. package/dist/string/leven.js +1 -4
  145. package/dist/string/lodash/unicodeWords.js +1 -4
  146. package/dist/string/lodash/words.js +3 -6
  147. package/dist/string/pupa.d.ts +1 -1
  148. package/dist/string/pupa.js +4 -9
  149. package/dist/string/readingTime.d.ts +1 -1
  150. package/dist/string/readingTime.js +1 -4
  151. package/dist/string/regex.js +1 -4
  152. package/dist/string/safeJsonStringify.d.ts +1 -1
  153. package/dist/string/safeJsonStringify.js +1 -4
  154. package/dist/string/slugify.js +1 -4
  155. package/dist/string/string.util.js +15 -32
  156. package/dist/string/stringify.d.ts +1 -1
  157. package/dist/string/stringify.js +10 -14
  158. package/dist/string/url.util.d.ts +1 -1
  159. package/dist/string/url.util.js +2 -6
  160. package/dist/time/time.util.d.ts +1 -1
  161. package/dist/time/time.util.js +3 -8
  162. package/dist/typeFest.js +1 -2
  163. package/dist/types.d.ts +7 -3
  164. package/dist/types.js +21 -23
  165. package/dist/unit/size.util.js +5 -12
  166. package/dist/web.d.ts +1 -1
  167. package/dist/web.js +1 -5
  168. package/dist/zod/index.d.ts +2 -2
  169. package/dist/zod/index.js +4 -10
  170. package/dist/zod/zod.shared.schemas.js +36 -39
  171. package/dist/zod/zod.util.js +7 -14
  172. package/package.json +7 -8
  173. package/src/array/array.util.ts +3 -3
  174. package/src/array/range.ts +2 -2
  175. package/src/bot.ts +1 -1
  176. package/src/browser/adminService.ts +4 -4
  177. package/src/browser/analytics.util.ts +1 -1
  178. package/src/browser/i18n/fetchTranslationLoader.ts +3 -3
  179. package/src/browser/i18n/translation.service.ts +2 -2
  180. package/src/browser/script.util.ts +2 -2
  181. package/src/datetime/dateInterval.ts +3 -3
  182. package/src/datetime/localDate.ts +5 -5
  183. package/src/datetime/localTime.ts +6 -6
  184. package/src/datetime/timeInterval.ts +3 -3
  185. package/src/datetime/wallTime.ts +4 -4
  186. package/src/decorators/asyncMemo.decorator.ts +7 -7
  187. package/src/decorators/createPromiseDecorator.ts +1 -1
  188. package/src/decorators/debounce.decorator.ts +2 -2
  189. package/src/decorators/debounce.ts +1 -1
  190. package/src/decorators/decorator.util.ts +1 -1
  191. package/src/decorators/logMethod.decorator.ts +4 -4
  192. package/src/decorators/memo.decorator.ts +7 -7
  193. package/src/decorators/memo.util.ts +4 -4
  194. package/src/decorators/memoFn.ts +4 -4
  195. package/src/decorators/memoFnAsync.ts +5 -5
  196. package/src/decorators/memoSimple.decorator.ts +4 -4
  197. package/src/decorators/retry.decorator.ts +2 -2
  198. package/src/decorators/swarmSafe.decorator.ts +2 -2
  199. package/src/decorators/timeout.decorator.ts +4 -4
  200. package/src/define.ts +3 -3
  201. package/src/deviceIdService.ts +3 -3
  202. package/src/enum.util.ts +1 -1
  203. package/src/env/buildInfo.ts +2 -2
  204. package/src/error/assert.ts +7 -7
  205. package/src/error/error.model.ts +2 -2
  206. package/src/error/error.util.ts +5 -5
  207. package/src/error/try.ts +5 -5
  208. package/src/error/tryCatch.ts +3 -3
  209. package/src/form.util.ts +1 -1
  210. package/src/http/fetcher.model.ts +5 -5
  211. package/src/http/fetcher.ts +20 -15
  212. package/src/index.ts +96 -96
  213. package/src/is.util.ts +2 -2
  214. package/src/iter/asyncIterable2.ts +3 -3
  215. package/src/iter/iterable2.ts +2 -2
  216. package/src/json-schema/from-data/generateJsonSchemaFromData.ts +2 -2
  217. package/src/json-schema/jsonSchema.cnst.ts +1 -1
  218. package/src/json-schema/jsonSchema.model.ts +1 -1
  219. package/src/json-schema/jsonSchema.util.ts +4 -4
  220. package/src/json-schema/jsonSchemaBuilder.ts +5 -5
  221. package/src/json-schema/jsonSchemas.ts +2 -2
  222. package/src/math/math.util.ts +2 -2
  223. package/src/math/stack.util.ts +1 -1
  224. package/src/number/number.util.ts +1 -1
  225. package/src/object/object.util.ts +3 -3
  226. package/src/object/sortObject.ts +1 -1
  227. package/src/promise/abortable.ts +1 -1
  228. package/src/promise/pDelay.ts +3 -3
  229. package/src/promise/pFilter.ts +1 -1
  230. package/src/promise/pMap.ts +2 -2
  231. package/src/promise/pQueue.ts +4 -4
  232. package/src/promise/pRetry.ts +2 -2
  233. package/src/promise/pTimeout.ts +4 -4
  234. package/src/semver.ts +3 -3
  235. package/src/string/case.ts +2 -2
  236. package/src/string/hash.util.ts +1 -1
  237. package/src/string/json.util.ts +2 -2
  238. package/src/string/lodash/words.ts +1 -1
  239. package/src/string/pupa.ts +2 -2
  240. package/src/string/readingTime.ts +1 -1
  241. package/src/string/safeJsonStringify.ts +1 -1
  242. package/src/string/stringify.ts +4 -4
  243. package/src/string/url.util.ts +1 -1
  244. package/src/time/time.util.ts +1 -1
  245. package/src/types.ts +15 -3
  246. package/src/web.ts +1 -1
  247. package/src/zod/index.ts +2 -2
  248. package/src/zod/zod.util.ts +1 -1
  249. package/dist-esm/abort.js +0 -12
  250. package/dist-esm/array/array.util.js +0 -458
  251. package/dist-esm/array/range.js +0 -34
  252. package/dist-esm/bot.js +0 -130
  253. package/dist-esm/browser/adminService.js +0 -94
  254. package/dist-esm/browser/analytics.util.js +0 -54
  255. package/dist-esm/browser/i18n/fetchTranslationLoader.js +0 -13
  256. package/dist-esm/browser/i18n/translation.service.js +0 -56
  257. package/dist-esm/browser/imageFitter.js +0 -65
  258. package/dist-esm/browser/script.util.js +0 -46
  259. package/dist-esm/browser/topbar.js +0 -135
  260. package/dist-esm/datetime/dateInterval.js +0 -80
  261. package/dist-esm/datetime/localDate.js +0 -719
  262. package/dist-esm/datetime/localTime.js +0 -996
  263. package/dist-esm/datetime/timeInterval.js +0 -88
  264. package/dist-esm/datetime/wallTime.js +0 -70
  265. package/dist-esm/decorators/asyncMemo.decorator.js +0 -111
  266. package/dist-esm/decorators/createPromiseDecorator.js +0 -82
  267. package/dist-esm/decorators/debounce.decorator.js +0 -17
  268. package/dist-esm/decorators/debounce.js +0 -114
  269. package/dist-esm/decorators/decorator.util.js +0 -31
  270. package/dist-esm/decorators/logMethod.decorator.js +0 -85
  271. package/dist-esm/decorators/memo.decorator.js +0 -80
  272. package/dist-esm/decorators/memo.util.js +0 -97
  273. package/dist-esm/decorators/memoFn.js +0 -29
  274. package/dist-esm/decorators/memoFnAsync.js +0 -35
  275. package/dist-esm/decorators/memoSimple.decorator.js +0 -55
  276. package/dist-esm/decorators/retry.decorator.js +0 -9
  277. package/dist-esm/decorators/swarmSafe.decorator.js +0 -38
  278. package/dist-esm/decorators/timeout.decorator.js +0 -19
  279. package/dist-esm/define.js +0 -109
  280. package/dist-esm/deviceIdService.js +0 -105
  281. package/dist-esm/enum.util.js +0 -157
  282. package/dist-esm/env/buildInfo.js +0 -19
  283. package/dist-esm/env.js +0 -19
  284. package/dist-esm/error/assert.js +0 -122
  285. package/dist-esm/error/error.model.js +0 -1
  286. package/dist-esm/error/error.util.js +0 -337
  287. package/dist-esm/error/errorMode.js +0 -20
  288. package/dist-esm/error/try.js +0 -105
  289. package/dist-esm/error/tryCatch.js +0 -41
  290. package/dist-esm/form.util.js +0 -16
  291. package/dist-esm/http/fetcher.js +0 -704
  292. package/dist-esm/http/fetcher.model.js +0 -3
  293. package/dist-esm/http/http.model.js +0 -1
  294. package/dist-esm/index.js +0 -96
  295. package/dist-esm/is.util.js +0 -70
  296. package/dist-esm/iter/asyncIterable2.js +0 -103
  297. package/dist-esm/iter/iterable2.js +0 -87
  298. package/dist-esm/json-schema/from-data/generateJsonSchemaFromData.js +0 -86
  299. package/dist-esm/json-schema/jsonSchema.cnst.js +0 -38
  300. package/dist-esm/json-schema/jsonSchema.model.js +0 -1
  301. package/dist-esm/json-schema/jsonSchema.util.js +0 -27
  302. package/dist-esm/json-schema/jsonSchemaBuilder.js +0 -352
  303. package/dist-esm/json-schema/jsonSchemas.js +0 -6
  304. package/dist-esm/log/commonLogger.js +0 -78
  305. package/dist-esm/math/accumulatingAverage.js +0 -32
  306. package/dist-esm/math/math.util.js +0 -85
  307. package/dist-esm/math/sma.js +0 -43
  308. package/dist-esm/math/stack.util.js +0 -82
  309. package/dist-esm/nanoid.js +0 -57
  310. package/dist-esm/number/createDeterministicRandom.js +0 -18
  311. package/dist-esm/number/number.util.js +0 -109
  312. package/dist-esm/object/deepEquals.js +0 -170
  313. package/dist-esm/object/map2.js +0 -21
  314. package/dist-esm/object/object.util.js +0 -435
  315. package/dist-esm/object/set2.js +0 -15
  316. package/dist-esm/object/sortObject.js +0 -21
  317. package/dist-esm/object/sortObjectDeep.js +0 -17
  318. package/dist-esm/polyfill.js +0 -6
  319. package/dist-esm/promise/abortable.js +0 -31
  320. package/dist-esm/promise/pDefer.js +0 -17
  321. package/dist-esm/promise/pDelay.js +0 -37
  322. package/dist-esm/promise/pFilter.js +0 -5
  323. package/dist-esm/promise/pHang.js +0 -6
  324. package/dist-esm/promise/pMap.js +0 -174
  325. package/dist-esm/promise/pProps.js +0 -20
  326. package/dist-esm/promise/pQueue.js +0 -101
  327. package/dist-esm/promise/pRetry.js +0 -64
  328. package/dist-esm/promise/pState.js +0 -14
  329. package/dist-esm/promise/pTimeout.js +0 -64
  330. package/dist-esm/semver.js +0 -149
  331. package/dist-esm/string/case.js +0 -24
  332. package/dist-esm/string/escape.js +0 -49
  333. package/dist-esm/string/hash.util.js +0 -67
  334. package/dist-esm/string/json.util.js +0 -46
  335. package/dist-esm/string/leven.js +0 -77
  336. package/dist-esm/string/lodash/unicodeWords.js +0 -68
  337. package/dist-esm/string/lodash/words.js +0 -31
  338. package/dist-esm/string/pupa.js +0 -54
  339. package/dist-esm/string/readingTime.js +0 -102
  340. package/dist-esm/string/regex.js +0 -6
  341. package/dist-esm/string/safeJsonStringify.js +0 -39
  342. package/dist-esm/string/slugify.js +0 -66
  343. package/dist-esm/string/string.util.js +0 -99
  344. package/dist-esm/string/stringify.js +0 -133
  345. package/dist-esm/string/url.util.js +0 -42
  346. package/dist-esm/time/time.util.js +0 -61
  347. package/dist-esm/typeFest.js +0 -2
  348. package/dist-esm/types.js +0 -59
  349. package/dist-esm/unit/size.util.js +0 -43
  350. package/dist-esm/web.js +0 -40
  351. package/dist-esm/zod/index.js +0 -4
  352. package/dist-esm/zod/zod.shared.schemas.js +0 -92
  353. package/dist-esm/zod/zod.util.js +0 -52
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.localTime = exports.LocalTime = exports.VALID_DAYS_OF_WEEK = exports.ISODayOfWeek = void 0;
4
- const assert_1 = require("../error/assert");
5
- const time_util_1 = require("../time/time.util");
6
- const localDate_1 = require("./localDate");
7
- const wallTime_1 = require("./wallTime");
8
- var ISODayOfWeek;
1
+ import { _assert } from '../error/assert.js';
2
+ import { _ms } from '../time/time.util.js';
3
+ import { localDate } from './localDate.js';
4
+ import { WallTime } from './wallTime.js';
5
+ export var ISODayOfWeek;
9
6
  (function (ISODayOfWeek) {
10
7
  ISODayOfWeek[ISODayOfWeek["MONDAY"] = 1] = "MONDAY";
11
8
  ISODayOfWeek[ISODayOfWeek["TUESDAY"] = 2] = "TUESDAY";
@@ -14,13 +11,13 @@ var ISODayOfWeek;
14
11
  ISODayOfWeek[ISODayOfWeek["FRIDAY"] = 5] = "FRIDAY";
15
12
  ISODayOfWeek[ISODayOfWeek["SATURDAY"] = 6] = "SATURDAY";
16
13
  ISODayOfWeek[ISODayOfWeek["SUNDAY"] = 7] = "SUNDAY";
17
- })(ISODayOfWeek || (exports.ISODayOfWeek = ISODayOfWeek = {}));
14
+ })(ISODayOfWeek || (ISODayOfWeek = {}));
18
15
  const weekStartsOn = 1; // mon, as per ISO
19
16
  const MILLISECONDS_IN_WEEK = 604800000;
20
17
  const SECONDS_IN_DAY = 86400;
21
18
  // const MILLISECONDS_IN_DAY = 86400000
22
19
  // const MILLISECONDS_IN_MINUTE = 60000
23
- exports.VALID_DAYS_OF_WEEK = new Set([1, 2, 3, 4, 5, 6, 7]);
20
+ export const VALID_DAYS_OF_WEEK = new Set([1, 2, 3, 4, 5, 6, 7]);
24
21
  /**
25
22
  * It supports 2 forms:
26
23
  * 1. 2023-03-03
@@ -36,7 +33,7 @@ const DATE_TIME_REGEX_LOOSE = /^(\d{4})-(\d{2})-(\d{2})([Tt\s](\d{2}):?(\d{2})?:
36
33
  */
37
34
  const DATE_TIME_REGEX_STRICT = /^(\d{4})-(\d{2})-(\d{2})[Tt\s](\d{2}):(\d{2}):(\d{2})/;
38
35
  const DATE_REGEX_STRICT = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
39
- class LocalTime {
36
+ export class LocalTime {
40
37
  $date;
41
38
  constructor($date) {
42
39
  this.$date = $date;
@@ -71,7 +68,7 @@ class LocalTime {
71
68
  */
72
69
  inTimezone(tz) {
73
70
  const d = new Date(this.$date.toLocaleString('en-US', { timeZone: tz }));
74
- return new wallTime_1.WallTime({
71
+ return new WallTime({
75
72
  year: d.getFullYear(),
76
73
  month: d.getMonth() + 1,
77
74
  day: d.getDate(),
@@ -228,7 +225,7 @@ class LocalTime {
228
225
  * relation to `this`.
229
226
  */
230
227
  setDayOfWeek(dow) {
231
- (0, assert_1._assert)(exports.VALID_DAYS_OF_WEEK.has(dow), `Invalid dayOfWeek: ${dow}`);
228
+ _assert(VALID_DAYS_OF_WEEK.has(dow), `Invalid dayOfWeek: ${dow}`);
232
229
  const delta = dow - this.dayOfWeek;
233
230
  return this.plus(delta, 'day');
234
231
  }
@@ -238,7 +235,7 @@ class LocalTime {
238
235
  * If this LocalTime is Monday, and desired DoW is also Monday - `this` is returned.
239
236
  */
240
237
  setNextDayOfWeek(dow) {
241
- (0, assert_1._assert)(exports.VALID_DAYS_OF_WEEK.has(dow), `Invalid dayOfWeek: ${dow}`);
238
+ _assert(VALID_DAYS_OF_WEEK.has(dow), `Invalid dayOfWeek: ${dow}`);
242
239
  let delta = dow - this.dayOfWeek;
243
240
  if (delta < 0)
244
241
  delta += 7;
@@ -310,7 +307,7 @@ class LocalTime {
310
307
  }
311
308
  if (unit === 'year' || unit === 'month') {
312
309
  const d = addMonths(this.$date, unit === 'month' ? num : num * 12, mutate);
313
- return mutate ? this : exports.localTime.fromInput(d);
310
+ return mutate ? this : localTime.fromInput(d);
314
311
  }
315
312
  return this.set(unit, this.get(unit) + num, mutate);
316
313
  }
@@ -321,7 +318,7 @@ class LocalTime {
321
318
  return Math.abs(this.diff(other, unit));
322
319
  }
323
320
  diff(other, unit) {
324
- const date2 = exports.localTime.fromInput(other).$date;
321
+ const date2 = localTime.fromInput(other).$date;
325
322
  const secDiff = (this.$date.valueOf() - date2.valueOf()) / 1000;
326
323
  if (!secDiff)
327
324
  return 0;
@@ -397,7 +394,7 @@ class LocalTime {
397
394
  }
398
395
  else {
399
396
  // year or month
400
- const lastDay = localDate_1.localDate.getMonthLength(d.getFullYear(), d.getMonth() + 1);
397
+ const lastDay = localDate.getMonthLength(d.getFullYear(), d.getMonth() + 1);
401
398
  d.setDate(lastDay);
402
399
  }
403
400
  }
@@ -410,7 +407,7 @@ class LocalTime {
410
407
  * E.g 31 for January.
411
408
  */
412
409
  get daysInMonth() {
413
- return localDate_1.localDate.getMonthLength(this.$date.getFullYear(), this.$date.getMonth() + 1);
410
+ return localDate.getMonthLength(this.$date.getFullYear(), this.$date.getMonth() + 1);
414
411
  }
415
412
  isSame(d) {
416
413
  return this.compare(d) === 0;
@@ -449,13 +446,13 @@ class LocalTime {
449
446
  * Third argument allows to override "now".
450
447
  */
451
448
  isOlderThan(n, unit, now) {
452
- return this.isBefore(exports.localTime.fromInput(now ?? new Date()).plus(-n, unit));
449
+ return this.isBefore(localTime.fromInput(now ?? new Date()).plus(-n, unit));
453
450
  }
454
451
  /**
455
452
  * Checks if this localTime is same or older (<=) than "now" by X units.
456
453
  */
457
454
  isSameOrOlderThan(n, unit, now) {
458
- return this.isSameOrBefore(exports.localTime.fromInput(now ?? new Date()).plus(-n, unit));
455
+ return this.isSameOrBefore(localTime.fromInput(now ?? new Date()).plus(-n, unit));
459
456
  }
460
457
  /**
461
458
  * Checks if this localTime is younger (>) than "now" by X units.
@@ -467,13 +464,13 @@ class LocalTime {
467
464
  * Third argument allows to override "now".
468
465
  */
469
466
  isYoungerThan(n, unit, now) {
470
- return this.isAfter(exports.localTime.fromInput(now ?? new Date()).plus(-n, unit));
467
+ return this.isAfter(localTime.fromInput(now ?? new Date()).plus(-n, unit));
471
468
  }
472
469
  /**
473
470
  * Checks if this localTime is same or younger (>=) than "now" by X units.
474
471
  */
475
472
  isSameOrYoungerThan(n, unit, now) {
476
- return this.isSameOrAfter(exports.localTime.fromInput(now ?? new Date()).plus(-n, unit));
473
+ return this.isSameOrAfter(localTime.fromInput(now ?? new Date()).plus(-n, unit));
477
474
  }
478
475
  getAgeInYears(now) {
479
476
  return this.getAgeIn('year', now);
@@ -494,7 +491,7 @@ class LocalTime {
494
491
  return this.getAgeIn('second', now);
495
492
  }
496
493
  getAgeIn(unit, now) {
497
- return exports.localTime.fromInput(now ?? new Date()).diff(this, unit);
494
+ return localTime.fromInput(now ?? new Date()).diff(this, unit);
498
495
  }
499
496
  isAfterNow() {
500
497
  return this.$date.valueOf() > Date.now();
@@ -509,7 +506,7 @@ class LocalTime {
509
506
  */
510
507
  compare(d) {
511
508
  const t1 = this.$date.valueOf();
512
- const t2 = exports.localTime.fromInput(d).$date.valueOf();
509
+ const t2 = localTime.fromInput(d).$date.valueOf();
513
510
  if (t1 === t2)
514
511
  return 0;
515
512
  return t1 < t2 ? -1 : 1;
@@ -535,13 +532,13 @@ class LocalTime {
535
532
  };
536
533
  }
537
534
  toFromNowString(now = new Date()) {
538
- const msDiff = exports.localTime.fromInput(now).$date.valueOf() - this.$date.valueOf();
535
+ const msDiff = localTime.fromInput(now).$date.valueOf() - this.$date.valueOf();
539
536
  if (msDiff === 0)
540
537
  return 'now';
541
538
  if (msDiff >= 0) {
542
- return `${(0, time_util_1._ms)(msDiff)} ago`;
539
+ return `${_ms(msDiff)} ago`;
543
540
  }
544
- return `in ${(0, time_util_1._ms)(msDiff * -1)}`;
541
+ return `in ${_ms(msDiff * -1)}`;
545
542
  }
546
543
  toDate() {
547
544
  return this.$date;
@@ -559,7 +556,7 @@ class LocalTime {
559
556
  return Math.floor(this.$date.valueOf() / 1000);
560
557
  }
561
558
  toLocalDate() {
562
- return localDate_1.localDate.fromDate(this.$date);
559
+ return localDate.fromDate(this.$date);
563
560
  }
564
561
  /**
565
562
  * Returns e.g: `1984-06-21 17:56:21`
@@ -609,7 +606,7 @@ class LocalTime {
609
606
  // return this.$date.toISOString().slice(11, seconds ? 19 : 16)
610
607
  }
611
608
  toWallTime() {
612
- return new wallTime_1.WallTime(this.toDateTimeObject());
609
+ return new WallTime(this.toDateTimeObject());
613
610
  }
614
611
  /**
615
612
  * Returns e.g: `19840621_1705`
@@ -642,7 +639,6 @@ class LocalTime {
642
639
  return fmt(this);
643
640
  }
644
641
  }
645
- exports.LocalTime = LocalTime;
646
642
  class LocalTimeFactory {
647
643
  /**
648
644
  * Creates a LocalTime from the input, unless it's falsy - then returns undefined.
@@ -742,7 +738,7 @@ class LocalTimeFactory {
742
738
  */
743
739
  fromIsoDateTimeString(s) {
744
740
  const d = this.parseStrictlyOrUndefined(s);
745
- (0, assert_1._assert)(d, `Cannot parse "${s}" into LocalTime`);
741
+ _assert(d, `Cannot parse "${s}" into LocalTime`);
746
742
  return new LocalTime(d);
747
743
  }
748
744
  /**
@@ -753,7 +749,7 @@ class LocalTimeFactory {
753
749
  */
754
750
  parse(s) {
755
751
  const d = this.parseLooselyOrUndefined(String(s));
756
- (0, assert_1._assert)(d, `Cannot parse "${s}" into LocalTime`);
752
+ _assert(d, `Cannot parse "${s}" into LocalTime`);
757
753
  return new LocalTime(d);
758
754
  }
759
755
  parseStrictlyOrUndefined(s) {
@@ -806,16 +802,16 @@ class LocalTimeFactory {
806
802
  * Throws on invalid value.
807
803
  */
808
804
  validateDateTimeObject(o) {
809
- (0, assert_1._assert)(this.isDateTimeObjectValid(o), `Cannot construct LocalTime from: ${o.year}-${o.month}-${o.day} ${o.hour}:${o.minute}:${o.second}`);
805
+ _assert(this.isDateTimeObjectValid(o), `Cannot construct LocalTime from: ${o.year}-${o.month}-${o.day} ${o.hour}:${o.minute}:${o.second}`);
810
806
  }
811
807
  isDateTimeObjectValid(o) {
812
- return localDate_1.localDate.isDateObjectValid(o) && this.isTimeObjectValid(o);
808
+ return localDate.isDateObjectValid(o) && this.isTimeObjectValid(o);
813
809
  }
814
810
  isTimeObjectValid({ hour, minute, second }) {
815
811
  return hour >= 0 && hour <= 23 && minute >= 0 && minute <= 59 && second >= 0 && second <= 59;
816
812
  }
817
813
  fromDate(date) {
818
- (0, assert_1._assert)(!Number.isNaN(date.getDate()), 'localTime.fromDate is called on Date object that is invalid');
814
+ _assert(!Number.isNaN(date.getDate()), 'localTime.fromDate is called on Date object that is invalid');
819
815
  return new LocalTime(date);
820
816
  }
821
817
  fromUnix(ts) {
@@ -885,7 +881,7 @@ class LocalTimeFactory {
885
881
  }
886
882
  min(items) {
887
883
  const min = this.minOrUndefined(items);
888
- (0, assert_1._assert)(min, 'localTime.min called on empty array');
884
+ _assert(min, 'localTime.min called on empty array');
889
885
  return min;
890
886
  }
891
887
  maxOrUndefined(items) {
@@ -902,7 +898,7 @@ class LocalTimeFactory {
902
898
  }
903
899
  max(items) {
904
900
  const max = this.maxOrUndefined(items);
905
- (0, assert_1._assert)(max, 'localTime.max called on empty array');
901
+ _assert(max, 'localTime.max called on empty array');
906
902
  return max;
907
903
  }
908
904
  }
@@ -979,7 +975,7 @@ function addMonths(d, num, mutate = false) {
979
975
  year--;
980
976
  month += 12;
981
977
  }
982
- const monthLen = localDate_1.localDate.getMonthLength(year, month);
978
+ const monthLen = localDate.getMonthLength(year, month);
983
979
  if (day > monthLen)
984
980
  day = monthLen;
985
981
  d.setFullYear(year, month - 1, day);
@@ -995,7 +991,7 @@ function differenceInMonths(a, b) {
995
991
  return -(wholeMonthDiff + ((b.getTime() - anchor) / (anchor2 - anchor)) * sign);
996
992
  }
997
993
  const localTimeFactory = new LocalTimeFactory();
998
- exports.localTime = localTimeFactory.fromInput.bind(localTimeFactory);
994
+ export const localTime = localTimeFactory.fromInput.bind(localTimeFactory);
999
995
  // The line below is the blackest of black magic I have ever written in 2024.
1000
996
  // And probably 2023 as well.
1001
- Object.setPrototypeOf(exports.localTime, localTimeFactory);
997
+ Object.setPrototypeOf(localTime, localTimeFactory);
@@ -1,5 +1,5 @@
1
- import type { Inclusiveness, UnixTimestamp } from '../types';
2
- import type { LocalTime, LocalTimeInput } from './localTime';
1
+ import type { Inclusiveness, UnixTimestamp } from '../types.js';
2
+ import type { LocalTime, LocalTimeInput } from './localTime.js';
3
3
  export type TimeIntervalConfig = TimeInterval | TimeIntervalString;
4
4
  export type TimeIntervalString = string;
5
5
  /**
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TimeInterval = void 0;
4
- const localTime_1 = require("./localTime");
1
+ import { localTime } from './localTime.js';
5
2
  /**
6
3
  * Class that supports an "interval of time" between 2 timestamps - start and end.
7
4
  * Example: `1649267185/1649267187`.
8
5
  *
9
6
  * @experimental
10
7
  */
11
- class TimeInterval {
8
+ export class TimeInterval {
12
9
  $start;
13
10
  $end;
14
11
  constructor($start, $end) {
@@ -16,7 +13,7 @@ class TimeInterval {
16
13
  this.$end = $end;
17
14
  }
18
15
  static of(start, end) {
19
- return new TimeInterval(localTime_1.localTime.fromInput(start).unix, localTime_1.localTime.fromInput(end).unix);
16
+ return new TimeInterval(localTime.fromInput(start).unix, localTime.fromInput(end).unix);
20
17
  }
21
18
  get start() {
22
19
  return this.$start;
@@ -25,10 +22,10 @@ class TimeInterval {
25
22
  return this.$end;
26
23
  }
27
24
  get startTime() {
28
- return (0, localTime_1.localTime)(this.$start);
25
+ return localTime(this.$start);
29
26
  }
30
27
  get endTime() {
31
- return (0, localTime_1.localTime)(this.$end);
28
+ return localTime(this.$end);
32
29
  }
33
30
  /**
34
31
  * Parses string like `1649267185/1649267187` into a TimeInterval.
@@ -60,7 +57,7 @@ class TimeInterval {
60
57
  return this.cmp(d) >= 0;
61
58
  }
62
59
  includes(d, incl = '[)') {
63
- d = localTime_1.localTime.fromInput(d).unix;
60
+ d = localTime.fromInput(d).unix;
64
61
  // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
65
62
  if (d < this.$start || (d === this.$start && incl[0] === '('))
66
63
  return false;
@@ -91,4 +88,3 @@ class TimeInterval {
91
88
  return this.toString();
92
89
  }
93
90
  }
94
- exports.TimeInterval = TimeInterval;
@@ -1,6 +1,6 @@
1
- import type { IsoDate, IsoDateTime } from '../types';
2
- import { LocalDate } from './localDate';
3
- import type { DateTimeObject, LocalTime } from './localTime';
1
+ import type { IsoDate, IsoDateTime } from '../types.js';
2
+ import { LocalDate } from './localDate.js';
3
+ import type { DateTimeObject, LocalTime } from './localTime.js';
4
4
  /**
5
5
  * Representation of a "time on the wall clock",
6
6
  * which means "local time, regardless of timezone".
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WallTime = void 0;
4
- const localDate_1 = require("./localDate");
5
- const localTime_1 = require("./localTime");
1
+ import { LocalDate } from './localDate.js';
2
+ import { localTime } from './localTime.js';
6
3
  /**
7
4
  * Representation of a "time on the wall clock",
8
5
  * which means "local time, regardless of timezone".
@@ -12,7 +9,7 @@ const localTime_1 = require("./localTime");
12
9
  * No math or manipulation is possible here.
13
10
  * Can be pretty-printed as Date, Time or DateAndTime.
14
11
  */
15
- class WallTime {
12
+ export class WallTime {
16
13
  year;
17
14
  month;
18
15
  day;
@@ -23,7 +20,7 @@ class WallTime {
23
20
  Object.assign(this, obj);
24
21
  }
25
22
  toLocalDate() {
26
- return new localDate_1.LocalDate(this.year, this.month, this.day);
23
+ return new LocalDate(this.year, this.month, this.day);
27
24
  }
28
25
  /**
29
26
  * Example:
@@ -32,7 +29,7 @@ class WallTime {
32
29
  * holding that time in the local timezone.
33
30
  */
34
31
  toLocalTime() {
35
- return localTime_1.localTime.fromDateTimeObject(this);
32
+ return localTime.fromDateTimeObject(this);
36
33
  }
37
34
  toJSON() {
38
35
  return this.toISODateTime();
@@ -77,4 +74,3 @@ class WallTime {
77
74
  .join(':');
78
75
  }
79
76
  }
80
- exports.WallTime = WallTime;
@@ -1,6 +1,6 @@
1
- import type { CommonLogger } from '../log/commonLogger';
2
- import type { AnyAsyncFunction, AnyFunction, AnyObject, MaybeParameters } from '../types';
3
- import type { AsyncMemoCache, MethodDecorator } from './memo.util';
1
+ import type { CommonLogger } from '../log/commonLogger.js';
2
+ import type { AnyAsyncFunction, AnyFunction, AnyObject, MaybeParameters } from '../types.js';
3
+ import type { AsyncMemoCache, MethodDecorator } from './memo.util.js';
4
4
  export interface AsyncMemoOptions<FN> {
5
5
  /**
6
6
  * Provide a custom implementation of AsyncMemoCache.
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._AsyncMemo = void 0;
4
- exports._getAsyncMemo = _getAsyncMemo;
5
- const assert_1 = require("../error/assert");
6
- const types_1 = require("../types");
7
- const decorator_util_1 = require("./decorator.util");
8
- const memo_util_1 = require("./memo.util");
1
+ import { _assert, _assertTypeOf } from '../error/assert.js';
2
+ import { _objectAssign, MISS } from '../types.js';
3
+ import { _getTargetMethodSignature } from './decorator.util.js';
4
+ import { jsonMemoSerializer } from './memo.util.js';
9
5
  /**
10
6
  * Like @_Memo, but allowing async MemoCache implementation.
11
7
  *
@@ -15,8 +11,8 @@ const memo_util_1 = require("./memo.util");
15
11
  * @experimental consider normal @_Memo for most of the cases, it's stable and predictable
16
12
  */
17
13
  // eslint-disable-next-line @typescript-eslint/naming-convention
18
- const _AsyncMemo = (opt) => (target, key, descriptor) => {
19
- (0, assert_1._assertTypeOf)(descriptor.value, 'function', 'Memoization can be applied only to methods');
14
+ export const _AsyncMemo = (opt) => (target, key, descriptor) => {
15
+ _assertTypeOf(descriptor.value, 'function', 'Memoization can be applied only to methods');
20
16
  const originalFn = descriptor.value;
21
17
  // Map from "instance" of the Class where @_AsyncMemo is applied to AsyncMemoCache instance.
22
18
  const instanceCache = new Map();
@@ -25,9 +21,9 @@ const _AsyncMemo = (opt) => (target, key, descriptor) => {
25
21
  // It only holds values that are "in-flight", until Promise is resolved
26
22
  // After it's resolved - it's evicted from the cache and moved to the "proper" `instanceCache`
27
23
  const instancePromiseCache = new Map();
28
- const { logger = console, cacheFactory, cacheKeyFn = memo_util_1.jsonMemoSerializer } = opt;
24
+ const { logger = console, cacheFactory, cacheKeyFn = jsonMemoSerializer } = opt;
29
25
  const keyStr = String(key);
30
- const methodSignature = (0, decorator_util_1._getTargetMethodSignature)(target, keyStr);
26
+ const methodSignature = _getTargetMethodSignature(target, keyStr);
31
27
  // eslint-disable-next-line @typescript-eslint/promise-function-async
32
28
  descriptor.value = function (...args) {
33
29
  const ctx = this;
@@ -51,7 +47,7 @@ const _AsyncMemo = (opt) => (target, key, descriptor) => {
51
47
  return promise;
52
48
  }
53
49
  promise = cache.get(cacheKey).then(async (value) => {
54
- if (value !== types_1.MISS) {
50
+ if (value !== MISS) {
55
51
  // console.log('hit', promiseCache.size)
56
52
  promiseCache.delete(cacheKey);
57
53
  return value;
@@ -94,7 +90,7 @@ const _AsyncMemo = (opt) => (target, key, descriptor) => {
94
90
  }
95
91
  }
96
92
  };
97
- (0, types_1._objectAssign)(descriptor.value, {
93
+ _objectAssign(descriptor.value, {
98
94
  clear: async () => {
99
95
  logger.log(`${methodSignature} @_AsyncMemo.clear()`);
100
96
  await Promise.all([...instanceCache.values()].map(c => c.clear()));
@@ -105,12 +101,11 @@ const _AsyncMemo = (opt) => (target, key, descriptor) => {
105
101
  });
106
102
  return descriptor;
107
103
  };
108
- exports._AsyncMemo = _AsyncMemo;
109
104
  /**
110
105
  Call it on a method that is decorated with `@_AsyncMemo` to get access to additional functions,
111
106
  e.g `clear` to clear the cache, or get its underlying data.
112
107
  */
113
- function _getAsyncMemo(method) {
114
- (0, assert_1._assert)(typeof method?.getInstanceCache === 'function', 'method is not an AsyncMemo instance');
108
+ export function _getAsyncMemo(method) {
109
+ _assert(typeof method?.getInstanceCache === 'function', 'method is not an AsyncMemo instance');
115
110
  return method;
116
111
  }
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._createPromiseDecorator = _createPromiseDecorator;
4
- const decorator_util_1 = require("./decorator.util");
1
+ import { _getTargetMethodSignature } from './decorator.util.js';
5
2
  /**
6
3
  * @example
7
4
  * // decorators.ts
@@ -13,13 +10,13 @@ const decorator_util_1 = require("./decorator.util");
13
10
  *
14
11
  * @experimental
15
12
  */
16
- function _createPromiseDecorator(cfg, decoratorParams = {}) {
13
+ export function _createPromiseDecorator(cfg, decoratorParams = {}) {
17
14
  const { decoratorName } = cfg;
18
15
  return function decoratorFunction(target, propertyKey, pd) {
19
16
  // console.log(`@Decorator.${cfg.decoratorName} called: ` + propertyKey, pd, target)
20
17
  const originalMethod = pd.value;
21
18
  const key = String(propertyKey);
22
- const methodSignature = (0, decorator_util_1._getTargetMethodSignature)(target, key);
19
+ const methodSignature = _getTargetMethodSignature(target, key);
23
20
  pd.value = async function (...args) {
24
21
  // console.log(`@${cfg.decoratorName} called inside function`)
25
22
  const started = Date.now();
@@ -1,4 +1,4 @@
1
- import type { AnyFunction } from '../types';
1
+ import type { AnyFunction } from '../types.js';
2
2
  export interface Cancelable {
3
3
  cancel: () => void;
4
4
  flush: () => void;
@@ -1,3 +1,3 @@
1
- import type { DebounceOptions, ThrottleOptions } from './debounce';
1
+ import type { DebounceOptions, ThrottleOptions } from './debounce.js';
2
2
  export declare function _Debounce(wait: number, opt?: DebounceOptions): MethodDecorator;
3
3
  export declare function _Throttle(wait: number, opt?: ThrottleOptions): MethodDecorator;
@@ -1,21 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._Debounce = _Debounce;
4
- exports._Throttle = _Throttle;
5
- const debounce_1 = require("./debounce");
1
+ import { _debounce, _throttle } from './debounce.js';
6
2
  // eslint-disable-next-line @typescript-eslint/naming-convention
7
- function _Debounce(wait, opt = {}) {
3
+ export function _Debounce(wait, opt = {}) {
8
4
  return (_target, _key, descriptor) => {
9
5
  const originalFn = descriptor.value;
10
- descriptor.value = (0, debounce_1._debounce)(originalFn, wait, opt);
6
+ descriptor.value = _debounce(originalFn, wait, opt);
11
7
  return descriptor;
12
8
  };
13
9
  }
14
10
  // eslint-disable-next-line @typescript-eslint/naming-convention
15
- function _Throttle(wait, opt = {}) {
11
+ export function _Throttle(wait, opt = {}) {
16
12
  return (_target, _key, descriptor) => {
17
13
  const originalFn = descriptor.value;
18
- descriptor.value = (0, debounce_1._throttle)(originalFn, wait, opt);
14
+ descriptor.value = _throttle(originalFn, wait, opt);
19
15
  return descriptor;
20
16
  };
21
17
  }
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._debounce = _debounce;
4
- exports._throttle = _throttle;
5
- function _debounce(func, wait, opt = {}) {
1
+ export function _debounce(func, wait, opt = {}) {
6
2
  let lastArgs;
7
3
  let lastThis;
8
4
  let result;
@@ -108,7 +104,7 @@ function _debounce(func, wait, opt = {}) {
108
104
  debounced.pending = pending;
109
105
  return debounced;
110
106
  }
111
- function _throttle(func, wait, opt = {}) {
107
+ export function _throttle(func, wait, opt = {}) {
112
108
  return _debounce(func, wait, {
113
109
  leading: true,
114
110
  trailing: true,
@@ -1,4 +1,4 @@
1
- import type { AnyObject } from '../index';
1
+ import type { AnyObject } from '../index.js';
2
2
  /**
3
3
  * @returns
4
4
  * e.g `NameOfYourClass.methodName`
@@ -1,21 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._getMethodSignature = _getMethodSignature;
4
- exports._getTargetMethodSignature = _getTargetMethodSignature;
5
- exports._getArgsSignature = _getArgsSignature;
6
1
  /**
7
2
  * @returns
8
3
  * e.g `NameOfYourClass.methodName`
9
4
  * or `NameOfYourClass(instanceId).methodName`
10
5
  */
11
- function _getMethodSignature(ctx, keyStr) {
6
+ export function _getMethodSignature(ctx, keyStr) {
12
7
  const { instanceId } = ctx;
13
8
  return `${ctx.constructor.name}${instanceId ? `#${instanceId}` : ''}.${keyStr}`;
14
9
  }
15
10
  /**
16
11
  * @returns `NameOfYourClass.methodName`
17
12
  */
18
- function _getTargetMethodSignature(target, keyStr) {
13
+ export function _getTargetMethodSignature(target, keyStr) {
19
14
  return `${target.constructor.name}.${keyStr}`;
20
15
  }
21
16
  /**
@@ -24,7 +19,7 @@ function _getTargetMethodSignature(target, keyStr) {
24
19
  * returns:
25
20
  * a, b, c
26
21
  */
27
- function _getArgsSignature(args = [], logArgs = true) {
22
+ export function _getArgsSignature(args = [], logArgs = true) {
28
23
  if (!logArgs)
29
24
  return '';
30
25
  return args
@@ -1,4 +1,4 @@
1
- import type { CommonLogger } from '..';
1
+ import type { CommonLogger } from '../index.js';
2
2
  /**
3
3
  * $r - result
4
4
  *
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._LogMethod = _LogMethod;
4
- const __1 = require("..");
5
- const time_util_1 = require("../time/time.util");
6
- const decorator_util_1 = require("./decorator.util");
1
+ import { _assert, _stringify, SimpleMovingAverage } from '../index.js';
2
+ import { _ms } from '../time/time.util.js';
3
+ import { _getArgsSignature, _getMethodSignature } from './decorator.util.js';
7
4
  /**
8
5
  * Console-logs when method had started, when it finished, time taken and if error happened.
9
6
  * Supports both sync and async methods.
@@ -18,30 +15,30 @@ const decorator_util_1 = require("./decorator.util");
18
15
  * << asyncMethodThrow() took 10 ms ERROR: MyError
19
16
  */
20
17
  // eslint-disable-next-line @typescript-eslint/naming-convention
21
- function _LogMethod(opt = {}) {
18
+ export function _LogMethod(opt = {}) {
22
19
  return (target, key, descriptor) => {
23
- (0, __1._assert)(typeof descriptor.value === 'function', '@_LogMethod can be applied only to methods');
20
+ _assert(typeof descriptor.value === 'function', '@_LogMethod can be applied only to methods');
24
21
  const originalFn = descriptor.value;
25
22
  const keyStr = String(key);
26
23
  const { avg, logArgs = true, logStart, logResult, logResultLength = true, logger = console, } = opt;
27
24
  let { logResultFn } = opt;
28
25
  if (!logResultFn) {
29
26
  if (logResult) {
30
- logResultFn = r => ['result:', (0, __1._stringify)(r)];
27
+ logResultFn = r => ['result:', _stringify(r)];
31
28
  }
32
29
  else if (logResultLength) {
33
30
  logResultFn = r => (Array.isArray(r) ? [`result: ${r.length} items`] : []);
34
31
  }
35
32
  }
36
- const sma = avg ? new __1.SimpleMovingAverage(avg) : undefined;
33
+ const sma = avg ? new SimpleMovingAverage(avg) : undefined;
37
34
  let count = 0;
38
35
  descriptor.value = function (...args) {
39
36
  const started = Date.now();
40
37
  const ctx = this;
41
38
  // e.g `NameOfYourClass.methodName`
42
39
  // or `NameOfYourClass(instanceId).methodName`
43
- const methodSignature = (0, decorator_util_1._getMethodSignature)(ctx, keyStr);
44
- const argsStr = (0, decorator_util_1._getArgsSignature)(args, logArgs);
40
+ const methodSignature = _getMethodSignature(ctx, keyStr);
41
+ const argsStr = _getArgsSignature(args, logArgs);
45
42
  const callSignature = `${methodSignature}(${argsStr}) #${++count}`;
46
43
  if (logStart)
47
44
  logger.log(`>> ${callSignature}`);
@@ -74,9 +71,9 @@ function _LogMethod(opt = {}) {
74
71
  // eslint-disable-next-line max-params
75
72
  function logFinished(logger, callSignature, started, sma, logResultFn, res, err) {
76
73
  const millis = Date.now() - started;
77
- const t = ['<<', callSignature, 'took', (0, time_util_1._ms)(millis)];
74
+ const t = ['<<', callSignature, 'took', _ms(millis)];
78
75
  if (sma) {
79
- t.push(`(avg ${(0, time_util_1._ms)(sma.pushGetAvg(millis))})`);
76
+ t.push(`(avg ${_ms(sma.pushGetAvg(millis))})`);
80
77
  }
81
78
  if (err !== undefined) {
82
79
  t.push('ERROR:', err);