javascript-time-ago 2.5.11 → 2.6.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 (452) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/README.md +410 -272
  3. package/bundle/javascript-time-ago.js +1 -1
  4. package/bundle/javascript-time-ago.js.map +1 -1
  5. package/bundle/javascript-time-ago.min.js +1 -1
  6. package/bundle/javascript-time-ago.min.js.map +1 -1
  7. package/commonjs/FullDateFormatter.js +72 -0
  8. package/commonjs/FullDateFormatter.js.map +1 -0
  9. package/commonjs/FullDateFormatter.test.js +26 -0
  10. package/commonjs/FullDateFormatter.test.js.map +1 -0
  11. package/commonjs/LocaleDataStore.js +2 -5
  12. package/commonjs/LocaleDataStore.js.map +1 -1
  13. package/commonjs/PropTypes.js +12 -12
  14. package/commonjs/PropTypes.js.map +1 -1
  15. package/commonjs/TimeAgo.js +300 -253
  16. package/commonjs/TimeAgo.js.map +1 -1
  17. package/commonjs/TimeAgo.test.js +214 -135
  18. package/commonjs/TimeAgo.test.js.map +1 -1
  19. package/commonjs/cache.js +7 -25
  20. package/commonjs/cache.js.map +1 -1
  21. package/commonjs/cache.test.js +1 -3
  22. package/commonjs/cache.test.js.map +1 -1
  23. package/commonjs/isStyleObject.js +9 -9
  24. package/commonjs/isStyleObject.js.map +1 -1
  25. package/commonjs/isStyleObject.test.js +1 -3
  26. package/commonjs/isStyleObject.test.js.map +1 -1
  27. package/commonjs/locale.js +6 -19
  28. package/commonjs/locale.js.map +1 -1
  29. package/commonjs/locale.test.js +2 -11
  30. package/commonjs/locale.test.js.map +1 -1
  31. package/commonjs/round.js +2 -5
  32. package/commonjs/round.js.map +1 -1
  33. package/commonjs/steps/approximate.js +1 -4
  34. package/commonjs/steps/approximate.js.map +1 -1
  35. package/commonjs/steps/approximate.test.js +1 -6
  36. package/commonjs/steps/approximate.test.js.map +1 -1
  37. package/commonjs/steps/getStep.js +36 -53
  38. package/commonjs/steps/getStep.js.map +1 -1
  39. package/commonjs/steps/getStep.test.js +7 -7
  40. package/commonjs/steps/getStep.test.js.map +1 -1
  41. package/commonjs/steps/getStepDenominator.js +2 -5
  42. package/commonjs/steps/getStepDenominator.js.map +1 -1
  43. package/commonjs/steps/getStepDenominator.test.js +1 -3
  44. package/commonjs/steps/getStepDenominator.test.js.map +1 -1
  45. package/commonjs/steps/getStepMinTime.js +31 -39
  46. package/commonjs/steps/getStepMinTime.js.map +1 -1
  47. package/commonjs/steps/getStepMinTime.test.js +1 -3
  48. package/commonjs/steps/getStepMinTime.test.js.map +1 -1
  49. package/commonjs/steps/getTimeToNextUpdate.js +27 -41
  50. package/commonjs/steps/getTimeToNextUpdate.js.map +1 -1
  51. package/commonjs/steps/getTimeToNextUpdate.test.js +29 -25
  52. package/commonjs/steps/getTimeToNextUpdate.test.js.map +1 -1
  53. package/commonjs/steps/getTimeToNextUpdateForUnit.js +3 -12
  54. package/commonjs/steps/getTimeToNextUpdateForUnit.js.map +1 -1
  55. package/commonjs/steps/getTimeToNextUpdateForUnit.test.js +1 -7
  56. package/commonjs/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
  57. package/commonjs/steps/helpers.js +1 -2
  58. package/commonjs/steps/helpers.js.map +1 -1
  59. package/commonjs/steps/helpers.test.js +0 -1
  60. package/commonjs/steps/helpers.test.js.map +1 -1
  61. package/commonjs/steps/index.js +1 -6
  62. package/commonjs/steps/index.js.map +1 -1
  63. package/commonjs/steps/renameLegacyProperties.js +6 -14
  64. package/commonjs/steps/renameLegacyProperties.js.map +1 -1
  65. package/commonjs/steps/renameLegacyProperties.test.js +1 -3
  66. package/commonjs/steps/renameLegacyProperties.test.js.map +1 -1
  67. package/commonjs/steps/round.js +1 -2
  68. package/commonjs/steps/round.js.map +1 -1
  69. package/commonjs/steps/round.test.js +1 -7
  70. package/commonjs/steps/round.test.js.map +1 -1
  71. package/commonjs/steps/units.js +10 -21
  72. package/commonjs/steps/units.js.map +1 -1
  73. package/commonjs/style/approximate.js +2 -6
  74. package/commonjs/style/approximate.js.map +1 -1
  75. package/commonjs/style/approximateTime.js +2 -6
  76. package/commonjs/style/approximateTime.js.map +1 -1
  77. package/commonjs/style/approximateTime.test.js +116 -75
  78. package/commonjs/style/approximateTime.test.js.map +1 -1
  79. package/commonjs/style/getStyleByName.js +3 -29
  80. package/commonjs/style/getStyleByName.js.map +1 -1
  81. package/commonjs/style/mini.js +9 -6
  82. package/commonjs/style/mini.js.map +1 -1
  83. package/commonjs/style/mini.test.js +15 -25
  84. package/commonjs/style/mini.test.js.map +1 -1
  85. package/commonjs/style/miniMinute.js +8 -13
  86. package/commonjs/style/miniMinute.js.map +1 -1
  87. package/commonjs/style/miniMinute.test.js +11 -17
  88. package/commonjs/style/miniMinute.test.js.map +1 -1
  89. package/commonjs/style/miniMinuteNow.js +8 -13
  90. package/commonjs/style/miniMinuteNow.js.map +1 -1
  91. package/commonjs/style/miniMinuteNow.test.js +11 -17
  92. package/commonjs/style/miniMinuteNow.test.js.map +1 -1
  93. package/commonjs/style/miniNow.js +8 -13
  94. package/commonjs/style/miniNow.js.map +1 -1
  95. package/commonjs/style/miniNow.test.js +11 -17
  96. package/commonjs/style/miniNow.test.js.map +1 -1
  97. package/commonjs/style/renameLegacyProperties.js +7 -13
  98. package/commonjs/style/renameLegacyProperties.js.map +1 -1
  99. package/commonjs/style/renameLegacyProperties.test.js +1 -4
  100. package/commonjs/style/renameLegacyProperties.test.js.map +1 -1
  101. package/commonjs/style/round.js +2 -6
  102. package/commonjs/style/round.js.map +1 -1
  103. package/commonjs/style/round.test.js +51 -67
  104. package/commonjs/style/round.test.js.map +1 -1
  105. package/commonjs/style/roundMinute.js +8 -13
  106. package/commonjs/style/roundMinute.js.map +1 -1
  107. package/commonjs/style/roundMinute.test.js +20 -27
  108. package/commonjs/style/roundMinute.test.js.map +1 -1
  109. package/commonjs/style/twitter.js +34 -39
  110. package/commonjs/style/twitter.js.map +1 -1
  111. package/commonjs/style/twitter.test.js +54 -57
  112. package/commonjs/style/twitter.test.js.map +1 -1
  113. package/commonjs/style/twitterFirstMinute.js +10 -15
  114. package/commonjs/style/twitterFirstMinute.js.map +1 -1
  115. package/commonjs/style/twitterFirstMinute.test.js +16 -23
  116. package/commonjs/style/twitterFirstMinute.test.js.map +1 -1
  117. package/commonjs/style/twitterMinute.js +8 -13
  118. package/commonjs/style/twitterMinute.js.map +1 -1
  119. package/commonjs/style/twitterMinute.test.js +20 -25
  120. package/commonjs/style/twitterMinute.test.js.map +1 -1
  121. package/commonjs/style/twitterMinuteNow.js +8 -13
  122. package/commonjs/style/twitterMinuteNow.js.map +1 -1
  123. package/commonjs/style/twitterMinuteNow.test.js +20 -25
  124. package/commonjs/style/twitterMinuteNow.test.js.map +1 -1
  125. package/commonjs/style/twitterNow.js +8 -13
  126. package/commonjs/style/twitterNow.js.map +1 -1
  127. package/commonjs/style/twitterNow.test.js +18 -24
  128. package/commonjs/style/twitterNow.test.js.map +1 -1
  129. package/full-date-formatter/index.cjs +4 -0
  130. package/full-date-formatter/index.cjs.js +9 -0
  131. package/full-date-formatter/index.d.ts +6 -0
  132. package/full-date-formatter/index.js +1 -0
  133. package/full-date-formatter/package.json +15 -0
  134. package/index.cjs +1 -1
  135. package/index.cjs.js +2 -2
  136. package/index.d.ts +14 -4
  137. package/index.js +3 -1
  138. package/load-all-locales/index.cjs +32 -0
  139. package/load-all-locales/index.cjs.js +32 -0
  140. package/load-all-locales/index.js +64 -0
  141. package/locale/ak/package.json +16 -0
  142. package/locale/ak.json +267 -0
  143. package/locale/ak.json.d.ts +4 -0
  144. package/locale/ak.json.js +267 -0
  145. package/locale/bal-Latn/package.json +16 -0
  146. package/locale/bal-Latn.json +240 -0
  147. package/locale/bal-Latn.json.d.ts +4 -0
  148. package/locale/bal-Latn.json.js +240 -0
  149. package/locale/be-tarask/package.json +16 -0
  150. package/locale/be-tarask.json +259 -0
  151. package/locale/be-tarask.json.d.ts +4 -0
  152. package/locale/be-tarask.json.js +259 -0
  153. package/locale/blo/package.json +16 -0
  154. package/locale/blo.json +159 -0
  155. package/locale/blo.json.d.ts +4 -0
  156. package/locale/blo.json.js +159 -0
  157. package/locale/bn.json +5 -2
  158. package/locale/bn.json.js +5 -2
  159. package/locale/bs.json +8 -2
  160. package/locale/bs.json.js +8 -2
  161. package/locale/ccp.json +2 -8
  162. package/locale/ccp.json.js +2 -8
  163. package/locale/csw/package.json +16 -0
  164. package/locale/csw.json +180 -0
  165. package/locale/csw.json.d.ts +4 -0
  166. package/locale/csw.json.js +180 -0
  167. package/locale/cy.json +6 -12
  168. package/locale/cy.json.js +6 -12
  169. package/locale/doi/package.json +16 -0
  170. package/locale/doi.json +159 -0
  171. package/locale/doi.json.d.ts +4 -0
  172. package/locale/doi.json.js +159 -0
  173. package/locale/en-AU.json +12 -12
  174. package/locale/en-AU.json.js +12 -12
  175. package/locale/en-CZ/package.json +16 -0
  176. package/locale/en-CZ.json +219 -0
  177. package/locale/en-CZ.json.d.ts +4 -0
  178. package/locale/en-CZ.json.js +219 -0
  179. package/locale/en-ES/package.json +16 -0
  180. package/locale/en-ES.json +219 -0
  181. package/locale/en-ES.json.d.ts +4 -0
  182. package/locale/en-ES.json.js +219 -0
  183. package/locale/en-FR/package.json +16 -0
  184. package/locale/en-FR.json +219 -0
  185. package/locale/en-FR.json.d.ts +4 -0
  186. package/locale/en-FR.json.js +219 -0
  187. package/locale/en-GS/package.json +16 -0
  188. package/locale/en-GS.json +219 -0
  189. package/locale/en-GS.json.d.ts +4 -0
  190. package/locale/en-GS.json.js +219 -0
  191. package/locale/en-HU/package.json +16 -0
  192. package/locale/en-HU.json +219 -0
  193. package/locale/en-HU.json.d.ts +4 -0
  194. package/locale/en-HU.json.js +219 -0
  195. package/locale/en-ID/package.json +16 -0
  196. package/locale/en-ID.json +219 -0
  197. package/locale/en-ID.json.d.ts +4 -0
  198. package/locale/en-ID.json.js +219 -0
  199. package/locale/en-IT/package.json +16 -0
  200. package/locale/en-IT.json +219 -0
  201. package/locale/en-IT.json.d.ts +4 -0
  202. package/locale/en-IT.json.js +219 -0
  203. package/locale/en-NO/package.json +16 -0
  204. package/locale/en-NO.json +219 -0
  205. package/locale/en-NO.json.d.ts +4 -0
  206. package/locale/en-NO.json.js +219 -0
  207. package/locale/en-PL/package.json +16 -0
  208. package/locale/en-PL.json +219 -0
  209. package/locale/en-PL.json.d.ts +4 -0
  210. package/locale/en-PL.json.js +219 -0
  211. package/locale/en-PT/package.json +16 -0
  212. package/locale/en-PT.json +219 -0
  213. package/locale/en-PT.json.d.ts +4 -0
  214. package/locale/en-PT.json.js +219 -0
  215. package/locale/en-RO/package.json +16 -0
  216. package/locale/en-RO.json +219 -0
  217. package/locale/en-RO.json.d.ts +4 -0
  218. package/locale/en-RO.json.js +219 -0
  219. package/locale/en-SK/package.json +16 -0
  220. package/locale/en-SK.json +219 -0
  221. package/locale/en-SK.json.d.ts +4 -0
  222. package/locale/en-SK.json.js +219 -0
  223. package/locale/es-MX.json +12 -9
  224. package/locale/es-MX.json.js +12 -9
  225. package/locale/es-SV.json +2 -2
  226. package/locale/es-SV.json.js +2 -2
  227. package/locale/eu.json +24 -24
  228. package/locale/eu.json.js +24 -24
  229. package/locale/ha.json +119 -65
  230. package/locale/ha.json.js +119 -65
  231. package/locale/he.json +0 -6
  232. package/locale/he.json.js +0 -6
  233. package/locale/hi-Latn.json +2 -2
  234. package/locale/hi-Latn.json.js +2 -2
  235. package/locale/ht/package.json +16 -0
  236. package/locale/ht.json +207 -0
  237. package/locale/ht.json.d.ts +4 -0
  238. package/locale/ht.json.js +207 -0
  239. package/locale/id.json +1 -1
  240. package/locale/id.json.js +1 -1
  241. package/locale/ie/package.json +16 -0
  242. package/locale/ie.json +159 -0
  243. package/locale/ie.json.d.ts +4 -0
  244. package/locale/ie.json.js +159 -0
  245. package/locale/ig.json +17 -17
  246. package/locale/ig.json.js +17 -17
  247. package/locale/ii/package.json +16 -0
  248. package/locale/ii.json +165 -0
  249. package/locale/ii.json.d.ts +4 -0
  250. package/locale/ii.json.js +165 -0
  251. package/locale/is.json +4 -1
  252. package/locale/is.json.js +4 -1
  253. package/locale/kaa/package.json +16 -0
  254. package/locale/kaa.json +159 -0
  255. package/locale/kaa.json.d.ts +4 -0
  256. package/locale/kaa.json.js +159 -0
  257. package/locale/kok-Latn/package.json +16 -0
  258. package/locale/kok-Latn.json +159 -0
  259. package/locale/kok-Latn.json.d.ts +4 -0
  260. package/locale/kok-Latn.json.js +159 -0
  261. package/locale/kok.json +8 -8
  262. package/locale/kok.json.js +8 -8
  263. package/locale/ks.json +9 -9
  264. package/locale/ks.json.js +9 -9
  265. package/locale/ku.json +55 -46
  266. package/locale/ku.json.js +55 -46
  267. package/locale/lld/package.json +16 -0
  268. package/locale/lld.json +291 -0
  269. package/locale/lld.json.d.ts +4 -0
  270. package/locale/lld.json.js +291 -0
  271. package/locale/mi.json +22 -22
  272. package/locale/mi.json.js +22 -22
  273. package/locale/ms-Arab/package.json +16 -0
  274. package/locale/ms-Arab.json +159 -0
  275. package/locale/ms-Arab.json.d.ts +4 -0
  276. package/locale/ms-Arab.json.js +159 -0
  277. package/locale/nb.json +2 -2
  278. package/locale/nb.json.js +2 -2
  279. package/locale/ne.json +1 -1
  280. package/locale/ne.json.js +1 -1
  281. package/locale/nn.json +4 -4
  282. package/locale/nn.json.js +4 -4
  283. package/locale/no.json +2 -2
  284. package/locale/no.json.js +2 -2
  285. package/locale/nqo/package.json +16 -0
  286. package/locale/nqo.json +159 -0
  287. package/locale/nqo.json.d.ts +4 -0
  288. package/locale/nqo.json.js +159 -0
  289. package/locale/om/package.json +16 -0
  290. package/locale/om.json +213 -0
  291. package/locale/om.json.d.ts +4 -0
  292. package/locale/om.json.js +213 -0
  293. package/locale/or.json +1 -1
  294. package/locale/or.json.js +1 -1
  295. package/locale/qu.json +46 -46
  296. package/locale/qu.json.js +46 -46
  297. package/locale/rhg/package.json +16 -0
  298. package/locale/rhg.json +159 -0
  299. package/locale/rhg.json.d.ts +4 -0
  300. package/locale/rhg.json.js +159 -0
  301. package/locale/sl.json +12 -12
  302. package/locale/sl.json.js +12 -12
  303. package/locale/sr-Cyrl-BA.json +2 -2
  304. package/locale/sr-Cyrl-BA.json.js +2 -2
  305. package/locale/sr-Latn-BA.json +2 -2
  306. package/locale/sr-Latn-BA.json.js +2 -2
  307. package/locale/sv.json +1 -1
  308. package/locale/sv.json.js +1 -1
  309. package/locale/syr/package.json +16 -0
  310. package/locale/syr.json +303 -0
  311. package/locale/syr.json.d.ts +4 -0
  312. package/locale/syr.json.js +303 -0
  313. package/locale/ti.json +6 -6
  314. package/locale/ti.json.js +6 -6
  315. package/locale/tn/package.json +16 -0
  316. package/locale/tn.json +159 -0
  317. package/locale/tn.json.d.ts +4 -0
  318. package/locale/tn.json.js +159 -0
  319. package/locale/to.json +26 -26
  320. package/locale/to.json.js +26 -26
  321. package/locale/uk.json +1 -1
  322. package/locale/uk.json.js +1 -1
  323. package/locale/ur-IN.json +9 -6
  324. package/locale/ur-IN.json.js +9 -6
  325. package/locale/vec/package.json +16 -0
  326. package/locale/vec.json +267 -0
  327. package/locale/vec.json.d.ts +4 -0
  328. package/locale/vec.json.js +267 -0
  329. package/locale/xnr/package.json +16 -0
  330. package/locale/xnr.json +159 -0
  331. package/locale/xnr.json.d.ts +4 -0
  332. package/locale/xnr.json.js +159 -0
  333. package/locale/yo-BJ.json +17 -17
  334. package/locale/yo-BJ.json.js +17 -17
  335. package/locale/yo.json +17 -17
  336. package/locale/yo.json.js +17 -17
  337. package/modules/FullDateFormatter.js +67 -0
  338. package/modules/FullDateFormatter.js.map +1 -0
  339. package/modules/FullDateFormatter.test.js +22 -0
  340. package/modules/FullDateFormatter.test.js.map +1 -0
  341. package/modules/LocaleDataStore.js +2 -3
  342. package/modules/LocaleDataStore.js.map +1 -1
  343. package/modules/PropTypes.js +11 -7
  344. package/modules/PropTypes.js.map +1 -1
  345. package/modules/TimeAgo.js +299 -237
  346. package/modules/TimeAgo.js.map +1 -1
  347. package/modules/TimeAgo.test.js +217 -119
  348. package/modules/TimeAgo.test.js.map +1 -1
  349. package/modules/cache.js +6 -22
  350. package/modules/cache.js.map +1 -1
  351. package/modules/cache.test.js.map +1 -1
  352. package/modules/isStyleObject.js +9 -7
  353. package/modules/isStyleObject.js.map +1 -1
  354. package/modules/isStyleObject.test.js.map +1 -1
  355. package/modules/locale.js +6 -16
  356. package/modules/locale.js.map +1 -1
  357. package/modules/locale.test.js +0 -4
  358. package/modules/locale.test.js.map +1 -1
  359. package/modules/round.js +2 -3
  360. package/modules/round.js.map +1 -1
  361. package/modules/steps/approximate.js +6 -2
  362. package/modules/steps/approximate.js.map +1 -1
  363. package/modules/steps/approximate.test.js +0 -2
  364. package/modules/steps/approximate.test.js.map +1 -1
  365. package/modules/steps/getStep.js +36 -48
  366. package/modules/steps/getStep.js.map +1 -1
  367. package/modules/steps/getStep.test.js +6 -2
  368. package/modules/steps/getStep.test.js.map +1 -1
  369. package/modules/steps/getStepDenominator.js +2 -3
  370. package/modules/steps/getStepDenominator.js.map +1 -1
  371. package/modules/steps/getStepDenominator.test.js.map +1 -1
  372. package/modules/steps/getStepMinTime.js +31 -36
  373. package/modules/steps/getStepMinTime.js.map +1 -1
  374. package/modules/steps/getStepMinTime.test.js.map +1 -1
  375. package/modules/steps/getTimeToNextUpdate.js +28 -32
  376. package/modules/steps/getTimeToNextUpdate.js.map +1 -1
  377. package/modules/steps/getTimeToNextUpdate.test.js +27 -18
  378. package/modules/steps/getTimeToNextUpdate.test.js.map +1 -1
  379. package/modules/steps/getTimeToNextUpdateForUnit.js +4 -10
  380. package/modules/steps/getTimeToNextUpdateForUnit.js.map +1 -1
  381. package/modules/steps/getTimeToNextUpdateForUnit.test.js +0 -4
  382. package/modules/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
  383. package/modules/steps/helpers.js +1 -1
  384. package/modules/steps/helpers.js.map +1 -1
  385. package/modules/steps/helpers.test.js.map +1 -1
  386. package/modules/steps/index.js +2 -1
  387. package/modules/steps/index.js.map +1 -1
  388. package/modules/steps/renameLegacyProperties.js +6 -13
  389. package/modules/steps/renameLegacyProperties.js.map +1 -1
  390. package/modules/steps/renameLegacyProperties.test.js.map +1 -1
  391. package/modules/steps/round.js.map +1 -1
  392. package/modules/steps/round.test.js +0 -3
  393. package/modules/steps/round.test.js.map +1 -1
  394. package/modules/steps/units.js +5 -9
  395. package/modules/steps/units.js.map +1 -1
  396. package/modules/style/approximate.js +5 -1
  397. package/modules/style/approximate.js.map +1 -1
  398. package/modules/style/approximateTime.js +6 -2
  399. package/modules/style/approximateTime.js.map +1 -1
  400. package/modules/style/approximateTime.test.js +115 -70
  401. package/modules/style/approximateTime.test.js.map +1 -1
  402. package/modules/style/getStyleByName.js +4 -17
  403. package/modules/style/getStyleByName.js.map +1 -1
  404. package/modules/style/mini.js +8 -4
  405. package/modules/style/mini.js.map +1 -1
  406. package/modules/style/mini.test.js +14 -20
  407. package/modules/style/mini.test.js.map +1 -1
  408. package/modules/style/miniMinute.js +6 -6
  409. package/modules/style/miniMinute.js.map +1 -1
  410. package/modules/style/miniMinute.test.js +10 -12
  411. package/modules/style/miniMinute.test.js.map +1 -1
  412. package/modules/style/miniMinuteNow.js +6 -6
  413. package/modules/style/miniMinuteNow.js.map +1 -1
  414. package/modules/style/miniMinuteNow.test.js +10 -12
  415. package/modules/style/miniMinuteNow.test.js.map +1 -1
  416. package/modules/style/miniNow.js +6 -6
  417. package/modules/style/miniNow.js.map +1 -1
  418. package/modules/style/miniNow.test.js +10 -12
  419. package/modules/style/miniNow.test.js.map +1 -1
  420. package/modules/style/renameLegacyProperties.js +8 -10
  421. package/modules/style/renameLegacyProperties.js.map +1 -1
  422. package/modules/style/renameLegacyProperties.test.js +0 -1
  423. package/modules/style/renameLegacyProperties.test.js.map +1 -1
  424. package/modules/style/round.js +3 -2
  425. package/modules/style/round.js.map +1 -1
  426. package/modules/style/round.test.js +50 -62
  427. package/modules/style/round.test.js.map +1 -1
  428. package/modules/style/roundMinute.js +8 -7
  429. package/modules/style/roundMinute.js.map +1 -1
  430. package/modules/style/roundMinute.test.js +19 -22
  431. package/modules/style/roundMinute.test.js.map +1 -1
  432. package/modules/style/twitter.js +36 -33
  433. package/modules/style/twitter.js.map +1 -1
  434. package/modules/style/twitter.test.js +53 -52
  435. package/modules/style/twitter.test.js.map +1 -1
  436. package/modules/style/twitterFirstMinute.js +8 -7
  437. package/modules/style/twitterFirstMinute.js.map +1 -1
  438. package/modules/style/twitterFirstMinute.test.js +15 -18
  439. package/modules/style/twitterFirstMinute.test.js.map +1 -1
  440. package/modules/style/twitterMinute.js +6 -6
  441. package/modules/style/twitterMinute.js.map +1 -1
  442. package/modules/style/twitterMinute.test.js +19 -20
  443. package/modules/style/twitterMinute.test.js.map +1 -1
  444. package/modules/style/twitterMinuteNow.js +6 -6
  445. package/modules/style/twitterMinuteNow.js.map +1 -1
  446. package/modules/style/twitterMinuteNow.test.js +19 -20
  447. package/modules/style/twitterMinuteNow.test.js.map +1 -1
  448. package/modules/style/twitterNow.js +6 -6
  449. package/modules/style/twitterNow.js.map +1 -1
  450. package/modules/style/twitterNow.test.js +17 -19
  451. package/modules/style/twitterNow.test.js.map +1 -1
  452. package/package.json +275 -13
