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,9 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _getStepDenominator = _interopRequireDefault(require("./getStepDenominator.js"));
4
-
5
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6
-
4
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
7
5
  describe('getStepDenominator', function () {
8
6
  it('should support the older "unit" name', function () {
9
7
  (0, _getStepDenominator["default"])({
@@ -1 +1 @@
1
- {"version":3,"file":"getStepDenominator.test.js","names":["describe","it","getStepDenominator","unit","should","equal","formatAs"],"sources":["../../source/steps/getStepDenominator.test.js"],"sourcesContent":["import getStepDenominator from './getStepDenominator.js'\r\n\r\ndescribe('getStepDenominator', () => {\r\n\tit('should support the older \"unit\" name', () => {\r\n\t\tgetStepDenominator({ unit: 'minute' }).should.equal(60)\r\n\t})\r\n\r\n\tit('should return 1 as a default \"denominator\"', () => {\r\n\t\tgetStepDenominator({ formatAs: 'exotic' }).should.equal(1)\r\n\t})\r\n})"],"mappings":";;AAAA;;;;AAEAA,QAAQ,CAAC,oBAAD,EAAuB,YAAM;EACpCC,EAAE,CAAC,sCAAD,EAAyC,YAAM;IAChD,IAAAC,8BAAA,EAAmB;MAAEC,IAAI,EAAE;IAAR,CAAnB,EAAuCC,MAAvC,CAA8CC,KAA9C,CAAoD,EAApD;EACA,CAFC,CAAF;EAIAJ,EAAE,CAAC,4CAAD,EAA+C,YAAM;IACtD,IAAAC,8BAAA,EAAmB;MAAEI,QAAQ,EAAE;IAAZ,CAAnB,EAA2CF,MAA3C,CAAkDC,KAAlD,CAAwD,CAAxD;EACA,CAFC,CAAF;AAGA,CARO,CAAR"}
1
+ {"version":3,"file":"getStepDenominator.test.js","names":["_getStepDenominator","_interopRequireDefault","require","e","__esModule","describe","it","getStepDenominator","unit","should","equal","formatAs"],"sources":["../../source/steps/getStepDenominator.test.js"],"sourcesContent":["import getStepDenominator from './getStepDenominator.js'\r\n\r\ndescribe('getStepDenominator', () => {\r\n\tit('should support the older \"unit\" name', () => {\r\n\t\tgetStepDenominator({ unit: 'minute' }).should.equal(60)\r\n\t})\r\n\r\n\tit('should return 1 as a default \"denominator\"', () => {\r\n\t\tgetStepDenominator({ formatAs: 'exotic' }).should.equal(1)\r\n\t})\r\n})"],"mappings":";;AAAA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAwD,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAExDE,QAAQ,CAAC,oBAAoB,EAAE,YAAM;EACpCC,EAAE,CAAC,sCAAsC,EAAE,YAAM;IAChD,IAAAC,8BAAkB,EAAC;MAAEC,IAAI,EAAE;IAAS,CAAC,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,EAAE,CAAC;EACxD,CAAC,CAAC;EAEFJ,EAAE,CAAC,4CAA4C,EAAE,YAAM;IACtD,IAAAC,8BAAkB,EAAC;MAAEI,QAAQ,EAAE;IAAS,CAAC,CAAC,CAACF,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC;EAC3D,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
@@ -4,45 +4,48 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = getStepMinTime;
7
-
8
7
  var _units = require("./units.js");
9
-
10
8
  var _round = require("../round.js");
11
-
12
- 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); }
13
-
9
+ 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); }
14
10
  function getStepMinTime(step, _ref) {
15
11
  var prevStep = _ref.prevStep,
16
- timestamp = _ref.timestamp,
17
- now = _ref.now,
18
- future = _ref.future,
19
- round = _ref.round;
20
- var minTime; // "threshold_for_xxx" is a legacy property.
21
-
12
+ timestamp = _ref.timestamp,
13
+ now = _ref.now,
14
+ future = _ref.future,
15
+ round = _ref.round;
16
+ var minTime;
17
+
18
+ // (deprecated)
19
+ // Get `minTime` from "threshold_for_xxx" property of the `step`.
20
+ // "threshold_for_xxx" property of a `step` is deprecated.
22
21
  if (prevStep) {
23
22
  if (prevStep.id || prevStep.unit) {
24
23
  minTime = step["threshold_for_".concat(prevStep.id || prevStep.unit)];
25
24
  }
26
25
  }
27
26
 
27
+ // (deprecated)
28
+ // Get `minTime` from "threshold" property of the `step`.
29
+ // "threshold" property of a `step` is deprecated.
28
30
  if (minTime === undefined) {
29
- // "threshold" is a legacy property.
30
31
  if (step.threshold !== undefined) {
31
32
  // "threshold" is a legacy name for "minTime".
32
- minTime = step.threshold; // "threshold" function is deprecated.
33
-
33
+ minTime = step.threshold;
34
+ // "threshold" function is deprecated.
34
35
  if (typeof minTime === 'function') {
35
36
  minTime = minTime(now, future);
36
37
  }
37
38
  }
38
39
  }
39
40
 
41
+ // Get `minTime` from `minTime` property of the `step`.
42
+ // This is the only non-deprecated source for the `minTime` property.
40
43
  if (minTime === undefined) {
41
44
  minTime = step.minTime;
42
- } // A deprecated way of specifying a different threshold
43
- // depending on the previous step's unit.
44
-
45
+ }
45
46
 
47
+ // (deprecated)
48
+ // If `minTime` is an object, calculate `minTime` from the previous step's `unit`.
46
49
  if (_typeof(minTime) === 'object') {
47
50
  if (prevStep && prevStep.id && minTime[prevStep.id] !== undefined) {
48
51
  minTime = minTime[prevStep.id];
@@ -51,6 +54,7 @@ function getStepMinTime(step, _ref) {
51
54
  }
52
55
  }
53
56
 
57
+ // If `minTime` is a function, call it with certain arguments.
54
58
  if (typeof minTime === 'function') {
55
59
  minTime = minTime(timestamp, {
56
60
  future: future,
@@ -60,10 +64,11 @@ function getStepMinTime(step, _ref) {
60
64
  });
61
65
  }
62
66
  });
63
- } // Evaluate the `test()` function.
64
- // `test()` function is deprecated.
65
-
67
+ }
66
68
 
69
+ // (deprecated)
70
+ // Get `minTime` from `step.test()` function property.
71
+ // `step.test` property is deprecated.
67
72
  if (minTime === undefined) {
68
73
  if (step.test) {
69
74
  if (step.test(timestamp, {
@@ -79,6 +84,8 @@ function getStepMinTime(step, _ref) {
79
84
  }
80
85
  }
81
86
 
87
+ // If `minTime` is `undefined`, calculate it from the previous `step`.
88
+ // If it's the first step and there's no previous one, the `minTime` is assumed `0`.
82
89
  if (minTime === undefined) {
83
90
  if (prevStep) {
84
91
  if (step.formatAs && prevStep.formatAs) {
@@ -90,33 +97,18 @@ function getStepMinTime(step, _ref) {
90
97
  // The first step's `minTime` is `0` by default.
91
98
  minTime = 0;
92
99
  }
93
- } // Warn if no `minTime` was defined or could be deduced.
94
-
100
+ }
95
101
 
102
+ // Warn if no `minTime` is defined for this step.
96
103
  if (minTime === undefined) {
97
104
  console.warn('[javascript-time-ago] A step should specify `minTime`:\n' + JSON.stringify(step, null, 2));
98
105
  }
99
-
100
106
  return minTime;
101
107
  }
102
-
103
108
  function _getMinTimeForUnit(toUnit, fromUnit, _ref2) {
104
109
  var round = _ref2.round;
105
- var toUnitAmount = (0, _units.getSecondsInUnit)(toUnit); // if (!fromUnit) {
106
- // return toUnitAmount;
107
- // }
108
- // if (!fromUnit) {
109
- // fromUnit = getPreviousUnitFor(toUnit)
110
- // }
111
-
112
- var fromUnitAmount;
113
-
114
- if (fromUnit === 'now') {
115
- fromUnitAmount = (0, _units.getSecondsInUnit)(toUnit);
116
- } else {
117
- fromUnitAmount = (0, _units.getSecondsInUnit)(fromUnit);
118
- }
119
-
110
+ var toUnitAmount = (0, _units.getSecondsInUnit)(toUnit);
111
+ var fromUnitAmount = fromUnit === 'now' ? (0, _units.getSecondsInUnit)(toUnit) : (0, _units.getSecondsInUnit)(fromUnit);
120
112
  if (toUnitAmount !== undefined && fromUnitAmount !== undefined) {
121
113
  return toUnitAmount - fromUnitAmount * (1 - (0, _round.getDiffRatioToNextRoundedNumber)(round));
122
114
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getStepMinTime.js","names":["getStepMinTime","step","prevStep","timestamp","now","future","round","minTime","id","unit","undefined","threshold","getMinTimeForUnit","toUnit","fromUnit","formatAs","test","console","warn","JSON","stringify","toUnitAmount","getSecondsInUnit","fromUnitAmount","getDiffRatioToNextRoundedNumber"],"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;;AACA;;;;AAEe,SAASA,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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ba,cAAc,KAAKb,SAArD,EAAgE;IAC/D,OAAOW,YAAY,GAAGE,cAAc,IAAI,IAAI,IAAAC,sCAAA,EAAgClB,KAAhC,CAAR,CAApC;EACA;AACD"}
1
+ {"version":3,"file":"getStepMinTime.js","names":["_units","require","_round","_typeof","o","Symbol","iterator","constructor","prototype","getStepMinTime","step","_ref","prevStep","timestamp","now","future","round","minTime","id","unit","concat","undefined","threshold","getMinTimeForUnit","toUnit","fromUnit","formatAs","test","console","warn","JSON","stringify","_ref2","toUnitAmount","getSecondsInUnit","fromUnitAmount","getDiffRatioToNextRoundedNumber"],"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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAA6D,SAAAE,QAAAC,CAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,CAAA,kBAAAA,CAAA,gBAAAA,CAAA,WAAAA,CAAA,yBAAAC,MAAA,IAAAD,CAAA,CAAAG,WAAA,KAAAF,MAAA,IAAAD,CAAA,KAAAC,MAAA,CAAAG,SAAA,qBAAAJ,CAAA,KAAAD,OAAA,CAAAC,CAAA;AAE9C,SAASK,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,IAAIL,QAAQ,EAAE;IACb,IAAIA,QAAQ,CAACM,EAAE,IAAIN,QAAQ,CAACO,IAAI,EAAE;MACjCF,OAAO,GAAGP,IAAI,kBAAAU,MA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./getStepMinTime.js"));
4
-
5
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6
-
4
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
7
5
  describe('getStepMinTime', function () {
8
6
  it('should support `step.test()` function (returns true)', function () {
9
7
  (0, _getStepMinTime["default"])({
@@ -1 +1 @@
1
- {"version":3,"file":"getStepMinTime.test.js","names":["describe","it","getStepMinTime","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;;;;AAEAA,QAAQ,CAAC,gBAAD,EAAmB,YAAM;EAChCC,EAAE,CAAC,sDAAD,EAAyD,YAAM;IAChE,IAAAC,0BAAA,EAAe;MACdC,IAAI,EAAE;QAAA,OAAM,IAAN;MAAA;IADQ,CAAf,EAEG;MACFC,QAAQ,EAAE;QAAEC,OAAO,EAAE;MAAX;IADR,CAFH,EAIGC,MAJH,CAIUC,KAJV,CAIgB,CAJhB;EAKA,CANC,CAAF;EAQAN,EAAE,CAAC,uDAAD,EAA0D,YAAM;IACjE,IAAAC,0BAAA,EAAe;MACdC,IAAI,EAAE;QAAA,OAAM,KAAN;MAAA;IADQ,CAAf,EAEG;MACFC,QAAQ,EAAE;QAAEC,OAAO,EAAE;MAAX;IADR,CAFH,EAIGC,MAJH,CAIUC,KAJV,CAIgB,gBAJhB;EAKA,CANC,CAAF;AAOA,CAhBO,CAAR"}
1
+ {"version":3,"file":"getStepMinTime.test.js","names":["_getStepMinTime","_interopRequireDefault","require","e","__esModule","describe","it","getStepMinTime","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,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAgD,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAEhDE,QAAQ,CAAC,gBAAgB,EAAE,YAAM;EAChCC,EAAE,CAAC,sDAAsD,EAAE,YAAM;IAChE,IAAAC,0BAAc,EAAC;MACdC,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;EAEFN,EAAE,CAAC,uDAAuD,EAAE,YAAM;IACjE,IAAAC,0BAAc,EAAC;MACdC,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":[]}
@@ -7,20 +7,18 @@ exports.INFINITY = void 0;
7
7
  exports["default"] = getTimeToNextUpdate;
8
8
  exports.getStepChangesAt = getStepChangesAt;
9
9
  exports.getTimeToStepChange = getTimeToStepChange;
10
-
11
10
  var _getTimeToNextUpdateForUnit2 = _interopRequireDefault(require("./getTimeToNextUpdateForUnit.js"));
12
-
13
11
  var _getStepMinTime = _interopRequireDefault(require("./getStepMinTime.js"));
14
-
15
12
  var _round = require("../round.js");
16
-
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
18
-
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
19
14
  // A thousand years is practically a metaphor for "infinity".
20
15
  var YEAR = 365 * 24 * 60 * 60 * 1000;
21
- var INFINITY = 1000 * YEAR;
16
+ // It can't really return `Infinity` in order to not screw any potential calculations performed with it.
17
+ // Hence, it emulates `Infinity` with a really large number that is "practically infinite".
18
+ var INFINITY = exports.INFINITY = 1000 * YEAR;
19
+
22
20
  /**
23
- * Gets the time to next update for a date and a step.
21
+ * Returns the time (in milliseconds) after which the formatted date label should be refreshed.
24
22
  * @param {number} date — The date passed to `.format()`, converted to a timestamp.
25
23
  * @param {object} step
26
24
  * @param {object} [options.previousStep]
@@ -28,25 +26,23 @@ var INFINITY = 1000 * YEAR;
28
26
  * @param {number} options.now
29
27
  * @param {boolean} options.future
30
28
  * @param {string} [options.round] - (undocumented) Rounding mechanism.
31
- * @return {number} [timeToNextUpdate]
29
+ * @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).
32
30
  */
33
-
34
- exports.INFINITY = INFINITY;
35
-
36
31
  function getTimeToNextUpdate(date, step, _ref) {
37
32
  var prevStep = _ref.prevStep,
38
- nextStep = _ref.nextStep,
39
- now = _ref.now,
40
- future = _ref.future,
41
- round = _ref.round;
33
+ nextStep = _ref.nextStep,
34
+ now = _ref.now,
35
+ future = _ref.future,
36
+ round = _ref.round;
42
37
  var timestamp = date.getTime ? date.getTime() : date;
43
-
44
38
  var getTimeToNextUpdateForUnit = function getTimeToNextUpdateForUnit(unit) {
45
39
  return (0, _getTimeToNextUpdateForUnit2["default"])(unit, timestamp, {
46
40
  now: now,
47
41
  round: round
48
42
  });
49
- }; // For future dates, steps move from the last one to the first one,
43
+ };
44
+
45
+ // For future dates, steps move from the last one to the first one,
50
46
  // while for past dates, steps move from the first one to the last one,
51
47
  // due to the fact that time flows in one direction,
52
48
  // and future dates' interval naturally becomes smaller
@@ -60,24 +56,22 @@ function getTimeToNextUpdate(date, step, _ref) {
60
56
  // from the current step to the next step,
61
57
  // therefore check the `minTime` of the next step.
62
58
  //
63
-
64
-
65
59
  var timeToStepChange = getTimeToStepChange(future ? step : nextStep, timestamp, {
66
60
  future: future,
67
61
  now: now,
68
62
  round: round,
69
- prevStep: future ? prevStep : step // isFirstStep: future && isFirstStep
70
-
63
+ prevStep: future ? prevStep : step
64
+ // isFirstStep: future && isFirstStep
71
65
  });
72
66
 
67
+ // If the "style" doesn't meet the minimum requirements for `getTimeToNextUpdate: true` feature (see README)
68
+ // then `timeToStepChange` will be `undefined`. In that case, just return `undefined`.
73
69
  if (timeToStepChange === undefined) {
74
70
  // Can't reliably determine "time to next update"
75
71
  // if not all of the steps provide `minTime`.
76
72
  return;
77
73
  }
78
-
79
74
  var timeToNextUpdate;
80
-
81
75
  if (step) {
82
76
  if (step.getTimeToNextUpdate) {
83
77
  timeToNextUpdate = step.getTimeToNextUpdate(timestamp, {
@@ -88,11 +82,9 @@ function getTimeToNextUpdate(date, step, _ref) {
88
82
  round: round
89
83
  });
90
84
  }
91
-
92
85
  if (timeToNextUpdate === undefined) {
93
86
  // "unit" is now called "formatAs".
94
87
  var unit = step.unit || step.formatAs;
95
-
96
88
  if (unit) {
97
89
  // For some units, like "now", there's no defined amount of seconds in them.
98
90
  // In such cases, `getTimeToNextUpdateForUnit()` returns `undefined`,
@@ -102,19 +94,19 @@ function getTimeToNextUpdate(date, step, _ref) {
102
94
  }
103
95
  }
104
96
  }
105
-
106
97
  if (timeToNextUpdate === undefined) {
107
98
  return timeToStepChange;
108
99
  }
109
-
110
100
  return Math.min(timeToNextUpdate, timeToStepChange);
111
101
  }
112
102
 
103
+ // Returns the timestamp at which it'll move to the next step.
104
+ // 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).
113
105
  function getStepChangesAt(currentOrNextStep, timestamp, _ref2) {
114
106
  var now = _ref2.now,
115
- future = _ref2.future,
116
- round = _ref2.round,
117
- prevStep = _ref2.prevStep;
107
+ future = _ref2.future,
108
+ round = _ref2.round,
109
+ prevStep = _ref2.prevStep;
118
110
  // The first step's `minTime` is `0` by default.
119
111
  // It doesn't "change" steps at zero point
120
112
  // but it does change the wording when switching
@@ -127,11 +119,9 @@ function getStepChangesAt(currentOrNextStep, timestamp, _ref2) {
127
119
  round: round,
128
120
  prevStep: prevStep
129
121
  });
130
-
131
122
  if (minTime === undefined) {
132
123
  return;
133
124
  }
134
-
135
125
  if (future) {
136
126
  // The step changes to the previous step
137
127
  // as soon as `timestamp - now` becomes
@@ -145,21 +135,19 @@ function getStepChangesAt(currentOrNextStep, timestamp, _ref2) {
145
135
  // equal to `minTime` of the next step:
146
136
  // `now - timestamp === minTime`
147
137
  // => `now === timestamp + minTime`.
138
+
148
139
  // This is a special case when double-update could be skipped.
149
140
  if (minTime === 0 && timestamp === now) {
150
141
  return INFINITY;
151
142
  }
152
-
153
143
  return timestamp + minTime * 1000;
154
144
  }
155
145
  }
156
-
157
146
  function getTimeToStepChange(step, timestamp, _ref3) {
158
147
  var now = _ref3.now,
159
- future = _ref3.future,
160
- round = _ref3.round,
161
- prevStep = _ref3.prevStep;
162
-
148
+ future = _ref3.future,
149
+ round = _ref3.round,
150
+ prevStep = _ref3.prevStep;
163
151
  if (step) {
164
152
  var stepChangesAt = getStepChangesAt(step, timestamp, {
165
153
  now: now,
@@ -167,11 +155,9 @@ function getTimeToStepChange(step, timestamp, _ref3) {
167
155
  round: round,
168
156
  prevStep: prevStep
169
157
  });
170
-
171
158
  if (stepChangesAt === undefined) {
172
159
  return;
173
160
  }
174
-
175
161
  return stepChangesAt - now;
176
162
  } else {
177
163
  if (future) {
@@ -1 +1 @@
1
- {"version":3,"file":"getTimeToNextUpdate.js","names":["YEAR","INFINITY","getTimeToNextUpdate","date","step","prevStep","nextStep","now","future","round","timestamp","getTime","getTimeToNextUpdateForUnit","unit","_getTimeToNextUpdateForUnit","timeToStepChange","getTimeToStepChange","undefined","timeToNextUpdate","getRoundFunction","formatAs","Math","min","getStepChangesAt","currentOrNextStep","minTime","getStepMinTime","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 INFINIT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OAAO,GAAG,IAAtB,GAA6B,CAApC;EACA,CAPD,MAOO;IACN;IACA;IACA;IACA;IACA;IAEA;IACA,IAAIA,OAAO,KAAK,CAAZ,IAAiBf,SAAS,KAAKH,GAAnC,EAAwC;MACvC,OAAON,QAAP;IACA;;IAED,OAAOS,SAAS,GAAGe,OAAO,GAAG,IAA7B;EACA;AACD;;AAEM,SAAST,mBAAT,CAA6BZ,IAA7B,EAAmCM,SAAnC,SAKJ;EAAA,IAJFH,GAIE,SAJFA,GAIE;EAAA,IAHFC,MAGE,SAHFA,MAGE;EAAA,IAFFC,KAEE,SAFFA,KAEE;EAAA,IADFJ,QACE,SADFA,QACE;;EACF,IAAID,IAAJ,EAAU;IACT,IAAMuB,aAAa,GAAGJ,gBAAgB,CAACnB,IAAD,EAAOM,SAAP,EAAkB;MACvDH,GAAG,EAAHA,GADuD;MAEvDC,MAAM,EAANA,MAFuD;MAGvDC,KAAK,EAALA,KAHuD;MAIvDJ,QAAQ,EAARA;IAJuD,CAAlB,CAAtC;;IAMA,IAAIsB,aAAa,KAAKV,SAAtB,EAAiC;MAChC;IACA;;IACD,OAAOU,aAAa,GAAGpB,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":["_getTimeToNextUpdateForUnit2","_interopRequireDefault","require","_getStepMinTime","_round","e","__esModule","YEAR","INFINITY","exports","getTimeToNextUpdate","date","step","_ref","prevStep","nextStep","now","future","round","timestamp","getTime","getTimeToNextUpdateForUnit","unit","_getTimeToNextUpdateForUnit","timeToStepChange","getTimeToStepChange","undefined","timeToNextUpdate","getRoundFunction","formatAs","Math","min","getStepChangesAt","currentOrNextStep","_ref2","minTime","getStepMinTime","_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,IAAAA,4BAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAF,sB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CAAC,CAAC;EAC9F,IAAIqB,OAAO,KAAKT,SAAS,EAAE;IAC1B;EACD;EACA,IAAIT,MAAM,EAAE;IACX;IACA;IACA;IACA;IACA;IACA,OAAOE,SAAS,GAAGgB,OAAO,GAAG,IAAI,GAAG,CAAC;EACtC,CAAC,MAAM;IACN;IACA;IACA;IACA;IACA;;IAEA;IACA,IAAIA,OAAO,KAAK,CAAC,IAAIhB,SAAS,KAAKH,GAAG,EAAE;MACvC,OAAOR,QAAQ;IAChB;IAEA,OAAOW,SAAS,GAAGgB,OAAO,GAAG,IAAI;EAClC;AACD;AAEO,SAASV,mBAAmBA,CAACb,IAAI,EAAEO,SAAS,EAAAkB,KAAA,EAKhD;EAAA,IAJFrB,GAAG,GAAAqB,KAAA,CAAHrB,GAAG;IACHC,MAAM,GAAAoB,KAAA,CAANpB,MAAM;IACNC,KAAK,GAAAmB,KAAA,CAALnB,KAAK;IACLJ,QAAQ,GAAAuB,KAAA,CAARvB,QAAQ;EAER,IAAIF,IAAI,EAAE;IACT,IAAM0B,aAAa,GAAGN,gBAAgB,CAACpB,IAAI,EAAEO,SAAS,EAAE;MACvDH,GAAG,EAAHA,GAAG;MACHC,MAAM,EAANA,MAAM;MACNC,KAAK,EAALA,KAAK;MACLJ,QAAQ,EAARA;IACD,CAAC,CAAC;IACF,IAAIwB,aAAa,KAAKZ,SAAS,EAAE;MAChC;IACD;IACA,OAAOY,aAAa,GAAGtB,GAAG;EAC3B,CAAC,MAAM;IACN,IAAIC,MAAM,EAAE;MACX;MACA;MACA,OAAOE,SAAS,GAAGH,GAAG,GAAG,CAAC;IAC3B,CAAC,MAAM;MACN;MACA,OAAOR,QAAQ;IAChB;EACD;AACD","ignoreList":[]}
@@ -1,13 +1,8 @@
1
1
  "use strict";
2
2
 
3
- 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); }
4
-
3
+ 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); }
5
4
  var _getTimeToNextUpdate = _interopRequireWildcard(require("./getTimeToNextUpdate.js"));
6
-
7
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
8
-
9
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
10
-
5
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) { "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); } return f; })(e, t); }
11
6
  describe('getTimeToNextUpdate', function () {
12
7
  it('should return infinity when there are no more steps, and it does not format as a unit (past)', function () {
13
8
  expect((0, _getTimeToNextUpdate["default"])(-4 * 60 * 1000, {
@@ -175,11 +170,12 @@ describe('getStepChangesAt', function () {
175
170
  now: 0,
176
171
  future: false,
177
172
  prevStep: undefined
178
- }).should.equal(_getTimeToNextUpdate.INFINITY); // Past.
173
+ }).should.equal(_getTimeToNextUpdate.INFINITY);
174
+
175
+ // Past.
179
176
  // Is at zero point.
180
177
  // The next step is seconds.
181
178
  // Updates at the next step.
182
-
183
179
  (0, _getTimeToNextUpdate.getStepChangesAt)({
184
180
  unit: 'second',
185
181
  minTime: 1
@@ -187,32 +183,35 @@ describe('getStepChangesAt', function () {
187
183
  now: 0,
188
184
  future: false,
189
185
  prevStep: {}
190
- }).should.equal(1 * 1000); // Future.
186
+ }).should.equal(1 * 1000);
187
+
188
+ // Future.
191
189
  // Inside the first step.
192
190
  // Updates after zero point.
193
-
194
191
  (0, _getTimeToNextUpdate.getStepChangesAt)({
195
192
  unit: 'now'
196
193
  }, 0.9 * 1000, {
197
194
  now: 0,
198
195
  future: true,
199
196
  prevStep: undefined
200
- }).should.equal(0.9 * 1000 + 1); // Future.
197
+ }).should.equal(0.9 * 1000 + 1);
198
+
199
+ // Future.
201
200
  // The first step doesn't start at 0.
202
201
  // Outside of the first step.
203
202
  // Updates right after zero point.
204
-
205
203
  (0, _getTimeToNextUpdate.getTimeToStepChange)(undefined, 0.9 * 1000, {
206
204
  now: 0,
207
205
  future: true,
208
206
  prevStep: undefined
209
- }).should.equal(0.9 * 1000 + 1); // Past.
207
+ }).should.equal(0.9 * 1000 + 1);
208
+
209
+ // Past.
210
210
  // The current step is `undefined`.
211
211
  // The next step is the first step.
212
212
  // The first step doesn't start at 0.
213
213
  // Outside of the first step.
214
214
  // Updates at entering the first step.
215
-
216
215
  (0, _getTimeToNextUpdate.getStepChangesAt)({
217
216
  minTime: 1,
218
217
  unit: 'second'
@@ -220,10 +219,11 @@ describe('getStepChangesAt', function () {
220
219
  now: 0,
221
220
  future: false,
222
221
  prevStep: {}
223
- }).should.equal(0.1 * 1000); // Future.
222
+ }).should.equal(0.1 * 1000);
223
+
224
+ // Future.
224
225
  // The first step doesn't start at 0.
225
226
  // Will output empty string after it exits the current step.
226
-
227
227
  (0, _getTimeToNextUpdate.getStepChangesAt)({
228
228
  minTime: 1,
229
229
  unit: 'second'
@@ -231,39 +231,43 @@ describe('getStepChangesAt', function () {
231
231
  now: 0,
232
232
  future: true,
233
233
  prevStep: undefined
234
- }).should.equal(0.1 * 1000 + 1); // Past.
234
+ }).should.equal(0.1 * 1000 + 1);
235
+
236
+ // Past.
235
237
  // Next step is seconds.
236
238
  // The "next" step doesn't have `minTime`,
237
239
  // so "time to next update" couldn't be determined.
238
-
239
240
  expect((0, _getTimeToNextUpdate.getStepChangesAt)({
240
241
  unit: 'unknown-time-unit'
241
242
  }, 0, {
242
243
  now: 0,
243
244
  future: false,
244
245
  prevStep: {}
245
- })).to.be.undefined; // Past.
246
+ })).to.be.undefined;
247
+
248
+ // Past.
246
249
  // No next step.
247
250
  // The last step never changes.
248
-
249
251
  (0, _getTimeToNextUpdate.getTimeToStepChange)(undefined, 0, {
250
252
  now: 0,
251
253
  future: false,
252
254
  isFirstStep: undefined
253
- }).should.equal(_getTimeToNextUpdate.INFINITY); // Future.
255
+ }).should.equal(_getTimeToNextUpdate.INFINITY);
256
+
257
+ // Future.
254
258
  // Current step is seconds.
255
259
  // Updates after zero point.
256
-
257
260
  (0, _getTimeToNextUpdate.getStepChangesAt)({
258
261
  unit: 'second'
259
262
  }, 0, {
260
263
  now: 0,
261
264
  future: true,
262
265
  prevStep: undefined
263
- }).should.equal(1); // Past.
266
+ }).should.equal(1);
267
+
268
+ // Past.
264
269
  // Next step is minutes.
265
270
  // Already at zero point, so no need to update at zero point.
266
-
267
271
  (0, _getTimeToNextUpdate.getStepChangesAt)({
268
272
  minTime: 60,
269
273
  formatAs: 'minute'