@@ -1,39 +1,45 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
-
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
2
  import { getSecondsInUnit } from './units.js';
4
3
  import { getDiffRatioToNextRoundedNumber } from '../round.js';
5
4
  export default function getStepMinTime(step, _ref) {
6
5
  var prevStep = _ref.prevStep,
7
- timestamp = _ref.timestamp,
8
- now = _ref.now,
9
- future = _ref.future,
10
- round = _ref.round;
11
- var minTime; // "threshold_for_xxx" is a legacy property.
12
-
6
+ timestamp = _ref.timestamp,
7
+ now = _ref.now,
8
+ future = _ref.future,
9
+ round = _ref.round;
10
+ var minTime;
11
+
12
+ // (deprecated)
13
+ // Get `minTime` from "threshold_for_xxx" property of the `step`.
14
+ // "threshold_for_xxx" property of a `step` is deprecated.
13
15
  if (prevStep) {
14
16
  if (prevStep.id || prevStep.unit) {
15
17
  minTime = step["threshold_for_".concat(prevStep.id || prevStep.unit)];
16
18
  }
17
19
  }
18
20
 
21
+ // (deprecated)
22
+ // Get `minTime` from "threshold" property of the `step`.
23
+ // "threshold" property of a `step` is deprecated.
19
24
  if (minTime === undefined) {
20
- // "threshold" is a legacy property.
21
25
  if (step.threshold !== undefined) {
22
26
  // "threshold" is a legacy name for "minTime".
23
- minTime = step.threshold; // "threshold" function is deprecated.
24
-
27
+ minTime = step.threshold;
28
+ // "threshold" function is deprecated.
25
29
  if (typeof minTime === 'function') {
26
30
  minTime = minTime(now, future);
27
31
  }
28
32
  }
29
33
  }
30
34
 
35
+ // Get `minTime` from `minTime` property of the `step`.
36
+ // This is the only non-deprecated source for the `minTime` property.
31
37
  if (minTime === undefined) {
32
38
  minTime = step.minTime;
33
- } // A deprecated way of specifying a different threshold
34
- // depending on the previous step's unit.
35
-
39
+ }
36
40
 
41
+ // (deprecated)
42
+ // If `minTime` is an object, calculate `minTime` from the previous step's `unit`.
37
43
  if (_typeof(minTime) === 'object') {
38
44
  if (prevStep && prevStep.id && minTime[prevStep.id] !== undefined) {
39
45
  minTime = minTime[prevStep.id];
@@ -42,6 +48,7 @@ export default function getStepMinTime(step, _ref) {
42
48
  }
43
49
  }
44
50
 
51
+ // If `minTime` is a function, call it with certain arguments.
45
52
  if (typeof minTime === 'function') {
46
53
  minTime = minTime(timestamp, {
47
54
  future: future,
@@ -51,10 +58,11 @@ export default function getStepMinTime(step, _ref) {
51
58
  });
52
59
  }
53
60
  });
54
- } // Evaluate the `test()` function.
55
- // `test()` function is deprecated.
56
-
61
+ }
57
62
 
63
+ // (deprecated)
64
+ // Get `minTime` from `step.test()` function property.
65
+ // `step.test` property is deprecated.
58
66
  if (minTime === undefined) {
59
67
  if (step.test) {
60
68
  if (step.test(timestamp, {
@@ -70,6 +78,8 @@ export default function getStepMinTime(step, _ref) {
70
78
  }
71
79
  }
72
80
 
81
+ // If `minTime` is `undefined`, calculate it from the previous `step`.
82
+ // If it's the first step and there's no previous one, the `minTime` is assumed `0`.
73
83
  if (minTime === undefined) {
74
84
  if (prevStep) {
75
85
  if (step.formatAs && prevStep.formatAs) {
@@ -81,33 +91,18 @@ export default function getStepMinTime(step, _ref) {
81
91
  // The first step's `minTime` is `0` by default.
82
92
  minTime = 0;
83
93
  }
84
- } // Warn if no `minTime` was defined or could be deduced.
85
-
94
+ }
86
95
 
96
+ // Warn if no `minTime` is defined for this step.
87
97
  if (minTime === undefined) {
88
98
  console.warn('[javascript-time-ago] A step should specify `minTime`:\n' + JSON.stringify(step, null, 2));
89
99
  }
90
-
91
100
  return minTime;
92
101
  }
93
-
94
102
  function _getMinTimeForUnit(toUnit, fromUnit, _ref2) {
95
103
  var round = _ref2.round;
96
- var toUnitAmount = getSecondsInUnit(toUnit); // if (!fromUnit) {
97
- // return toUnitAmount;
98
- // }
99
- // if (!fromUnit) {
100
- // fromUnit = getPreviousUnitFor(toUnit)
101
- // }
102
-
103
- var fromUnitAmount;
104
-
105
- if (fromUnit === 'now') {
106
- fromUnitAmount = getSecondsInUnit(toUnit);
107
- } else {
108
- fromUnitAmount = getSecondsInUnit(fromUnit);
109
- }
110
-
104
+ var toUnitAmount = getSecondsInUnit(toUnit);
105
+ var fromUnitAmount = fromUnit === 'now' ? getSecondsInUnit(toUnit) : getSecondsInUnit(fromUnit);
111
106
  if (toUnitAmount !== undefined && fromUnitAmount !== undefined) {
112
107
  return toUnitAmount - fromUnitAmount * (1 - getDiffRatioToNextRoundedNumber(round));
113
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getStepMinTime.js","names":["getSecondsInUnit","getDiffRatioToNextRoundedNumber","getStepMinTime","step","prevStep","timestamp","now","future","round","minTime","id","unit","undefined","threshold","getMinTimeForUnit","toUnit","fromUnit","formatAs","test","console","warn","JSON","stringify","toUnitAmount","fromUnitAmount"],"sources":["../../source/steps/getStepMinTime.js"],"sourcesContent":["import { getSecondsInUnit } from './units.js'\r\nimport { getDiffRatioToNextRoundedNumber } from '../round.js'\r\n\r\nexport default function getStepMinTime(step, {\r\n\tprevStep,\r\n\ttimestamp,\r\n\t// `now` argument is used in a deprecated `step.test()` function.\r\n\tnow,\r\n\tfuture,\r\n\tround\r\n}) {\r\n\tlet minTime\r\n\t// \"threshold_for_xxx\" is a legacy property.\r\n\tif (prevStep) {\r\n\t\tif (prevStep.id || prevStep.unit) {\r\n\t\t\tminTime = step[`threshold_for_${prevStep.id || prevStep.unit}`]\r\n\t\t}\r\n\t}\r\n\tif (minTime === undefined) {\r\n\t\t// \"threshold\" is a legacy property.\r\n\t\tif (step.threshold !== undefined) {\r\n\t\t\t// \"threshold\" is a legacy name for \"minTime\".\r\n\t\t\tminTime = step.threshold\r\n\t\t\t// \"threshold\" function is deprecated.\r\n\t\t\tif (typeof minTime === 'function') {\r\n\t\t\t\tminTime = minTime(now, future)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (minTime === undefined) {\r\n\t\tminTime = step.minTime\r\n\t}\r\n\t// A deprecated way of specifying a different threshold\r\n\t// depending on the previous step's unit.\r\n\tif (typeof minTime === 'object') {\r\n\t\tif (prevStep && prevStep.id && minTime[prevStep.id] !== undefined) {\r\n\t\t\tminTime = minTime[prevStep.id]\r\n\t\t} else {\r\n\t\t\tminTime = minTime.default\r\n\t\t}\r\n\t}\r\n\tif (typeof minTime === 'function') {\r\n\t\tminTime = minTime(timestamp, {\r\n\t\t\tfuture,\r\n\t\t\tgetMinTimeForUnit(toUnit, fromUnit) {\r\n\t\t\t\treturn getMinTimeForUnit(\r\n\t\t\t\t\ttoUnit,\r\n\t\t\t\t\tfromUnit || prevStep && prevStep.formatAs,\r\n\t\t\t\t\t{ round }\r\n\t\t\t\t)\r\n\t\t\t}\r\n\t\t})\r\n\t}\r\n\t// Evaluate the `test()` function.\r\n\t// `test()` function is deprecated.\r\n\tif (minTime === undefined) {\r\n\t\tif (step.test) {\r\n\t\t\tif (step.test(timestamp, {\r\n\t\t\t\tnow,\r\n\t\t\t\tfuture\r\n\t\t\t})) {\r\n\t\t\t\t// `0` threshold always passes.\r\n\t\t\t\tminTime = 0\r\n\t\t\t} else {\r\n\t\t\t\t// `MAX_SAFE_INTEGER` threshold won't ever pass in real life.\r\n\t\t\t\tminTime = 9007199254740991 // Number.MAX_SAFE_INTEGER\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (minTime === undefined) {\r\n\t\tif (prevStep) {\r\n\t\t\tif (step.formatAs && prevStep.formatAs) {\r\n\t\t\t\tminTime = getMinTimeForUnit(step.formatAs, prevStep.formatAs, { round })\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\t// The first step's `minTime` is `0` by default.\r\n\t\t\tminTime = 0\r\n\t\t}\r\n\t}\r\n\t// Warn if no `minTime` was defined or could be deduced.\r\n\tif (minTime === undefined) {\r\n\t\tconsole.warn('[javascript-time-ago] A step should specify `minTime`:\\n' + JSON.stringify(step, null, 2))\r\n\t}\r\n\treturn minTime\r\n}\r\n\r\nfunction getMinTimeForUnit(toUnit, fromUnit, { round }) {\r\n\tconst toUnitAmount = getSecondsInUnit(toUnit)\r\n\t// if (!fromUnit) {\r\n\t// \treturn toUnitAmount;\r\n\t// }\r\n\t// if (!fromUnit) {\r\n\t// \tfromUnit = getPreviousUnitFor(toUnit)\r\n\t// }\r\n\tlet fromUnitAmount\r\n\tif (fromUnit === 'now') {\r\n\t\tfromUnitAmount = getSecondsInUnit(toUnit)\r\n\t} else {\r\n\t\tfromUnitAmount = getSecondsInUnit(fromUnit)\r\n\t}\r\n\tif (toUnitAmount !== undefined && fromUnitAmount !== undefined) {\r\n\t\treturn toUnitAmount - fromUnitAmount * (1 - getDiffRatioToNextRoundedNumber(round))\r\n\t}\r\n}"],"mappings":";;AAAA,SAASA,gBAAT,QAAiC,YAAjC;AACA,SAASC,+BAAT,QAAgD,aAAhD;AAEA,eAAe,SAASC,cAAT,CAAwBC,IAAxB,QAOZ;EAAA,IANFC,QAME,QANFA,QAME;EAAA,IALFC,SAKE,QALFA,SAKE;EAAA,IAHFC,GAGE,QAHFA,GAGE;EAAA,IAFFC,MAEE,QAFFA,MAEE;EAAA,IADFC,KACE,QADFA,KACE;EACF,IAAIC,OAAJ,CADE,CAEF;;EACA,IAAIL,QAAJ,EAAc;IACb,IAAIA,QAAQ,CAACM,EAAT,IAAeN,QAAQ,CAACO,IAA5B,EAAkC;MACjCF,OAAO,GAAGN,IAAI,yBAAkBC,QAAQ,CAACM,EAAT,IAAeN,QAAQ,CAACO,IAA1C,EAAd;IACA;EACD;;EACD,IAAIF,OAAO,KAAKG,SAAhB,EAA2B;IAC1B;IACA,IAAIT,IAAI,CAACU,SAAL,KAAmBD,SAAvB,EAAkC;MACjC;MACAH,OAAO,GAAGN,IAAI,CAACU,SAAf,CAFiC,CAGjC;;MACA,IAAI,OAAOJ,OAAP,KAAmB,UAAvB,EAAmC;QAClCA,OAAO,GAAGA,OAAO,CAACH,GAAD,EAAMC,MAAN,CAAjB;MACA;IACD;EACD;;EACD,IAAIE,OAAO,KAAKG,SAAhB,EAA2B;IAC1BH,OAAO,GAAGN,IAAI,CAACM,OAAf;EACA,CArBC,CAsBF;EACA;;;EACA,IAAI,QAAOA,OAAP,MAAmB,QAAvB,EAAiC;IAChC,IAAIL,QAAQ,IAAIA,QAAQ,CAACM,EAArB,IAA2BD,OAAO,CAACL,QAAQ,CAACM,EAAV,CAAP,KAAyBE,SAAxD,EAAmE;MAClEH,OAAO,GAAGA,OAAO,CAACL,QAAQ,C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EACA;;EACD,OAAOM,OAAP;AACA;;AAED,SAASK,kBAAT,CAA2BC,MAA3B,EAAmCC,QAAnC,SAAwD;EAAA,IAATR,KAAS,SAATA,KAAS;EACvD,IAAMe,YAAY,GAAGvB,gBAAgB,CAACe,MAAD,CAArC,CADuD,CAEvD;EACA;EACA;EACA;EACA;EACA;;EACA,IAAIS,cAAJ;;EACA,IAAIR,QAAQ,KAAK,KAAjB,EAAwB;IACvBQ,cAAc,GAAGxB,gBAAgB,CAACe,MAAD,CAAjC;EACA,CAFD,MAEO;IACNS,cAAc,GAAGxB,gBAAgB,CAACgB,QAAD,CAAjC;EACA;;EACD,IAAIO,YAAY,KAAKX,SAAjB,IAA8BY,cAAc,KAAKZ,SAArD,EAAgE;IAC/D,OAAOW,YAAY,GAAGC,cAAc,IAAI,IAAIvB,+BAA+B,CAACO,KAAD,CAAvC,CAApC;EACA;AACD"}
1
+ {"version":3,"file":"getStepMinTime.js","names":["getSecondsInUnit","getDiffRatioToNextRoundedNumber","getStepMinTime","step","_ref","prevStep","timestamp","now","future","round","minTime","id","unit","concat","undefined","threshold","_typeof","getMinTimeForUnit","toUnit","fromUnit","formatAs","test","console","warn","JSON","stringify","_ref2","toUnitAmount","fromUnitAmount"],"sources":["../../source/steps/getStepMinTime.js"],"sourcesContent":["import { getSecondsInUnit } from './units.js'\r\nimport { getDiffRatioToNextRoundedNumber } from '../round.js'\r\n\r\nexport default function getStepMinTime(step, {\r\n\tprevStep,\r\n\ttimestamp,\r\n\t// `now` argument is used in a deprecated `step.test()` function.\r\n\tnow,\r\n\tfuture,\r\n\tround\r\n}) {\r\n\tlet minTime\r\n\r\n\t// (deprecated)\r\n\t// Get `minTime` from \"threshold_for_xxx\" property of the `step`.\r\n\t// \"threshold_for_xxx\" property of a `step` is deprecated.\r\n\tif (prevStep) {\r\n\t\tif (prevStep.id || prevStep.unit) {\r\n\t\t\tminTime = step[`threshold_for_${prevStep.id || prevStep.unit}`]\r\n\t\t}\r\n\t}\r\n\r\n\t// (deprecated)\r\n\t// Get `minTime` from \"threshold\" property of the `step`.\r\n\t// \"threshold\" property of a `step` is deprecated.\r\n\tif (minTime === undefined) {\r\n\t\tif (step.threshold !== undefined) {\r\n\t\t\t// \"threshold\" is a legacy name for \"minTime\".\r\n\t\t\tminTime = step.threshold\r\n\t\t\t// \"threshold\" function is deprecated.\r\n\t\t\tif (typeof minTime === 'function') {\r\n\t\t\t\tminTime = minTime(now, future)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Get `minTime` from `minTime` property of the `step`.\r\n\t// This is the only non-deprecated source for the `minTime` property.\r\n\tif (minTime === undefined) {\r\n\t\tminTime = step.minTime\r\n\t}\r\n\r\n\t// (deprecated)\r\n\t// If `minTime` is an object, calculate `minTime` from the previous step's `unit`.\r\n\tif (typeof minTime === 'object') {\r\n\t\tif (prevStep && prevStep.id && minTime[prevStep.id] !== undefined) {\r\n\t\t\tminTime = minTime[prevStep.id]\r\n\t\t} else {\r\n\t\t\tminTime = minTime.default\r\n\t\t}\r\n\t}\r\n\r\n\t// If `minTime` is a function, call it with certain arguments.\r\n\tif (typeof minTime === 'function') {\r\n\t\tminTime = minTime(timestamp, {\r\n\t\t\tfuture,\r\n\t\t\tgetMinTimeForUnit(toUnit, fromUnit) {\r\n\t\t\t\treturn getMinTimeForUnit(\r\n\t\t\t\t\ttoUnit,\r\n\t\t\t\t\tfromUnit || prevStep && prevStep.formatAs,\r\n\t\t\t\t\t{ round }\r\n\t\t\t\t)\r\n\t\t\t}\r\n\t\t})\r\n\t}\r\n\r\n\t// (deprecated)\r\n\t// Get `minTime` from `step.test()` function property.\r\n\t// `step.test` property is deprecated.\r\n\tif (minTime === undefined) {\r\n\t\tif (step.test) {\r\n\t\t\tif (step.test(timestamp, {\r\n\t\t\t\tnow,\r\n\t\t\t\tfuture\r\n\t\t\t})) {\r\n\t\t\t\t// `0` threshold always passes.\r\n\t\t\t\tminTime = 0\r\n\t\t\t} else {\r\n\t\t\t\t// `MAX_SAFE_INTEGER` threshold won't ever pass in real life.\r\n\t\t\t\tminTime = 9007199254740991 // Number.MAX_SAFE_INTEGER\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// If `minTime` is `undefined`, calculate it from the previous `step`.\r\n\t// If it's the first step and there's no previous one, the `minTime` is assumed `0`.\r\n\tif (minTime === undefined) {\r\n\t\tif (prevStep) {\r\n\t\t\tif (step.formatAs && prevStep.formatAs) {\r\n\t\t\t\tminTime = getMinTimeForUnit(step.formatAs, prevStep.formatAs, { round })\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\t// The first step's `minTime` is `0` by default.\r\n\t\t\tminTime = 0\r\n\t\t}\r\n\t}\r\n\r\n\t// Warn if no `minTime` is defined for this step.\r\n\tif (minTime === undefined) {\r\n\t\tconsole.warn('[javascript-time-ago] A step should specify `minTime`:\\n' + JSON.stringify(step, null, 2))\r\n\t}\r\n\r\n\treturn minTime\r\n}\r\n\r\nfunction getMinTimeForUnit(toUnit, fromUnit, { round }) {\r\n\tconst toUnitAmount = getSecondsInUnit(toUnit)\r\n\tconst fromUnitAmount = fromUnit === 'now' ? getSecondsInUnit(toUnit) : getSecondsInUnit(fromUnit)\r\n\tif (toUnitAmount !== undefined && fromUnitAmount !== undefined) {\r\n\t\treturn toUnitAmount - fromUnitAmount * (1 - getDiffRatioToNextRoundedNumber(round))\r\n\t}\r\n}"],"mappings":";AAAA,SAASA,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,+BAA+B,QAAQ,aAAa;AAE7D,eAAe,SAASC,cAAcA,CAACC,IAAI,EAAAC,IAAA,EAOxC;EAAA,IANFC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IACRC,SAAS,GAAAF,IAAA,CAATE,SAAS;IAETC,GAAG,GAAAH,IAAA,CAAHG,GAAG;IACHC,MAAM,GAAAJ,IAAA,CAANI,MAAM;IACNC,KAAK,GAAAL,IAAA,CAALK,KAAK;EAEL,IAAIC,OAAO;;EAEX;EACA;EACA;EACA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AAC,CAAC;EACpF;AACD","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"getStepMinTime.test.js","names":["getStepMinTime","describe","it","test","prevStep","minTime","should","equal"],"sources":["../../source/steps/getStepMinTime.test.js"],"sourcesContent":["import getStepMinTime from './getStepMinTime.js'\r\n\r\ndescribe('getStepMinTime', () => {\r\n\tit('should support `step.test()` function (returns true)', () => {\r\n\t\tgetStepMinTime({\r\n\t\t\ttest: () => true\r\n\t\t}, {\r\n\t\t\tprevStep: { minTime: 1 }\r\n\t\t}).should.equal(0)\r\n\t})\r\n\r\n\tit('should support `step.test()` function (returns false)', () => {\r\n\t\tgetStepMinTime({\r\n\t\t\ttest: () => false\r\n\t\t}, {\r\n\t\t\tprevStep: { minTime: 1 }\r\n\t\t}).should.equal(9007199254740991)\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,qBAA3B;AAEAC,QAAQ,CAAC,gBAAD,EAAmB,YAAM;EAChCC,EAAE,CAAC,sDAAD,EAAyD,YAAM;IAChEF,cAAc,CAAC;MACdG,IAAI,EAAE;QAAA,OAAM,IAAN;MAAA;IADQ,CAAD,EAEX;MACFC,QAAQ,EAAE;QAAEC,OAAO,EAAE;MAAX;IADR,CAFW,CAAd,CAIGC,MAJH,CAIUC,KAJV,CAIgB,CAJhB;EAKA,CANC,CAAF;EAQAL,EAAE,CAAC,uDAAD,EAA0D,YAAM;IACjEF,cAAc,CAAC;MACdG,IAAI,EAAE;QAAA,OAAM,KAAN;MAAA;IADQ,CAAD,EAEX;MACFC,QAAQ,EAAE;QAAEC,OAAO,EAAE;MAAX;IADR,CAFW,CAAd,CAIGC,MAJH,CAIUC,KAJV,CAIgB,gBAJhB;EAKA,CANC,CAAF;AAOA,CAhBO,CAAR"}
1
+ {"version":3,"file":"getStepMinTime.test.js","names":["getStepMinTime","describe","it","test","prevStep","minTime","should","equal"],"sources":["../../source/steps/getStepMinTime.test.js"],"sourcesContent":["import getStepMinTime from './getStepMinTime.js'\r\n\r\ndescribe('getStepMinTime', () => {\r\n\tit('should support `step.test()` function (returns true)', () => {\r\n\t\tgetStepMinTime({\r\n\t\t\ttest: () => true\r\n\t\t}, {\r\n\t\t\tprevStep: { minTime: 1 }\r\n\t\t}).should.equal(0)\r\n\t})\r\n\r\n\tit('should support `step.test()` function (returns false)', () => {\r\n\t\tgetStepMinTime({\r\n\t\t\ttest: () => false\r\n\t\t}, {\r\n\t\t\tprevStep: { minTime: 1 }\r\n\t\t}).should.equal(9007199254740991)\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,cAAc,MAAM,qBAAqB;AAEhDC,QAAQ,CAAC,gBAAgB,EAAE,YAAM;EAChCC,EAAE,CAAC,sDAAsD,EAAE,YAAM;IAChEF,cAAc,CAAC;MACdG,IAAI,EAAE,SAAAA,KAAA;QAAA,OAAM,IAAI;MAAA;IACjB,CAAC,EAAE;MACFC,QAAQ,EAAE;QAAEC,OAAO,EAAE;MAAE;IACxB,CAAC,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC;EACnB,CAAC,CAAC;EAEFL,EAAE,CAAC,uDAAuD,EAAE,YAAM;IACjEF,cAAc,CAAC;MACdG,IAAI,EAAE,SAAAA,KAAA;QAAA,OAAM,KAAK;MAAA;IAClB,CAAC,EAAE;MACFC,QAAQ,EAAE;QAAEC,OAAO,EAAE;MAAE;IACxB,CAAC,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,gBAAgB,CAAC;EAClC,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
@@ -1,11 +1,15 @@
1
1
  import _getTimeToNextUpdateForUnit from './getTimeToNextUpdateForUnit.js';
2
2
  import getStepMinTime from './getStepMinTime.js';
3
- import { getRoundFunction } from '../round.js'; // A thousand years is practically a metaphor for "infinity".
3
+ import { getRoundFunction } from '../round.js';
4
4
 
5
+ // A thousand years is practically a metaphor for "infinity".
5
6
  var YEAR = 365 * 24 * 60 * 60 * 1000;
7
+ // It can't really return `Infinity` in order to not screw any potential calculations performed with it.
8
+ // Hence, it emulates `Infinity` with a really large number that is "practically infinite".
6
9
  export var INFINITY = 1000 * YEAR;
10
+
7
11
  /**
8
- * Gets the time to next update for a date and a step.
12
+ * Returns the time (in milliseconds) after which the formatted date label should be refreshed.
9
13
  * @param {number} date — The date passed to `.format()`, converted to a timestamp.
10
14
  * @param {object} step
11
15
  * @param {object} [options.previousStep]
@@ -13,23 +17,23 @@ export var INFINITY = 1000 * YEAR;
13
17
  * @param {number} options.now
14
18
  * @param {boolean} options.future
15
19
  * @param {string} [options.round] - (undocumented) Rounding mechanism.
16
- * @return {number} [timeToNextUpdate]
20
+ * @return {number} [timeToNextUpdate] Returns the time to next update. Returns `undefined` when it can't determine time to next update. That could only happen when the "style" doesn't meet the minimum requirements for `getTimeToNextUpdate: true` feature (see README).
17
21
  */
18
-
19
22
  export default function getTimeToNextUpdate(date, step, _ref) {
20
23
  var prevStep = _ref.prevStep,
21
- nextStep = _ref.nextStep,
22
- now = _ref.now,
23
- future = _ref.future,
24
- round = _ref.round;
24
+ nextStep = _ref.nextStep,
25
+ now = _ref.now,
26
+ future = _ref.future,
27
+ round = _ref.round;
25
28
  var timestamp = date.getTime ? date.getTime() : date;
26
-
27
29
  var getTimeToNextUpdateForUnit = function getTimeToNextUpdateForUnit(unit) {
28
30
  return _getTimeToNextUpdateForUnit(unit, timestamp, {
29
31
  now: now,
30
32
  round: round
31
33
  });
32
- }; // For future dates, steps move from the last one to the first one,
34
+ };
35
+
36
+ // For future dates, steps move from the last one to the first one,
33
37
  // while for past dates, steps move from the first one to the last one,
34
38
  // due to the fact that time flows in one direction,
35
39
  // and future dates' interval naturally becomes smaller
@@ -43,24 +47,22 @@ export default function getTimeToNextUpdate(date, step, _ref) {
43
47
  // from the current step to the next step,
44
48
  // therefore check the `minTime` of the next step.
45
49
  //
46
-
47
-
48
50
  var timeToStepChange = getTimeToStepChange(future ? step : nextStep, timestamp, {
49
51
  future: future,
50
52
  now: now,
51
53
  round: round,
52
- prevStep: future ? prevStep : step // isFirstStep: future && isFirstStep
53
-
54
+ prevStep: future ? prevStep : step
55
+ // isFirstStep: future && isFirstStep
54
56
  });
55
57
 
58
+ // If the "style" doesn't meet the minimum requirements for `getTimeToNextUpdate: true` feature (see README)
59
+ // then `timeToStepChange` will be `undefined`. In that case, just return `undefined`.
56
60
  if (timeToStepChange === undefined) {
57
61
  // Can't reliably determine "time to next update"
58
62
  // if not all of the steps provide `minTime`.
59
63
  return;
60
64
  }
61
-
62
65
  var timeToNextUpdate;
63
-
64
66
  if (step) {
65
67
  if (step.getTimeToNextUpdate) {
66
68
  timeToNextUpdate = step.getTimeToNextUpdate(timestamp, {
@@ -71,11 +73,9 @@ export default function getTimeToNextUpdate(date, step, _ref) {
71
73
  round: round
72
74
  });
73
75
  }
74
-
75
76
  if (timeToNextUpdate === undefined) {
76
77
  // "unit" is now called "formatAs".
77
78
  var unit = step.unit || step.formatAs;
78
-
79
79
  if (unit) {
80
80
  // For some units, like "now", there's no defined amount of seconds in them.
81
81
  // In such cases, `getTimeToNextUpdateForUnit()` returns `undefined`,
@@ -85,18 +85,19 @@ export default function getTimeToNextUpdate(date, step, _ref) {
85
85
  }
86
86
  }
87
87
  }
88
-
89
88
  if (timeToNextUpdate === undefined) {
90
89
  return timeToStepChange;
91
90
  }
92
-
93
91
  return Math.min(timeToNextUpdate, timeToStepChange);
94
92
  }
93
+
94
+ // Returns the timestamp at which it'll move to the next step.
95
+ // Returns `undefined` when it can't determine when it'll move to the next stemp. That could only happen when the "style" doesn't meet the minimum requirements for `getTimeToNextUpdate: true` feature (see README).
95
96
  export function getStepChangesAt(currentOrNextStep, timestamp, _ref2) {
96
97
  var now = _ref2.now,
97
- future = _ref2.future,
98
- round = _ref2.round,
99
- prevStep = _ref2.prevStep;
98
+ future = _ref2.future,
99
+ round = _ref2.round,
100
+ prevStep = _ref2.prevStep;
100
101
  // The first step's `minTime` is `0` by default.
101
102
  // It doesn't "change" steps at zero point
102
103
  // but it does change the wording when switching
@@ -109,11 +110,9 @@ export function getStepChangesAt(currentOrNextStep, timestamp, _ref2) {
109
110
  round: round,
110
111
  prevStep: prevStep
111
112
  });
112
-
113
113
  if (minTime === undefined) {
114
114
  return;
115
115
  }
116
-
117
116
  if (future) {
118
117
  // The step changes to the previous step
119
118
  // as soon as `timestamp - now` becomes
@@ -127,20 +126,19 @@ export function getStepChangesAt(currentOrNextStep, timestamp, _ref2) {
127
126
  // equal to `minTime` of the next step:
128
127
  // `now - timestamp === minTime`
129
128
  // => `now === timestamp + minTime`.
129
+
130
130
  // This is a special case when double-update could be skipped.
131
131
  if (minTime === 0 && timestamp === now) {
132
132
  return INFINITY;
133
133
  }
134
-
135
134
  return timestamp + minTime * 1000;
136
135
  }
137
136
  }
138
137
  export function getTimeToStepChange(step, timestamp, _ref3) {
139
138
  var now = _ref3.now,
140
- future = _ref3.future,
141
- round = _ref3.round,
142
- prevStep = _ref3.prevStep;
143
-
139
+ future = _ref3.future,
140
+ round = _ref3.round,
141
+ prevStep = _ref3.prevStep;
144
142
  if (step) {
145
143
  var stepChangesAt = getStepChangesAt(step, timestamp, {
146
144
  now: now,
@@ -148,11 +146,9 @@ export function getTimeToStepChange(step, timestamp, _ref3) {
148
146
  round: round,
149
147
  prevStep: prevStep
150
148
  });
151
-
152
149
  if (stepChangesAt === undefined) {
153
150
  return;
154
151
  }
155
-
156
152
  return stepChangesAt - now;
157
153
  } else {
158
154
  if (future) {
@@ -1 +1 @@
1
- {"version":3,"file":"getTimeToNextUpdate.js","names":["_getTimeToNextUpdateForUnit","getStepMinTime","getRoundFunction","YEAR","INFINITY","getTimeToNextUpdate","date","step","prevStep","nextStep","now","future","round","timestamp","getTime","getTimeToNextUpdateForUnit","unit","timeToStepChange","getTimeToStepChange","undefined","timeToNextUpdate","formatAs","Math","min","getStepChangesAt","currentOrNextStep","minTime","stepChangesAt"],"sources":["../../source/steps/getTimeToNextUpdate.js"],"sourcesContent":["import _getTimeToNextUpdateForUnit from './getTimeToNextUpdateForUnit.js'\r\nimport getStepMinTime from './getStepMinTime.js'\r\nimport { getRoundFunction } from '../round.js'\r\n\r\n// A thousand years is practically a metaphor for \"infinity\".\r\nconst YEAR = 365 * 24 * 60 * 60 * 1000\r\nexport const INFINITY = 1000 * YEAR\r\n\r\n/**\r\n * Gets the time to next update for a date and a step.\r\n * @param {number} date — The date passed to `.format()`, converted to a timestamp.\r\n * @param {object} step\r\n * @param {object} [options.previousStep]\r\n * @param {object} [options.nextStep]\r\n * @param {number} options.now\r\n * @param {boolean} options.future\r\n * @param {string} [options.round] - (undocumented) Rounding mechanism.\r\n * @return {number} [timeToNextUpdate]\r\n */\r\nexport default function getTimeToNextUpdate(date, step, { prevStep, nextStep, now, future, round }) {\r\n\tconst timestamp = date.getTime ? date.getTime() : date\r\n\r\n\tconst getTimeToNextUpdateForUnit = (unit) => _getTimeToNextUpdateForUnit(unit, timestamp, { now, round })\r\n\r\n\t// For future dates, steps move from the last one to the first one,\r\n\t// while for past dates, steps move from the first one to the last one,\r\n\t// due to the fact that time flows in one direction,\r\n\t// and future dates' interval naturally becomes smaller\r\n\t// while past dates' interval naturally grows larger.\r\n\t//\r\n\t// For future dates, it's the transition\r\n\t// from the current step to the previous step,\r\n\t// therefore check the `minTime` of the current step.\r\n\t//\r\n\t// For past dates, it's the transition\r\n\t// from the current step to the next step,\r\n\t// therefore check the `minTime` of the next step.\r\n\t//\r\n\tconst timeToStepChange = getTimeToStepChange(future ? step : nextStep, timestamp, {\r\n\t\tfuture,\r\n\t\tnow,\r\n\t\tround,\r\n\t\tprevStep: future ? prevStep : step,\r\n\t\t// isFirstStep: future && isFirstStep\r\n\t})\r\n\r\n\tif (timeToStepChange === undefined) {\r\n\t\t// Can't reliably determine \"time to next update\"\r\n\t\t// if not all of the steps provide `minTime`.\r\n\t\treturn\r\n\t}\r\n\r\n\tlet timeToNextUpdate\r\n\r\n\tif (step) {\r\n\t\tif (step.getTimeToNextUpdate) {\r\n\t\t\ttimeToNextUpdate = step.getTimeToNextUpdate(timestamp, {\r\n\t\t\t\tgetTimeToNextUpdateForUnit,\r\n\t\t\t\tgetRoundFunction,\r\n\t\t\t\tnow,\r\n\t\t\t\tfuture,\r\n\t\t\t\tround\r\n\t\t\t})\r\n\t\t}\r\n\r\n\t\tif (timeToNextUpdate === undefined) {\r\n\t\t\t// \"unit\" is now called \"formatAs\".\r\n\t\t\tconst unit = step.unit || step.formatAs\r\n\t\t\tif (unit) {\r\n\t\t\t\t// For some units, like \"now\", there's no defined amount of seconds in them.\r\n\t\t\t\t// In such cases, `getTimeToNextUpdateForUnit()` returns `undefined`,\r\n\t\t\t\t// and the next step's `minTime` could be used to calculate the update interval:\r\n\t\t\t\t// it will just assume that the label never changes for this step.\r\n\t\t\t\ttimeToNextUpdate = getTimeToNextUpdateForUnit(unit)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (timeToNextUpdate === undefined) {\r\n\t\treturn timeToStepChange\r\n\t}\r\n\r\n\treturn Math.min(timeToNextUpdate, timeToStepChange)\r\n}\r\n\r\nexport function getStepChangesAt(currentOrNextStep, timestamp, { now, future, round, prevStep }) {\r\n\t// The first step's `minTime` is `0` by default.\r\n\t// It doesn't \"change\" steps at zero point\r\n\t// but it does change the wording when switching\r\n\t// from \"future\" to \"past\": \"in ...\" -> \"... ago\".\r\n\t// Therefore, the label should be updated at zero-point too.\r\n\tconst minTime = getStepMinTime(currentOrNextStep, { timestamp, now, future, round, prevStep })\r\n\tif (minTime === undefined) {\r\n\t\treturn\r\n\t}\r\n\tif (future) {\r\n\t\t// The step changes to the previous step\r\n\t\t// as soon as `timestamp - now` becomes\r\n\t\t// less than the `minTime` of the current step:\r\n\t\t// `timestamp - now === minTime - 1`\r\n\t\t// => `now === timestamp - minTime + 1`.\r\n\t\treturn timestamp - minTime * 1000 + 1\r\n\t} else {\r\n\t\t// The step changes to the next step\r\n\t\t// as soon as `now - timestamp` becomes\r\n\t\t// equal to `minTime` of the next step:\r\n\t\t// `now - timestamp === minTime`\r\n\t\t// => `now === timestamp + minTime`.\r\n\r\n\t\t// This is a special case when double-update could be skipped.\r\n\t\tif (minTime === 0 && timestamp === now) {\r\n\t\t\treturn INFINITY\r\n\t\t}\r\n\r\n\t\treturn timestamp + minTime * 1000\r\n\t}\r\n}\r\n\r\nexport function getTimeToStepChange(step, timestamp, {\r\n\tnow,\r\n\tfuture,\r\n\tround,\r\n\tprevStep\r\n}) {\r\n\tif (step) {\r\n\t\tconst stepChangesAt = getStepChangesAt(step, timestamp, {\r\n\t\t\tnow,\r\n\t\t\tfuture,\r\n\t\t\tround,\r\n\t\t\tprevStep\r\n\t\t})\r\n\t\tif (stepChangesAt === undefined) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\treturn stepChangesAt - now\r\n\t} else {\r\n\t\tif (future) {\r\n\t\t\t// No step.\r\n\t\t\t// Update right after zero point, when it changes from \"future\" to \"past\".\r\n\t\t\treturn timestamp - now + 1\r\n\t\t} else {\r\n\t\t\t// The last step doesn't ever change when `date` is in the past.\r\n\t\t\treturn INFINITY\r\n\t\t}\r\n\t}\r\n}"],"mappings":"AAAA,OAAOA,2BAAP,MAAwC,iCAAxC;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,SAASC,gBAAT,QAAiC,aAAjC,C,CAEA;;AACA,IAAMC,IAAI,GAAG,MAAM,EAAN,GAAW,EAAX,GAAgB,EAAhB,GAAqB,IAAlC;AACA,OAAO,IAAMC,QAAQ,GAAG,OAAOD,IAAxB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASE,mBAAT,CAA6BC,IAA7B,EAAmCC,IAAnC,QAAqF;EAAA,IAA1CC,QAA0C,QAA1CA,QAA0C;EAAA,IAAhCC,QAAgC,QAAhCA,QAAgC;EAAA,IAAtBC,GAAsB,QAAtBA,GAAsB;EAAA,IAAjBC,MAAiB,QAAjBA,MAAiB;EAAA,IAATC,KAAS,QAATA,KAAS;EACnG,IAAMC,SAA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AG,EAAHA,GADuD;MAEvDC,MAAM,EAANA,MAFuD;MAGvDC,KAAK,EAALA,KAHuD;MAIvDJ,QAAQ,EAARA;IAJuD,CAAlB,CAAtC;;IAMA,IAAImB,aAAa,KAAKR,SAAtB,EAAiC;MAChC;IACA;;IACD,OAAOQ,aAAa,GAAGjB,GAAvB;EACA,CAXD,MAWO;IACN,IAAIC,MAAJ,EAAY;MACX;MACA;MACA,OAAOE,SAAS,GAAGH,GAAZ,GAAkB,CAAzB;IACA,CAJD,MAIO;MACN;MACA,OAAON,QAAP;IACA;EACD;AACD"}
1
+ {"version":3,"file":"getTimeToNextUpdate.js","names":["_getTimeToNextUpdateForUnit","getStepMinTime","getRoundFunction","YEAR","INFINITY","getTimeToNextUpdate","date","step","_ref","prevStep","nextStep","now","future","round","timestamp","getTime","getTimeToNextUpdateForUnit","unit","timeToStepChange","getTimeToStepChange","undefined","timeToNextUpdate","formatAs","Math","min","getStepChangesAt","currentOrNextStep","_ref2","minTime","_ref3","stepChangesAt"],"sources":["../../source/steps/getTimeToNextUpdate.js"],"sourcesContent":["import _getTimeToNextUpdateForUnit from './getTimeToNextUpdateForUnit.js'\r\nimport getStepMinTime from './getStepMinTime.js'\r\nimport { getRoundFunction } from '../round.js'\r\n\r\n// A thousand years is practically a metaphor for \"infinity\".\r\nconst YEAR = 365 * 24 * 60 * 60 * 1000\r\n// It can't really return `Infinity` in order to not screw any potential calculations performed with it.\r\n// Hence, it emulates `Infinity` with a really large number that is \"practically infinite\".\r\nexport const INFINITY = 1000 * YEAR\r\n\r\n/**\r\n * Returns the time (in milliseconds) after which the formatted date label should be refreshed.\r\n * @param {number} date — The date passed to `.format()`, converted to a timestamp.\r\n * @param {object} step\r\n * @param {object} [options.previousStep]\r\n * @param {object} [options.nextStep]\r\n * @param {number} options.now\r\n * @param {boolean} options.future\r\n * @param {string} [options.round] - (undocumented) Rounding mechanism.\r\n * @return {number} [timeToNextUpdate] Returns the time to next update. Returns `undefined` when it can't determine time to next update. That could only happen when the \"style\" doesn't meet the minimum requirements for `getTimeToNextUpdate: true` feature (see README).\r\n */\r\nexport default function getTimeToNextUpdate(date, step, { prevStep, nextStep, now, future, round }) {\r\n\tconst timestamp = date.getTime ? date.getTime() : date\r\n\r\n\tconst getTimeToNextUpdateForUnit = (unit) => _getTimeToNextUpdateForUnit(unit, timestamp, { now, round })\r\n\r\n\t// For future dates, steps move from the last one to the first one,\r\n\t// while for past dates, steps move from the first one to the last one,\r\n\t// due to the fact that time flows in one direction,\r\n\t// and future dates' interval naturally becomes smaller\r\n\t// while past dates' interval naturally grows larger.\r\n\t//\r\n\t// For future dates, it's the transition\r\n\t// from the current step to the previous step,\r\n\t// therefore check the `minTime` of the current step.\r\n\t//\r\n\t// For past dates, it's the transition\r\n\t// from the current step to the next step,\r\n\t// therefore check the `minTime` of the next step.\r\n\t//\r\n\tconst timeToStepChange = getTimeToStepChange(future ? step : nextStep, timestamp, {\r\n\t\tfuture,\r\n\t\tnow,\r\n\t\tround,\r\n\t\tprevStep: future ? prevStep : step,\r\n\t\t// isFirstStep: future && isFirstStep\r\n\t})\r\n\r\n\t// If the \"style\" doesn't meet the minimum requirements for `getTimeToNextUpdate: true` feature (see README)\r\n\t// then `timeToStepChange` will be `undefined`. In that case, just return `undefined`.\r\n\tif (timeToStepChange === undefined) {\r\n\t\t// Can't reliably determine \"time to next update\"\r\n\t\t// if not all of the steps provide `minTime`.\r\n\t\treturn\r\n\t}\r\n\r\n\tlet timeToNextUpdate\r\n\r\n\tif (step) {\r\n\t\tif (step.getTimeToNextUpdate) {\r\n\t\t\ttimeToNextUpdate = step.getTimeToNextUpdate(timestamp, {\r\n\t\t\t\tgetTimeToNextUpdateForUnit,\r\n\t\t\t\tgetRoundFunction,\r\n\t\t\t\tnow,\r\n\t\t\t\tfuture,\r\n\t\t\t\tround\r\n\t\t\t})\r\n\t\t}\r\n\r\n\t\tif (timeToNextUpdate === undefined) {\r\n\t\t\t// \"unit\" is now called \"formatAs\".\r\n\t\t\tconst unit = step.unit || step.formatAs\r\n\t\t\tif (unit) {\r\n\t\t\t\t// For some units, like \"now\", there's no defined amount of seconds in them.\r\n\t\t\t\t// In such cases, `getTimeToNextUpdateForUnit()` returns `undefined`,\r\n\t\t\t\t// and the next step's `minTime` could be used to calculate the update interval:\r\n\t\t\t\t// it will just assume that the label never changes for this step.\r\n\t\t\t\ttimeToNextUpdate = getTimeToNextUpdateForUnit(unit)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (timeToNextUpdate === undefined) {\r\n\t\treturn timeToStepChange\r\n\t}\r\n\r\n\treturn Math.min(timeToNextUpdate, timeToStepChange)\r\n}\r\n\r\n// Returns the timestamp at which it'll move to the next step.\r\n// Returns `undefined` when it can't determine when it'll move to the next stemp. That could only happen when the \"style\" doesn't meet the minimum requirements for `getTimeToNextUpdate: true` feature (see README).\r\nexport function getStepChangesAt(currentOrNextStep, timestamp, { now, future, round, prevStep }) {\r\n\t// The first step's `minTime` is `0` by default.\r\n\t// It doesn't \"change\" steps at zero point\r\n\t// but it does change the wording when switching\r\n\t// from \"future\" to \"past\": \"in ...\" -> \"... ago\".\r\n\t// Therefore, the label should be updated at zero-point too.\r\n\tconst minTime = getStepMinTime(currentOrNextStep, { timestamp, now, future, round, prevStep })\r\n\tif (minTime === undefined) {\r\n\t\treturn\r\n\t}\r\n\tif (future) {\r\n\t\t// The step changes to the previous step\r\n\t\t// as soon as `timestamp - now` becomes\r\n\t\t// less than the `minTime` of the current step:\r\n\t\t// `timestamp - now === minTime - 1`\r\n\t\t// => `now === timestamp - minTime + 1`.\r\n\t\treturn timestamp - minTime * 1000 + 1\r\n\t} else {\r\n\t\t// The step changes to the next step\r\n\t\t// as soon as `now - timestamp` becomes\r\n\t\t// equal to `minTime` of the next step:\r\n\t\t// `now - timestamp === minTime`\r\n\t\t// => `now === timestamp + minTime`.\r\n\r\n\t\t// This is a special case when double-update could be skipped.\r\n\t\tif (minTime === 0 && timestamp === now) {\r\n\t\t\treturn INFINITY\r\n\t\t}\r\n\r\n\t\treturn timestamp + minTime * 1000\r\n\t}\r\n}\r\n\r\nexport function getTimeToStepChange(step, timestamp, {\r\n\tnow,\r\n\tfuture,\r\n\tround,\r\n\tprevStep\r\n}) {\r\n\tif (step) {\r\n\t\tconst stepChangesAt = getStepChangesAt(step, timestamp, {\r\n\t\t\tnow,\r\n\t\t\tfuture,\r\n\t\t\tround,\r\n\t\t\tprevStep\r\n\t\t})\r\n\t\tif (stepChangesAt === undefined) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\treturn stepChangesAt - now\r\n\t} else {\r\n\t\tif (future) {\r\n\t\t\t// No step.\r\n\t\t\t// Update right after zero point, when it changes from \"future\" to \"past\".\r\n\t\t\treturn timestamp - now + 1\r\n\t\t} else {\r\n\t\t\t// The last step doesn't ever change when `date` is in the past.\r\n\t\t\treturn INFINITY\r\n\t\t}\r\n\t}\r\n}"],"mappings":"AAAA,OAAOA,2BAA2B,MAAM,iCAAiC;AACzE,OAAOC,cAAc,MAAM,qBAAqB;AAChD,SAASC,gBAAgB,QAAQ,aAAa;;AAE9C;AACA,IAAMC,IAAI,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;AACtC;AACA;AACA,OAAO,IAAMC,QAAQ,GAAG,IAAI,GAAGD,IAAI;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASE,mBAAmBA,CAACC,IAAI,EAAEC,IAAI,EAAAC,IAAA,EAA8C;EAAA,IAA1CC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IAAEC,GAAG,GAAAH,IAAA,CAAHG,GAAG;IAAEC,MAAM,GAAAJ,IAAA,CAANI,MAAM;IAAEC,KAAK,GAAAL,IAAA,CAALK,KAAK;EAC/F,IAAMC,SAAS,GAAGR,IAAI,CAACS,OAAO,GAAGT,IAAI,CAACS,OAAO,CAAC,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,MAAM,EAANA,MAAM;MACNC,KAAK,EAALA,KAAK;MACLJ,QAAQ,EAARA;IACD,CAAC,CAAC;IACF,IAAIqB,aAAa,KAAKV,SAAS,EAAE;MAChC;IACD;IACA,OAAOU,aAAa,GAAGnB,GAAG;EAC3B,CAAC,MAAM;IACN,IAAIC,MAAM,EAAE;MACX;MACA;MACA,OAAOE,SAAS,GAAGH,GAAG,GAAG,CAAC;IAC3B,CAAC,MAAM;MACN;MACA,OAAOP,QAAQ;IAChB;EACD;AACD","ignoreList":[]}
@@ -166,11 +166,12 @@ describe('getStepChangesAt', function () {
166
166
  now: 0,
167
167
  future: false,
168
168
  prevStep: undefined
169
- }).should.equal(INFINITY); // Past.
169
+ }).should.equal(INFINITY);
170
+
171
+ // Past.
170
172
  // Is at zero point.
171
173
  // The next step is seconds.
172
174
  // Updates at the next step.
173
-
174
175
  getStepChangesAt({
175
176
  unit: 'second',
176
177
  minTime: 1
@@ -178,32 +179,35 @@ describe('getStepChangesAt', function () {
178
179
  now: 0,
179
180
  future: false,
180
181
  prevStep: {}
181
- }).should.equal(1 * 1000); // Future.
182
+ }).should.equal(1 * 1000);
183
+
184
+ // Future.
182
185
  // Inside the first step.
183
186
  // Updates after zero point.
184
-
185
187
  getStepChangesAt({
186
188
  unit: 'now'
187
189
  }, 0.9 * 1000, {
188
190
  now: 0,
189
191
  future: true,
190
192
  prevStep: undefined
191
- }).should.equal(0.9 * 1000 + 1); // Future.
193
+ }).should.equal(0.9 * 1000 + 1);
194
+
195
+ // Future.
192
196
  // The first step doesn't start at 0.
193
197
  // Outside of the first step.
194
198
  // Updates right after zero point.
195
-
196
199
  getTimeToStepChange(undefined, 0.9 * 1000, {
197
200
  now: 0,
198
201
  future: true,
199
202
  prevStep: undefined
200
- }).should.equal(0.9 * 1000 + 1); // Past.
203
+ }).should.equal(0.9 * 1000 + 1);
204
+
205
+ // Past.
201
206
  // The current step is `undefined`.
202
207
  // The next step is the first step.
203
208
  // The first step doesn't start at 0.
204
209
  // Outside of the first step.
205
210
  // Updates at entering the first step.
206
-
207
211
  getStepChangesAt({
208
212
  minTime: 1,
209
213
  unit: 'second'
@@ -211,10 +215,11 @@ describe('getStepChangesAt', function () {
211
215
  now: 0,
212
216
  future: false,
213
217
  prevStep: {}
214
- }).should.equal(0.1 * 1000); // Future.
218
+ }).should.equal(0.1 * 1000);
219
+
220
+ // Future.
215
221
  // The first step doesn't start at 0.
216
222
  // Will output empty string after it exits the current step.
217
-
218
223
  getStepChangesAt({
219
224
  minTime: 1,
220
225
  unit: 'second'
@@ -222,39 +227,43 @@ describe('getStepChangesAt', function () {
222
227
  now: 0,
223
228
  future: true,
224
229
  prevStep: undefined
225
- }).should.equal(0.1 * 1000 + 1); // Past.
230
+ }).should.equal(0.1 * 1000 + 1);
231
+
232
+ // Past.
226
233
  // Next step is seconds.
227
234
  // The "next" step doesn't have `minTime`,
228
235
  // so "time to next update" couldn't be determined.
229
-
230
236
  expect(getStepChangesAt({
231
237
  unit: 'unknown-time-unit'
232
238
  }, 0, {
233
239
  now: 0,
234
240
  future: false,
235
241
  prevStep: {}
236
- })).to.be.undefined; // Past.
242
+ })).to.be.undefined;
243
+
244
+ // Past.
237
245
  // No next step.
238
246
  // The last step never changes.
239
-
240
247
  getTimeToStepChange(undefined, 0, {
241
248
  now: 0,
242
249
  future: false,
243
250
  isFirstStep: undefined
244
- }).should.equal(INFINITY); // Future.
251
+ }).should.equal(INFINITY);
252
+
253
+ // Future.
245
254
  // Current step is seconds.
246
255
  // Updates after zero point.
247
-
248
256
  getStepChangesAt({
249
257
  unit: 'second'
250
258
  }, 0, {
251
259
  now: 0,
252
260
  future: true,
253
261
  prevStep: undefined
254
- }).should.equal(1); // Past.
262
+ }).should.equal(1);
263
+
264
+ // Past.
255
265
  // Next step is minutes.
256
266
  // Already at zero point, so no need to update at zero point.
257
-
258
267
  getStepChangesAt({
259
268
  minTime: 60,
260
269
  formatAs: 'minute'
@@ -1 +1 @@
1
- {"version":3,"file":"getTimeToNextUpdate.test.js","names":["getTimeToNextUpdate","INFINITY","getStepChangesAt","getTimeToStepChange","describe","it","expect","minTime","format","now","future","isFirstStep","to","equal","Date","nextStep","formatAs","be","undefined","should","test","unit","prevStep"],"sources":["../../source/steps/getTimeToNextUpdate.test.js"],"sourcesContent":["import getTimeToNextUpdate, { INFINITY, getStepChangesAt, getTimeToStepChange } from './getTimeToNextUpdate.js'\r\n\r\ndescribe('getTimeToNextUpdate', () => {\r\n\tit('should return infinity when there are no more steps, and it does not format as a unit (past)', () => {\r\n\t\texpect(getTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tminTime: 59.5,\r\n\t\t\tformat: () => ''\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true\r\n\t\t})).to.equal(INFINITY)\r\n\t})\r\n\r\n\tit('should support date argument', () => {\r\n\t\texpect(getTimeToNextUpdate(new Date(4 * 60 * 1000), {\r\n\t\t\tminTime: 60\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {}\r\n\t\t})).to.equal(3 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should return this step\\'s \"minTime\" timestamp (future)', () => {\r\n\t\texpect(getTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tminTime: 60,\r\n\t\t\tformat: () => ''\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformat: () => ''\r\n\t\t\t}\r\n\t\t})).to.equal(3 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should return undefined when there is a next step and time to next update can not be reliably determined (formatAs) (past)', () => {\r\n\t\texpect(getTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tminTime: 60,\r\n\t\t\tformatAs: 'minute'\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'unknown-time-unit'\r\n\t\t\t}\r\n\t\t})).to.be.undefined\r\n\t})\r\n\r\n\tit('should get time to next update (no next step) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.5 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (no next step) (future)', () => {\r\n\t\tgetTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.5 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should get time to next update (has prev/next step without `minTime`) (future)', () => {\r\n\t\tgetTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'hour',\r\n\t\t\t\ttest: () => false\r\n\t\t\t}\r\n\t\t}).should.equal(0.5 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should get time to next update (has `getTimeToNextUpdate`) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5,\r\n\t\t\tgetTimeToNextUpdate: () => 0.25 * 60 * 1000\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.25 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (has `getTimeToNextUpdate`) (future)', () => {\r\n\t\tgetTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5,\r\n\t\t\tgetTimeToNextUpdate: () => 0.25 * 60 * 1000\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.25 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (has both unit and prev/next steps with `minTime`) (returns time to \"minTime\" of next step) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-59 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'hour',\r\n\t\t\t\tminTime: 59.5 * 60\r\n\t\t\t}\r\n\t\t}).should.equal(0.5 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (has no unit but has prev/next step with `minTime`) (returns time to \"minTime\" of next step) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-59 * 60 * 1000, {\r\n\t\t\tformat: () => {},\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'hour',\r\n\t\t\t\tminTime: 59.5 * 60\r\n\t\t\t}\r\n\t\t}).should.equal(0.5 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (will be outside of the first step) (future)', () => {\r\n\t\tgetTimeToNextUpdate(60 * 60 * 1000, {\r\n\t\t\tformatAs: 'hour',\r\n\t\t\tminTime: 60 * 60\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(1)\r\n\t})\r\n})\r\n\r\ndescribe('getStepChangesAt', () => {\r\n\tit('should work for \"round\" steps', () => {\r\n\t\t// Future.\r\n\t\t// Is at zero point.\r\n\t\t// No next step.\r\n\t\t// No tickable unit.\r\n\t\t// Doesn't update.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'now'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(INFINITY)\r\n\r\n\t\t// Past.\r\n\t\t// Is at zero point.\r\n\t\t// The next step is seconds.\r\n\t\t// Updates at the next step.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'second',\r\n\t\t\tminTime: 1\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t}).should.equal(1 * 1000)\r\n\r\n\t\t// Future.\r\n\t\t// Inside the first step.\r\n\t\t// Updates after zero point.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'now'\r\n\t\t}, 0.9 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(0.9 * 1000 + 1)\r\n\r\n\t\t// Future.\r\n\t\t// The first step doesn't start at 0.\r\n\t\t// Outside of the first step.\r\n\t\t// Updates right after zero point.\r\n\t\tgetTimeToStepChange(undefined, 0.9 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(0.9 * 1000 + 1)\r\n\r\n\t\t// Past.\r\n\t\t// The current step is `undefined`.\r\n\t\t// The next step is the first step.\r\n\t\t// The first step doesn't start at 0.\r\n\t\t// Outside of the first step.\r\n\t\t// Updates at entering the first step.\r\n\t\tgetStepChangesAt({\r\n\t\t\tminTime: 1,\r\n\t\t\tunit: 'second'\r\n\t\t}, -0.9 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t}).should.equal(0.1 * 1000)\r\n\r\n\t\t// Future.\r\n\t\t// The first step doesn't start at 0.\r\n\t\t// Will output empty string after it exits the current step.\r\n\t\tgetStepChangesAt({\r\n\t\t\tminTime: 1,\r\n\t\t\tunit: 'second'\r\n\t\t}, 1.1 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(0.1 * 1000 + 1)\r\n\r\n\t\t// Past.\r\n\t\t// Next step is seconds.\r\n\t\t// The \"next\" step doesn't have `minTime`,\r\n\t\t// so \"time to next update\" couldn't be determined.\r\n\t\texpect(getStepChangesAt({\r\n\t\t\tunit: 'unknown-time-unit'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t})).to.be.undefined\r\n\r\n\t\t// Past.\r\n\t\t// No next step.\r\n\t\t// The last step never changes.\r\n\t\tgetTimeToStepChange(undefined, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: undefined\r\n\t\t}).should.equal(INFINITY)\r\n\r\n\t\t// Future.\r\n\t\t// Current step is seconds.\r\n\t\t// Updates after zero point.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'second'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(1)\r\n\r\n\t\t// Past.\r\n\t\t// Next step is minutes.\r\n\t\t// Already at zero point, so no need to update at zero point.\r\n\t\tgetStepChangesAt({\r\n\t\t\tminTime: 60,\r\n\t\t\tformatAs: 'minute'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t}).should.equal(60 * 1000)\r\n\t})\r\n})"],"mappings":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CAOgB,KAAK,IAPrB;EAQA,CAtHC,CAAF;AAuHA,CAxHO,CAAR"}
1
+ {"version":3,"file":"getTimeToNextUpdate.test.js","names":["getTimeToNextUpdate","INFINITY","getStepChangesAt","getTimeToStepChange","describe","it","expect","minTime","format","now","future","isFirstStep","to","equal","Date","nextStep","formatAs","be","undefined","should","test","unit","prevStep"],"sources":["../../source/steps/getTimeToNextUpdate.test.js"],"sourcesContent":["import getTimeToNextUpdate, { INFINITY, getStepChangesAt, getTimeToStepChange } from './getTimeToNextUpdate.js'\r\n\r\ndescribe('getTimeToNextUpdate', () => {\r\n\tit('should return infinity when there are no more steps, and it does not format as a unit (past)', () => {\r\n\t\texpect(getTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tminTime: 59.5,\r\n\t\t\tformat: () => ''\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true\r\n\t\t})).to.equal(INFINITY)\r\n\t})\r\n\r\n\tit('should support date argument', () => {\r\n\t\texpect(getTimeToNextUpdate(new Date(4 * 60 * 1000), {\r\n\t\t\tminTime: 60\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {}\r\n\t\t})).to.equal(3 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should return this step\\'s \"minTime\" timestamp (future)', () => {\r\n\t\texpect(getTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tminTime: 60,\r\n\t\t\tformat: () => ''\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformat: () => ''\r\n\t\t\t}\r\n\t\t})).to.equal(3 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should return undefined when there is a next step and time to next update can not be reliably determined (formatAs) (past)', () => {\r\n\t\texpect(getTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tminTime: 60,\r\n\t\t\tformatAs: 'minute'\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'unknown-time-unit'\r\n\t\t\t}\r\n\t\t})).to.be.undefined\r\n\t})\r\n\r\n\tit('should get time to next update (no next step) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.5 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (no next step) (future)', () => {\r\n\t\tgetTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.5 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should get time to next update (has prev/next step without `minTime`) (future)', () => {\r\n\t\tgetTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'hour',\r\n\t\t\t\ttest: () => false\r\n\t\t\t}\r\n\t\t}).should.equal(0.5 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should get time to next update (has `getTimeToNextUpdate`) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5,\r\n\t\t\tgetTimeToNextUpdate: () => 0.25 * 60 * 1000\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.25 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (has `getTimeToNextUpdate`) (future)', () => {\r\n\t\tgetTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5,\r\n\t\t\tgetTimeToNextUpdate: () => 0.25 * 60 * 1000\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.25 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (has both unit and prev/next steps with `minTime`) (returns time to \"minTime\" of next step) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-59 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'hour',\r\n\t\t\t\tminTime: 59.5 * 60\r\n\t\t\t}\r\n\t\t}).should.equal(0.5 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (has no unit but has prev/next step with `minTime`) (returns time to \"minTime\" of next step) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-59 * 60 * 1000, {\r\n\t\t\tformat: () => {},\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'hour',\r\n\t\t\t\tminTime: 59.5 * 60\r\n\t\t\t}\r\n\t\t}).should.equal(0.5 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (will be outside of the first step) (future)', () => {\r\n\t\tgetTimeToNextUpdate(60 * 60 * 1000, {\r\n\t\t\tformatAs: 'hour',\r\n\t\t\tminTime: 60 * 60\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(1)\r\n\t})\r\n})\r\n\r\ndescribe('getStepChangesAt', () => {\r\n\tit('should work for \"round\" steps', () => {\r\n\t\t// Future.\r\n\t\t// Is at zero point.\r\n\t\t// No next step.\r\n\t\t// No tickable unit.\r\n\t\t// Doesn't update.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'now'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(INFINITY)\r\n\r\n\t\t// Past.\r\n\t\t// Is at zero point.\r\n\t\t// The next step is seconds.\r\n\t\t// Updates at the next step.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'second',\r\n\t\t\tminTime: 1\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t}).should.equal(1 * 1000)\r\n\r\n\t\t// Future.\r\n\t\t// Inside the first step.\r\n\t\t// Updates after zero point.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'now'\r\n\t\t}, 0.9 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(0.9 * 1000 + 1)\r\n\r\n\t\t// Future.\r\n\t\t// The first step doesn't start at 0.\r\n\t\t// Outside of the first step.\r\n\t\t// Updates right after zero point.\r\n\t\tgetTimeToStepChange(undefined, 0.9 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(0.9 * 1000 + 1)\r\n\r\n\t\t// Past.\r\n\t\t// The current step is `undefined`.\r\n\t\t// The next step is the first step.\r\n\t\t// The first step doesn't start at 0.\r\n\t\t// Outside of the first step.\r\n\t\t// Updates at entering the first step.\r\n\t\tgetStepChangesAt({\r\n\t\t\tminTime: 1,\r\n\t\t\tunit: 'second'\r\n\t\t}, -0.9 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t}).should.equal(0.1 * 1000)\r\n\r\n\t\t// Future.\r\n\t\t// The first step doesn't start at 0.\r\n\t\t// Will output empty string after it exits the current step.\r\n\t\tgetStepChangesAt({\r\n\t\t\tminTime: 1,\r\n\t\t\tunit: 'second'\r\n\t\t}, 1.1 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(0.1 * 1000 + 1)\r\n\r\n\t\t// Past.\r\n\t\t// Next step is seconds.\r\n\t\t// The \"next\" step doesn't have `minTime`,\r\n\t\t// so \"time to next update\" couldn't be determined.\r\n\t\texpect(getStepChangesAt({\r\n\t\t\tunit: 'unknown-time-unit'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t})).to.be.undefined\r\n\r\n\t\t// Past.\r\n\t\t// No next step.\r\n\t\t// The last step never changes.\r\n\t\tgetTimeToStepChange(undefined, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: undefined\r\n\t\t}).should.equal(INFINITY)\r\n\r\n\t\t// Future.\r\n\t\t// Current step is seconds.\r\n\t\t// Updates after zero point.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'second'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(1)\r\n\r\n\t\t// Past.\r\n\t\t// Next step is minutes.\r\n\t\t// Already at zero point, so no need to update at zero point.\r\n\t\tgetStepChangesAt({\r\n\t\t\tminTime: 60,\r\n\t\t\tformatAs: 'minute'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0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