javascript-time-ago 2.5.10 → 2.5.12

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 (439) hide show
  1. package/bundle/javascript-time-ago.js +1 -1
  2. package/bundle/javascript-time-ago.js.map +1 -1
  3. package/bundle/javascript-time-ago.min.js +1 -1
  4. package/bundle/javascript-time-ago.min.js.map +1 -1
  5. package/commonjs/LocaleDataStore.js +2 -5
  6. package/commonjs/LocaleDataStore.js.map +1 -1
  7. package/commonjs/PropTypes.js +12 -12
  8. package/commonjs/PropTypes.js.map +1 -1
  9. package/commonjs/TimeAgo.js +135 -190
  10. package/commonjs/TimeAgo.js.map +1 -1
  11. package/commonjs/TimeAgo.test.js +124 -130
  12. package/commonjs/TimeAgo.test.js.map +1 -1
  13. package/commonjs/cache.js +7 -25
  14. package/commonjs/cache.js.map +1 -1
  15. package/commonjs/cache.test.js +1 -3
  16. package/commonjs/cache.test.js.map +1 -1
  17. package/commonjs/isStyleObject.js +9 -9
  18. package/commonjs/isStyleObject.js.map +1 -1
  19. package/commonjs/isStyleObject.test.js +1 -3
  20. package/commonjs/isStyleObject.test.js.map +1 -1
  21. package/commonjs/locale.js +6 -19
  22. package/commonjs/locale.js.map +1 -1
  23. package/commonjs/locale.test.js +2 -11
  24. package/commonjs/locale.test.js.map +1 -1
  25. package/commonjs/round.js +2 -5
  26. package/commonjs/round.js.map +1 -1
  27. package/commonjs/steps/approximate.js +1 -4
  28. package/commonjs/steps/approximate.js.map +1 -1
  29. package/commonjs/steps/approximate.test.js +1 -6
  30. package/commonjs/steps/approximate.test.js.map +1 -1
  31. package/commonjs/steps/getStep.js +36 -53
  32. package/commonjs/steps/getStep.js.map +1 -1
  33. package/commonjs/steps/getStep.test.js +7 -7
  34. package/commonjs/steps/getStep.test.js.map +1 -1
  35. package/commonjs/steps/getStepDenominator.js +2 -5
  36. package/commonjs/steps/getStepDenominator.js.map +1 -1
  37. package/commonjs/steps/getStepDenominator.test.js +1 -3
  38. package/commonjs/steps/getStepDenominator.test.js.map +1 -1
  39. package/commonjs/steps/getStepMinTime.js +17 -32
  40. package/commonjs/steps/getStepMinTime.js.map +1 -1
  41. package/commonjs/steps/getStepMinTime.test.js +1 -3
  42. package/commonjs/steps/getStepMinTime.test.js.map +1 -1
  43. package/commonjs/steps/getTimeToNextUpdate.js +19 -41
  44. package/commonjs/steps/getTimeToNextUpdate.js.map +1 -1
  45. package/commonjs/steps/getTimeToNextUpdate.test.js +29 -25
  46. package/commonjs/steps/getTimeToNextUpdate.test.js.map +1 -1
  47. package/commonjs/steps/getTimeToNextUpdateForUnit.js +3 -12
  48. package/commonjs/steps/getTimeToNextUpdateForUnit.js.map +1 -1
  49. package/commonjs/steps/getTimeToNextUpdateForUnit.test.js +1 -7
  50. package/commonjs/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
  51. package/commonjs/steps/helpers.js +1 -2
  52. package/commonjs/steps/helpers.js.map +1 -1
  53. package/commonjs/steps/helpers.test.js +0 -1
  54. package/commonjs/steps/helpers.test.js.map +1 -1
  55. package/commonjs/steps/index.js +1 -6
  56. package/commonjs/steps/index.js.map +1 -1
  57. package/commonjs/steps/renameLegacyProperties.js +6 -14
  58. package/commonjs/steps/renameLegacyProperties.js.map +1 -1
  59. package/commonjs/steps/renameLegacyProperties.test.js +1 -3
  60. package/commonjs/steps/renameLegacyProperties.test.js.map +1 -1
  61. package/commonjs/steps/round.js +1 -2
  62. package/commonjs/steps/round.js.map +1 -1
  63. package/commonjs/steps/round.test.js +1 -7
  64. package/commonjs/steps/round.test.js.map +1 -1
  65. package/commonjs/steps/units.js +10 -21
  66. package/commonjs/steps/units.js.map +1 -1
  67. package/commonjs/style/approximate.js +2 -6
  68. package/commonjs/style/approximate.js.map +1 -1
  69. package/commonjs/style/approximateTime.js +2 -6
  70. package/commonjs/style/approximateTime.js.map +1 -1
  71. package/commonjs/style/approximateTime.test.js +116 -75
  72. package/commonjs/style/approximateTime.test.js.map +1 -1
  73. package/commonjs/style/getStyleByName.js +3 -29
  74. package/commonjs/style/getStyleByName.js.map +1 -1
  75. package/commonjs/style/mini.js +9 -6
  76. package/commonjs/style/mini.js.map +1 -1
  77. package/commonjs/style/mini.test.js +15 -25
  78. package/commonjs/style/mini.test.js.map +1 -1
  79. package/commonjs/style/miniMinute.js +8 -13
  80. package/commonjs/style/miniMinute.js.map +1 -1
  81. package/commonjs/style/miniMinute.test.js +11 -17
  82. package/commonjs/style/miniMinute.test.js.map +1 -1
  83. package/commonjs/style/miniMinuteNow.js +8 -13
  84. package/commonjs/style/miniMinuteNow.js.map +1 -1
  85. package/commonjs/style/miniMinuteNow.test.js +11 -17
  86. package/commonjs/style/miniMinuteNow.test.js.map +1 -1
  87. package/commonjs/style/miniNow.js +8 -13
  88. package/commonjs/style/miniNow.js.map +1 -1
  89. package/commonjs/style/miniNow.test.js +11 -17
  90. package/commonjs/style/miniNow.test.js.map +1 -1
  91. package/commonjs/style/renameLegacyProperties.js +7 -13
  92. package/commonjs/style/renameLegacyProperties.js.map +1 -1
  93. package/commonjs/style/renameLegacyProperties.test.js +1 -4
  94. package/commonjs/style/renameLegacyProperties.test.js.map +1 -1
  95. package/commonjs/style/round.js +2 -6
  96. package/commonjs/style/round.js.map +1 -1
  97. package/commonjs/style/round.test.js +51 -67
  98. package/commonjs/style/round.test.js.map +1 -1
  99. package/commonjs/style/roundMinute.js +8 -13
  100. package/commonjs/style/roundMinute.js.map +1 -1
  101. package/commonjs/style/roundMinute.test.js +20 -27
  102. package/commonjs/style/roundMinute.test.js.map +1 -1
  103. package/commonjs/style/twitter.js +34 -38
  104. package/commonjs/style/twitter.js.map +1 -1
  105. package/commonjs/style/twitter.test.js +49 -55
  106. package/commonjs/style/twitter.test.js.map +1 -1
  107. package/commonjs/style/twitterFirstMinute.js +10 -15
  108. package/commonjs/style/twitterFirstMinute.js.map +1 -1
  109. package/commonjs/style/twitterFirstMinute.test.js +16 -23
  110. package/commonjs/style/twitterFirstMinute.test.js.map +1 -1
  111. package/commonjs/style/twitterMinute.js +8 -13
  112. package/commonjs/style/twitterMinute.js.map +1 -1
  113. package/commonjs/style/twitterMinute.test.js +20 -25
  114. package/commonjs/style/twitterMinute.test.js.map +1 -1
  115. package/commonjs/style/twitterMinuteNow.js +8 -13
  116. package/commonjs/style/twitterMinuteNow.js.map +1 -1
  117. package/commonjs/style/twitterMinuteNow.test.js +20 -25
  118. package/commonjs/style/twitterMinuteNow.test.js.map +1 -1
  119. package/commonjs/style/twitterNow.js +8 -13
  120. package/commonjs/style/twitterNow.js.map +1 -1
  121. package/commonjs/style/twitterNow.test.js +18 -24
  122. package/commonjs/style/twitterNow.test.js.map +1 -1
  123. package/load-all-locales/index.cjs +32 -0
  124. package/load-all-locales/index.cjs.js +32 -0
  125. package/load-all-locales/index.js +64 -0
  126. package/locale/ak/package.json +16 -0
  127. package/locale/ak.json +267 -0
  128. package/locale/ak.json.d.ts +4 -0
  129. package/locale/ak.json.js +267 -0
  130. package/locale/bal-Latn/package.json +16 -0
  131. package/locale/bal-Latn.json +240 -0
  132. package/locale/bal-Latn.json.d.ts +4 -0
  133. package/locale/bal-Latn.json.js +240 -0
  134. package/locale/be-tarask/package.json +16 -0
  135. package/locale/be-tarask.json +259 -0
  136. package/locale/be-tarask.json.d.ts +4 -0
  137. package/locale/be-tarask.json.js +259 -0
  138. package/locale/blo/package.json +16 -0
  139. package/locale/blo.json +159 -0
  140. package/locale/blo.json.d.ts +4 -0
  141. package/locale/blo.json.js +159 -0
  142. package/locale/bn.json +5 -2
  143. package/locale/bn.json.js +5 -2
  144. package/locale/bs.json +8 -2
  145. package/locale/bs.json.js +8 -2
  146. package/locale/ccp.json +2 -8
  147. package/locale/ccp.json.js +2 -8
  148. package/locale/csw/package.json +16 -0
  149. package/locale/csw.json +180 -0
  150. package/locale/csw.json.d.ts +4 -0
  151. package/locale/csw.json.js +180 -0
  152. package/locale/cy.json +6 -12
  153. package/locale/cy.json.js +6 -12
  154. package/locale/doi/package.json +16 -0
  155. package/locale/doi.json +159 -0
  156. package/locale/doi.json.d.ts +4 -0
  157. package/locale/doi.json.js +159 -0
  158. package/locale/en-AU.json +12 -12
  159. package/locale/en-AU.json.js +12 -12
  160. package/locale/en-CZ/package.json +16 -0
  161. package/locale/en-CZ.json +219 -0
  162. package/locale/en-CZ.json.d.ts +4 -0
  163. package/locale/en-CZ.json.js +219 -0
  164. package/locale/en-ES/package.json +16 -0
  165. package/locale/en-ES.json +219 -0
  166. package/locale/en-ES.json.d.ts +4 -0
  167. package/locale/en-ES.json.js +219 -0
  168. package/locale/en-FR/package.json +16 -0
  169. package/locale/en-FR.json +219 -0
  170. package/locale/en-FR.json.d.ts +4 -0
  171. package/locale/en-FR.json.js +219 -0
  172. package/locale/en-GS/package.json +16 -0
  173. package/locale/en-GS.json +219 -0
  174. package/locale/en-GS.json.d.ts +4 -0
  175. package/locale/en-GS.json.js +219 -0
  176. package/locale/en-HU/package.json +16 -0
  177. package/locale/en-HU.json +219 -0
  178. package/locale/en-HU.json.d.ts +4 -0
  179. package/locale/en-HU.json.js +219 -0
  180. package/locale/en-ID/package.json +16 -0
  181. package/locale/en-ID.json +219 -0
  182. package/locale/en-ID.json.d.ts +4 -0
  183. package/locale/en-ID.json.js +219 -0
  184. package/locale/en-IT/package.json +16 -0
  185. package/locale/en-IT.json +219 -0
  186. package/locale/en-IT.json.d.ts +4 -0
  187. package/locale/en-IT.json.js +219 -0
  188. package/locale/en-NO/package.json +16 -0
  189. package/locale/en-NO.json +219 -0
  190. package/locale/en-NO.json.d.ts +4 -0
  191. package/locale/en-NO.json.js +219 -0
  192. package/locale/en-PL/package.json +16 -0
  193. package/locale/en-PL.json +219 -0
  194. package/locale/en-PL.json.d.ts +4 -0
  195. package/locale/en-PL.json.js +219 -0
  196. package/locale/en-PT/package.json +16 -0
  197. package/locale/en-PT.json +219 -0
  198. package/locale/en-PT.json.d.ts +4 -0
  199. package/locale/en-PT.json.js +219 -0
  200. package/locale/en-RO/package.json +16 -0
  201. package/locale/en-RO.json +219 -0
  202. package/locale/en-RO.json.d.ts +4 -0
  203. package/locale/en-RO.json.js +219 -0
  204. package/locale/en-SK/package.json +16 -0
  205. package/locale/en-SK.json +219 -0
  206. package/locale/en-SK.json.d.ts +4 -0
  207. package/locale/en-SK.json.js +219 -0
  208. package/locale/es-MX.json +12 -9
  209. package/locale/es-MX.json.js +12 -9
  210. package/locale/es-SV.json +2 -2
  211. package/locale/es-SV.json.js +2 -2
  212. package/locale/eu.json +24 -24
  213. package/locale/eu.json.js +24 -24
  214. package/locale/ha.json +119 -65
  215. package/locale/ha.json.js +119 -65
  216. package/locale/he.json +0 -6
  217. package/locale/he.json.js +0 -6
  218. package/locale/hi-Latn.json +2 -2
  219. package/locale/hi-Latn.json.js +2 -2
  220. package/locale/ht/package.json +16 -0
  221. package/locale/ht.json +207 -0
  222. package/locale/ht.json.d.ts +4 -0
  223. package/locale/ht.json.js +207 -0
  224. package/locale/id.json +1 -1
  225. package/locale/id.json.js +1 -1
  226. package/locale/ie/package.json +16 -0
  227. package/locale/ie.json +159 -0
  228. package/locale/ie.json.d.ts +4 -0
  229. package/locale/ie.json.js +159 -0
  230. package/locale/ig.json +17 -17
  231. package/locale/ig.json.js +17 -17
  232. package/locale/ii/package.json +16 -0
  233. package/locale/ii.json +165 -0
  234. package/locale/ii.json.d.ts +4 -0
  235. package/locale/ii.json.js +165 -0
  236. package/locale/is.json +4 -1
  237. package/locale/is.json.js +4 -1
  238. package/locale/kaa/package.json +16 -0
  239. package/locale/kaa.json +159 -0
  240. package/locale/kaa.json.d.ts +4 -0
  241. package/locale/kaa.json.js +159 -0
  242. package/locale/kok-Latn/package.json +16 -0
  243. package/locale/kok-Latn.json +159 -0
  244. package/locale/kok-Latn.json.d.ts +4 -0
  245. package/locale/kok-Latn.json.js +159 -0
  246. package/locale/kok.json +8 -8
  247. package/locale/kok.json.js +8 -8
  248. package/locale/ks.json +9 -9
  249. package/locale/ks.json.js +9 -9
  250. package/locale/ku.json +55 -46
  251. package/locale/ku.json.js +55 -46
  252. package/locale/lld/package.json +16 -0
  253. package/locale/lld.json +291 -0
  254. package/locale/lld.json.d.ts +4 -0
  255. package/locale/lld.json.js +291 -0
  256. package/locale/mi.json +22 -22
  257. package/locale/mi.json.js +22 -22
  258. package/locale/ms-Arab/package.json +16 -0
  259. package/locale/ms-Arab.json +159 -0
  260. package/locale/ms-Arab.json.d.ts +4 -0
  261. package/locale/ms-Arab.json.js +159 -0
  262. package/locale/nb.json +2 -2
  263. package/locale/nb.json.js +2 -2
  264. package/locale/ne.json +1 -1
  265. package/locale/ne.json.js +1 -1
  266. package/locale/nn.json +4 -4
  267. package/locale/nn.json.js +4 -4
  268. package/locale/no.json +2 -2
  269. package/locale/no.json.js +2 -2
  270. package/locale/nqo/package.json +16 -0
  271. package/locale/nqo.json +159 -0
  272. package/locale/nqo.json.d.ts +4 -0
  273. package/locale/nqo.json.js +159 -0
  274. package/locale/om/package.json +16 -0
  275. package/locale/om.json +213 -0
  276. package/locale/om.json.d.ts +4 -0
  277. package/locale/om.json.js +213 -0
  278. package/locale/or.json +1 -1
  279. package/locale/or.json.js +1 -1
  280. package/locale/pl.json +59 -0
  281. package/locale/pl.json.js +59 -0
  282. package/locale/qu.json +46 -46
  283. package/locale/qu.json.js +46 -46
  284. package/locale/rhg/package.json +16 -0
  285. package/locale/rhg.json +159 -0
  286. package/locale/rhg.json.d.ts +4 -0
  287. package/locale/rhg.json.js +159 -0
  288. package/locale/sl.json +12 -12
  289. package/locale/sl.json.js +12 -12
  290. package/locale/sr-Cyrl-BA.json +2 -2
  291. package/locale/sr-Cyrl-BA.json.js +2 -2
  292. package/locale/sr-Latn-BA.json +2 -2
  293. package/locale/sr-Latn-BA.json.js +2 -2
  294. package/locale/sv.json +1 -1
  295. package/locale/sv.json.js +1 -1
  296. package/locale/syr/package.json +16 -0
  297. package/locale/syr.json +303 -0
  298. package/locale/syr.json.d.ts +4 -0
  299. package/locale/syr.json.js +303 -0
  300. package/locale/ti.json +6 -6
  301. package/locale/ti.json.js +6 -6
  302. package/locale/tn/package.json +16 -0
  303. package/locale/tn.json +159 -0
  304. package/locale/tn.json.d.ts +4 -0
  305. package/locale/tn.json.js +159 -0
  306. package/locale/to.json +26 -26
  307. package/locale/to.json.js +26 -26
  308. package/locale/uk.json +1 -1
  309. package/locale/uk.json.js +1 -1
  310. package/locale/ur-IN.json +9 -6
  311. package/locale/ur-IN.json.js +9 -6
  312. package/locale/vec/package.json +16 -0
  313. package/locale/vec.json +267 -0
  314. package/locale/vec.json.d.ts +4 -0
  315. package/locale/vec.json.js +267 -0
  316. package/locale/xnr/package.json +16 -0
  317. package/locale/xnr.json +159 -0
  318. package/locale/xnr.json.d.ts +4 -0
  319. package/locale/xnr.json.js +159 -0
  320. package/locale/yo-BJ.json +17 -17
  321. package/locale/yo-BJ.json.js +17 -17
  322. package/locale/yo.json +17 -17
  323. package/locale/yo.json.js +17 -17
  324. package/locale-more-styles/pl/long-time.json +30 -0
  325. package/locale-more-styles/pl/mini.json +9 -0
  326. package/locale-more-styles/pl/now.json +7 -0
  327. package/locale-more-styles/pl/short-time.json +12 -0
  328. package/modules/LocaleDataStore.js +2 -3
  329. package/modules/LocaleDataStore.js.map +1 -1
  330. package/modules/PropTypes.js +11 -7
  331. package/modules/PropTypes.js.map +1 -1
  332. package/modules/TimeAgo.js +135 -174
  333. package/modules/TimeAgo.js.map +1 -1
  334. package/modules/TimeAgo.test.js +126 -115
  335. package/modules/TimeAgo.test.js.map +1 -1
  336. package/modules/cache.js +6 -22
  337. package/modules/cache.js.map +1 -1
  338. package/modules/cache.test.js.map +1 -1
  339. package/modules/isStyleObject.js +9 -7
  340. package/modules/isStyleObject.js.map +1 -1
  341. package/modules/isStyleObject.test.js.map +1 -1
  342. package/modules/locale.js +6 -16
  343. package/modules/locale.js.map +1 -1
  344. package/modules/locale.test.js +0 -4
  345. package/modules/locale.test.js.map +1 -1
  346. package/modules/round.js +2 -3
  347. package/modules/round.js.map +1 -1
  348. package/modules/steps/approximate.js +6 -2
  349. package/modules/steps/approximate.js.map +1 -1
  350. package/modules/steps/approximate.test.js +0 -2
  351. package/modules/steps/approximate.test.js.map +1 -1
  352. package/modules/steps/getStep.js +36 -48
  353. package/modules/steps/getStep.js.map +1 -1
  354. package/modules/steps/getStep.test.js +6 -2
  355. package/modules/steps/getStep.test.js.map +1 -1
  356. package/modules/steps/getStepDenominator.js +2 -3
  357. package/modules/steps/getStepDenominator.js.map +1 -1
  358. package/modules/steps/getStepDenominator.test.js.map +1 -1
  359. package/modules/steps/getStepMinTime.js +17 -29
  360. package/modules/steps/getStepMinTime.js.map +1 -1
  361. package/modules/steps/getStepMinTime.test.js.map +1 -1
  362. package/modules/steps/getTimeToNextUpdate.js +19 -31
  363. package/modules/steps/getTimeToNextUpdate.js.map +1 -1
  364. package/modules/steps/getTimeToNextUpdate.test.js +27 -18
  365. package/modules/steps/getTimeToNextUpdate.test.js.map +1 -1
  366. package/modules/steps/getTimeToNextUpdateForUnit.js +4 -10
  367. package/modules/steps/getTimeToNextUpdateForUnit.js.map +1 -1
  368. package/modules/steps/getTimeToNextUpdateForUnit.test.js +0 -4
  369. package/modules/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
  370. package/modules/steps/helpers.js +1 -1
  371. package/modules/steps/helpers.js.map +1 -1
  372. package/modules/steps/helpers.test.js.map +1 -1
  373. package/modules/steps/index.js +2 -1
  374. package/modules/steps/index.js.map +1 -1
  375. package/modules/steps/renameLegacyProperties.js +6 -13
  376. package/modules/steps/renameLegacyProperties.js.map +1 -1
  377. package/modules/steps/renameLegacyProperties.test.js.map +1 -1
  378. package/modules/steps/round.js.map +1 -1
  379. package/modules/steps/round.test.js +0 -3
  380. package/modules/steps/round.test.js.map +1 -1
  381. package/modules/steps/units.js +5 -9
  382. package/modules/steps/units.js.map +1 -1
  383. package/modules/style/approximate.js +5 -1
  384. package/modules/style/approximate.js.map +1 -1
  385. package/modules/style/approximateTime.js +6 -2
  386. package/modules/style/approximateTime.js.map +1 -1
  387. package/modules/style/approximateTime.test.js +115 -70
  388. package/modules/style/approximateTime.test.js.map +1 -1
  389. package/modules/style/getStyleByName.js +4 -17
  390. package/modules/style/getStyleByName.js.map +1 -1
  391. package/modules/style/mini.js +8 -4
  392. package/modules/style/mini.js.map +1 -1
  393. package/modules/style/mini.test.js +14 -20
  394. package/modules/style/mini.test.js.map +1 -1
  395. package/modules/style/miniMinute.js +6 -6
  396. package/modules/style/miniMinute.js.map +1 -1
  397. package/modules/style/miniMinute.test.js +10 -12
  398. package/modules/style/miniMinute.test.js.map +1 -1
  399. package/modules/style/miniMinuteNow.js +6 -6
  400. package/modules/style/miniMinuteNow.js.map +1 -1
  401. package/modules/style/miniMinuteNow.test.js +10 -12
  402. package/modules/style/miniMinuteNow.test.js.map +1 -1
  403. package/modules/style/miniNow.js +6 -6
  404. package/modules/style/miniNow.js.map +1 -1
  405. package/modules/style/miniNow.test.js +10 -12
  406. package/modules/style/miniNow.test.js.map +1 -1
  407. package/modules/style/renameLegacyProperties.js +8 -10
  408. package/modules/style/renameLegacyProperties.js.map +1 -1
  409. package/modules/style/renameLegacyProperties.test.js +0 -1
  410. package/modules/style/renameLegacyProperties.test.js.map +1 -1
  411. package/modules/style/round.js +3 -2
  412. package/modules/style/round.js.map +1 -1
  413. package/modules/style/round.test.js +50 -62
  414. package/modules/style/round.test.js.map +1 -1
  415. package/modules/style/roundMinute.js +8 -7
  416. package/modules/style/roundMinute.js.map +1 -1
  417. package/modules/style/roundMinute.test.js +19 -22
  418. package/modules/style/roundMinute.test.js.map +1 -1
  419. package/modules/style/twitter.js +35 -32
  420. package/modules/style/twitter.js.map +1 -1
  421. package/modules/style/twitter.test.js +48 -50
  422. package/modules/style/twitter.test.js.map +1 -1
  423. package/modules/style/twitterFirstMinute.js +8 -7
  424. package/modules/style/twitterFirstMinute.js.map +1 -1
  425. package/modules/style/twitterFirstMinute.test.js +15 -18
  426. package/modules/style/twitterFirstMinute.test.js.map +1 -1
  427. package/modules/style/twitterMinute.js +6 -6
  428. package/modules/style/twitterMinute.js.map +1 -1
  429. package/modules/style/twitterMinute.test.js +19 -20
  430. package/modules/style/twitterMinute.test.js.map +1 -1
  431. package/modules/style/twitterMinuteNow.js +6 -6
  432. package/modules/style/twitterMinuteNow.js.map +1 -1
  433. package/modules/style/twitterMinuteNow.test.js +19 -20
  434. package/modules/style/twitterMinuteNow.test.js.map +1 -1
  435. package/modules/style/twitterNow.js +6 -6
  436. package/modules/style/twitterNow.js.map +1 -1
  437. package/modules/style/twitterNow.test.js +17 -19
  438. package/modules/style/twitterNow.test.js.map +1 -1
  439. package/package.json +261 -4
@@ -1 +1 @@
1
- {"version":3,"file":"round.js","names":["getRoundFunction","round","Math","floor","getDiffRatioToNextRoundedNumber"],"sources":["../source/round.js"],"sourcesContent":["export function getRoundFunction(round) {\r\n\tswitch (round) {\r\n\t\tcase 'floor':\r\n\t\t\treturn Math.floor\r\n\t\tdefault:\r\n\t\t\treturn Math.round\r\n\t}\r\n}\r\n\r\n// For non-negative numbers.\r\nexport function getDiffRatioToNextRoundedNumber(round) {\r\n\tswitch (round) {\r\n\t\tcase 'floor':\r\n\t\t\t// Math.floor(x) = x\r\n\t\t\t// Math.floor(x + 1) = x + 1\r\n\t\t\treturn 1\r\n\t\tdefault:\r\n\t\t\t// Math.round(x) = x\r\n\t\t\t// Math.round(x + 0.5) = x + 1\r\n\t\t\treturn 0.5\r\n\t}\r\n}"],"mappings":"AAAA,OAAO,SAASA,gBAAT,CAA0BC,KAA1B,EAAiC;EACvC,QAAQA,KAAR;IACC,KAAK,OAAL;MACC,OAAOC,IAAI,CAACC,KAAZ;;IACD;MACC,OAAOD,IAAI,CAACD,KAAZ;EAJF;AAMA,C,CAED;;AACA,OAAO,SAASG,+BAAT,CAAyCH,KAAzC,EAAgD;EACtD,QAAQA,KAAR;IACC,KAAK,OAAL;MACC;MACA;MACA,OAAO,CAAP;;IACD;MACC;MACA;MACA,OAAO,GAAP;EARF;AAUA"}
1
+ {"version":3,"file":"round.js","names":["getRoundFunction","round","Math","floor","getDiffRatioToNextRoundedNumber"],"sources":["../source/round.js"],"sourcesContent":["export function getRoundFunction(round) {\r\n\tswitch (round) {\r\n\t\tcase 'floor':\r\n\t\t\treturn Math.floor\r\n\t\tdefault:\r\n\t\t\treturn Math.round\r\n\t}\r\n}\r\n\r\n// For non-negative numbers.\r\nexport function getDiffRatioToNextRoundedNumber(round) {\r\n\tswitch (round) {\r\n\t\tcase 'floor':\r\n\t\t\t// Math.floor(x) = x\r\n\t\t\t// Math.floor(x + 1) = x + 1\r\n\t\t\treturn 1\r\n\t\tdefault:\r\n\t\t\t// Math.round(x) = x\r\n\t\t\t// Math.round(x + 0.5) = x + 1\r\n\t\t\treturn 0.5\r\n\t}\r\n}"],"mappings":"AAAA,OAAO,SAASA,gBAAgBA,CAACC,KAAK,EAAE;EACvC,QAAQA,KAAK;IACZ,KAAK,OAAO;MACX,OAAOC,IAAI,CAACC,KAAK;IAClB;MACC,OAAOD,IAAI,CAACD,KAAK;EACnB;AACD;;AAEA;AACA,OAAO,SAASG,+BAA+BA,CAACH,KAAK,EAAE;EACtD,QAAQA,KAAK;IACZ,KAAK,OAAO;MACX;MACA;MACA,OAAO,CAAC;IACT;MACC;MACA;MACA,OAAO,GAAG;EACZ;AACD","ignoreList":[]}
@@ -1,9 +1,14 @@
1
- import { minute, hour, day, week, month, year } from './units.js'; // "factor" is a legacy property.
1
+ import { minute, hour, day, week, month, year } from './units.js';
2
+
3
+ // "factor" is a legacy property.
2
4
  // Developers shouldn't need to use it in their custom steps.
5
+
3
6
  // "threshold" is a legacy name of "min".
4
7
  // Developers should use "min" property name instead of "threshold".
8
+
5
9
  // "threshold_for_idOrUnit: value" is a legacy way of specifying "min: { id: value }".
6
10
  // Developers should use "min" property instead of "threshold".
11
+
7
12
  // just now
8
13
  // 1 minute ago
9
14
  // 2 minutes ago
@@ -29,7 +34,6 @@ import { minute, hour, day, week, month, year } from './units.js'; // "factor" i
29
34
  // a year ago
30
35
  // 2 years ago
31
36
  // …
32
-
33
37
  export default [{
34
38
  // This step returns the amount of seconds
35
39
  // by dividing the amount of seconds by `1`.
@@ -1 +1 @@
1
- {"version":3,"file":"approximate.js","names":["minute","hour","day","week","month","year","factor","unit","threshold","threshold_for_now","granularity","threshold_for_minute"],"sources":["../../source/steps/approximate.js"],"sourcesContent":["import { minute, hour, day, week, month, year } from './units.js'\r\n\r\n// \"factor\" is a legacy property.\r\n// Developers shouldn't need to use it in their custom steps.\r\n\r\n// \"threshold\" is a legacy name of \"min\".\r\n// Developers should use \"min\" property name instead of \"threshold\".\r\n\r\n// \"threshold_for_idOrUnit: value\" is a legacy way of specifying \"min: { id: value }\".\r\n// Developers should use \"min\" property instead of \"threshold\".\r\n\r\n// just now\r\n// 1 minute ago\r\n// 2 minutes ago\r\n// 5 minutes ago\r\n// 10 minutes ago\r\n// 15 minutes ago\r\n// 20 minutes ago\r\n// …\r\n// 50 minutes ago\r\n// an hour ago\r\n// 2 hours ago\r\n// …\r\n// 20 hours ago\r\n// a day ago\r\n// 2 days ago\r\n// 5 days ago\r\n// a week ago\r\n// 2 weeks ago\r\n// 3 weeks ago\r\n// a month ago\r\n// 2 months ago\r\n// 4 months ago\r\n// a year ago\r\n// 2 years ago\r\n// …\r\nexport default [\r\n\t{\r\n\t\t// This step returns the amount of seconds\r\n\t\t// by dividing the amount of seconds by `1`.\r\n\t\tfactor: 1,\r\n \t// \"now\" labels are used for formatting the output.\r\n\t\tunit: 'now'\r\n\t},\r\n\t{\r\n\t\t// When the language doesn't support `now` unit,\r\n\t\t// the first step is ignored, and it uses this `second` unit.\r\n\t\tthreshold: 1,\r\n\t\t// `threshold_for_now` should be the same as `threshold` on minutes.\r\n\t\tthreshold_for_now: 45.5,\r\n\t\t// This step returns the amount of seconds\r\n\t\t// by dividing the amount of seconds by `1`.\r\n\t\tfactor: 1,\r\n \t// \"second\" labels are used for formatting the output.\r\n\t\tunit: 'second'\r\n\t},\r\n\t{\r\n\t\t// `threshold` should be the same as `threshold_for_now` on seconds.\r\n\t\tthreshold: 45.5,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in a minute.\r\n\t\tfactor: minute,\r\n \t// \"minute\" labels are used for formatting the output.\r\n\t\tunit: 'minute'\r\n\t},\r\n\t{\r\n\t\t// This step is effective starting from 2.5 minutes.\r\n\t\tthreshold: 2.5 * minute,\r\n\t\t// Allow only 5-minute increments of minutes starting from 2.5 minutes.\r\n\t\t// `granularity` — (advanced) Time interval value \"granularity\".\r\n\t\t// For example, it could be set to `5` for minutes to allow only 5-minute increments\r\n\t\t// when formatting time intervals: `0 minutes`, `5 minutes`, `10 minutes`, etc.\r\n\t\t// Perhaps this feature will be removed because there seem to be no use cases\r\n\t\t// of it in the real world.\r\n\t\tgranularity: 5,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in a minute.\r\n\t\tfactor: minute,\r\n\t\t// \"minute\" labels are used for formatting the output.\r\n\t\tunit: 'minute'\r\n\t},\r\n\t{\r\n\t\t// This step is effective starting from 22.5 minutes.\r\n\t\tthreshold: 22.5 * minute,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in half-an-hour.\r\n\t\tfactor: 0.5 * hour,\r\n\t\t// \"half-hour\" labels are used for formatting the output.\r\n\t\t// (if available, which is no longer the case)\r\n\t\tunit: 'half-hour'\r\n\t},\r\n\t{\r\n\t\t// This step is effective starting from 42.5 minutes.\r\n\t\tthreshold: 42.5 * minute,\r\n\t\tthreshold_for_minute: 52.5 * minute,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in an hour.\r\n\t\tfactor: hour,\r\n\t\t// \"hour\" labels are used for formatting the output.\r\n\t\tunit: 'hour'\r\n\t},\r\n\t{\r\n\t\t// This step is effective starting from 20.5 hours.\r\n\t\tthreshold: (20.5 / 24) * day,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in a day.\r\n\t\tfactor: day,\r\n\t\t// \"day\" labels are used for formatting the output.\r\n\t\tunit: 'day'\r\n\t},\r\n\t{\r\n\t\t// This step is effective starting from 5.5 days.\r\n\t\tthreshold: 5.5 * day,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in a week.\r\n\t\tfactor: week,\r\n\t\t// \"week\" labels are used for formatting the output.\r\n\t\tunit: 'week'\r\n\t},\r\n\t{\r\n\t\t// This step is effective starting from 3.5 weeks.\r\n\t\tthreshold: 3.5 * week,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in a month.\r\n\t\tfactor: month,\r\n\t\t// \"month\" labels are used for formatting the output.\r\n\t\tunit: 'month'\r\n\t},\r\n\t{\r\n\t\t// This step is effective starting from 10.5 months.\r\n\t\tthreshold: 10.5 * month,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in a year.\r\n\t\tfactor: year,\r\n\t\t// \"year\" labels are used for formatting the output.\r\n\t\tunit: 'year'\r\n\t}\r\n]"],"mappings":"AAAA,SAASA,MAAT,EAAiBC,IAAjB,EAAuBC,GAAvB,EAA4BC,IAA5B,EAAkCC,KAAlC,EAAyCC,IAAzC,QAAqD,YAArD,C,CAEA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,CACd;EACC;EACA;EACAC,MAAM,EAAE,CAHT;EAII;EACHC,IAAI,EAAE;AALP,CADc,EAQd;EACC;EACA;EACAC,SAAS,EAAE,CAHZ;EAIC;EACAC,iBAAiB,EAAE,IALpB;EAMC;EACA;EACAH,MAAM,EAAE,CART;EASI;EACHC,IAAI,EAAE;AAVP,CARc,EAoBd;EACC;EACAC,SAAS,EAAE,IAFZ;EAGC;EACA;EACAF,MAAM,EAAEN,MALT;EAMI;EACHO,IAAI,EAAE;AAPP,CApBc,EA6Bd;EACC;EACAC,SAAS,EAAE,MAAMR,MAFlB;EAGC;EACA;EACA;EACA;EACA;EACA;EACAU,WAAW,EAAE,CATd;EAUC;EACA;EACAJ,MAAM,EAAEN,MAZT;EAaC;EACAO,IAAI,EAAE;AAdP,CA7Bc,EA6Cd;EACC;EACAC,SAAS,EAAE,OAAOR,MAFnB;EAGC;EACA;EACAM,MAAM,EAAE,MAAML,IALf;EAMC;EACA;EACAM,IAAI,EAAE;AARP,CA7Cc,EAuDd;EACC;EACAC,SAAS,EAAE,OAAOR,MAFnB;EAGCW,oBAAoB,EAAE,OAAOX,MAH9B;EAIC;EACA;EACAM,MAAM,EAAEL,IANT;EAOC;EACAM,IAAI,EAAE;AARP,CAvDc,EAiEd;EACC;EACAC,SAAS,EAAG,OAAO,EAAR,GAAcN,GAF1B;EAGC;EACA;EACAI,MAAM,EAAEJ,GALT;EAMC;EACAK,IAAI,EAAE;AAPP,CAjEc,EA0Ed;EACC;EACAC,SAAS,EAAE,MAAMN,GAFlB;EAGC;EACA;EACAI,MAAM,EAAEH,IALT;EAMC;EACAI,IAAI,EAAE;AAPP,CA1Ec,EAmFd;EACC;EACAC,SAAS,EAAE,MAAML,IAFlB;EAGC;EACA;EACAG,MAAM,EAAEF,KALT;EAMC;EACAG,IAAI,EAAE;AAPP,CAnFc,EA4Fd;EACC;EACAC,SAAS,EAAE,OAAOJ,KAFnB;EAGC;EACA;EACAE,MAAM,EAAED,IALT;EAMC;EACAE,IAAI,EAAE;AAPP,CA5Fc,CAAf"}
1
+ {"version":3,"file":"approximate.js","names":["minute","hour","day","week","month","year","factor","unit","threshold","threshold_for_now","granularity","threshold_for_minute"],"sources":["../../source/steps/approximate.js"],"sourcesContent":["import { minute, hour, day, week, month, year } from './units.js'\r\n\r\n// \"factor\" is a legacy property.\r\n// Developers shouldn't need to use it in their custom steps.\r\n\r\n// \"threshold\" is a legacy name of \"min\".\r\n// Developers should use \"min\" property name instead of \"threshold\".\r\n\r\n// \"threshold_for_idOrUnit: value\" is a legacy way of specifying \"min: { id: value }\".\r\n// Developers should use \"min\" property instead of \"threshold\".\r\n\r\n// just now\r\n// 1 minute ago\r\n// 2 minutes ago\r\n// 5 minutes ago\r\n// 10 minutes ago\r\n// 15 minutes ago\r\n// 20 minutes ago\r\n// …\r\n// 50 minutes ago\r\n// an hour ago\r\n// 2 hours ago\r\n// …\r\n// 20 hours ago\r\n// a day ago\r\n// 2 days ago\r\n// 5 days ago\r\n// a week ago\r\n// 2 weeks ago\r\n// 3 weeks ago\r\n// a month ago\r\n// 2 months ago\r\n// 4 months ago\r\n// a year ago\r\n// 2 years ago\r\n// …\r\nexport default [\r\n\t{\r\n\t\t// This step returns the amount of seconds\r\n\t\t// by dividing the amount of seconds by `1`.\r\n\t\tfactor: 1,\r\n \t// \"now\" labels are used for formatting the output.\r\n\t\tunit: 'now'\r\n\t},\r\n\t{\r\n\t\t// When the language doesn't support `now` unit,\r\n\t\t// the first step is ignored, and it uses this `second` unit.\r\n\t\tthreshold: 1,\r\n\t\t// `threshold_for_now` should be the same as `threshold` on minutes.\r\n\t\tthreshold_for_now: 45.5,\r\n\t\t// This step returns the amount of seconds\r\n\t\t// by dividing the amount of seconds by `1`.\r\n\t\tfactor: 1,\r\n \t// \"second\" labels are used for formatting the output.\r\n\t\tunit: 'second'\r\n\t},\r\n\t{\r\n\t\t// `threshold` should be the same as `threshold_for_now` on seconds.\r\n\t\tthreshold: 45.5,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in a minute.\r\n\t\tfactor: minute,\r\n \t// \"minute\" labels are used for formatting the output.\r\n\t\tunit: 'minute'\r\n\t},\r\n\t{\r\n\t\t// This step is effective starting from 2.5 minutes.\r\n\t\tthreshold: 2.5 * minute,\r\n\t\t// Allow only 5-minute increments of minutes starting from 2.5 minutes.\r\n\t\t// `granularity` — (advanced) Time interval value \"granularity\".\r\n\t\t// For example, it could be set to `5` for minutes to allow only 5-minute increments\r\n\t\t// when formatting time intervals: `0 minutes`, `5 minutes`, `10 minutes`, etc.\r\n\t\t// Perhaps this feature will be removed because there seem to be no use cases\r\n\t\t// of it in the real world.\r\n\t\tgranularity: 5,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in a minute.\r\n\t\tfactor: minute,\r\n\t\t// \"minute\" labels are used for formatting the output.\r\n\t\tunit: 'minute'\r\n\t},\r\n\t{\r\n\t\t// This step is effective starting from 22.5 minutes.\r\n\t\tthreshold: 22.5 * minute,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in half-an-hour.\r\n\t\tfactor: 0.5 * hour,\r\n\t\t// \"half-hour\" labels are used for formatting the output.\r\n\t\t// (if available, which is no longer the case)\r\n\t\tunit: 'half-hour'\r\n\t},\r\n\t{\r\n\t\t// This step is effective starting from 42.5 minutes.\r\n\t\tthreshold: 42.5 * minute,\r\n\t\tthreshold_for_minute: 52.5 * minute,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in an hour.\r\n\t\tfactor: hour,\r\n\t\t// \"hour\" labels are used for formatting the output.\r\n\t\tunit: 'hour'\r\n\t},\r\n\t{\r\n\t\t// This step is effective starting from 20.5 hours.\r\n\t\tthreshold: (20.5 / 24) * day,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in a day.\r\n\t\tfactor: day,\r\n\t\t// \"day\" labels are used for formatting the output.\r\n\t\tunit: 'day'\r\n\t},\r\n\t{\r\n\t\t// This step is effective starting from 5.5 days.\r\n\t\tthreshold: 5.5 * day,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in a week.\r\n\t\tfactor: week,\r\n\t\t// \"week\" labels are used for formatting the output.\r\n\t\tunit: 'week'\r\n\t},\r\n\t{\r\n\t\t// This step is effective starting from 3.5 weeks.\r\n\t\tthreshold: 3.5 * week,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in a month.\r\n\t\tfactor: month,\r\n\t\t// \"month\" labels are used for formatting the output.\r\n\t\tunit: 'month'\r\n\t},\r\n\t{\r\n\t\t// This step is effective starting from 10.5 months.\r\n\t\tthreshold: 10.5 * month,\r\n\t\t// Return the amount of minutes by dividing the amount\r\n\t\t// of seconds by the amount of seconds in a year.\r\n\t\tfactor: year,\r\n\t\t// \"year\" labels are used for formatting the output.\r\n\t\tunit: 'year'\r\n\t}\r\n]"],"mappings":"AAAA,SAASA,MAAM,EAAEC,IAAI,EAAEC,GAAG,EAAEC,IAAI,EAAEC,KAAK,EAAEC,IAAI,QAAQ,YAAY;;AAEjE;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,CACd;EACC;EACA;EACAC,MAAM,EAAE,CAAC;EACN;EACHC,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACA;EACAC,SAAS,EAAE,CAAC;EACZ;EACAC,iBAAiB,EAAE,IAAI;EACvB;EACA;EACAH,MAAM,EAAE,CAAC;EACN;EACHC,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAE,IAAI;EACf;EACA;EACAF,MAAM,EAAEN,MAAM;EACX;EACHO,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAE,GAAG,GAAGR,MAAM;EACvB;EACA;EACA;EACA;EACA;EACA;EACAU,WAAW,EAAE,CAAC;EACd;EACA;EACAJ,MAAM,EAAEN,MAAM;EACd;EACAO,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAE,IAAI,GAAGR,MAAM;EACxB;EACA;EACAM,MAAM,EAAE,GAAG,GAAGL,IAAI;EAClB;EACA;EACAM,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAE,IAAI,GAAGR,MAAM;EACxBW,oBAAoB,EAAE,IAAI,GAAGX,MAAM;EACnC;EACA;EACAM,MAAM,EAAEL,IAAI;EACZ;EACAM,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAG,IAAI,GAAG,EAAE,GAAIN,GAAG;EAC5B;EACA;EACAI,MAAM,EAAEJ,GAAG;EACX;EACAK,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAE,GAAG,GAAGN,GAAG;EACpB;EACA;EACAI,MAAM,EAAEH,IAAI;EACZ;EACAI,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAE,GAAG,GAAGL,IAAI;EACrB;EACA;EACAG,MAAM,EAAEF,KAAK;EACb;EACAG,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAE,IAAI,GAAGJ,KAAK;EACvB;EACA;EACAE,MAAM,EAAED,IAAI;EACZ;EACAE,IAAI,EAAE;AACP,CAAC,CACD","ignoreList":[]}
@@ -8,7 +8,6 @@ describe('steps/approximate', function () {
8
8
  units: ['now', 'second', 'minute', 'hour', 'day', 'week', 'month', 'year']
9
9
  });
10
10
  };
11
-
12
11
  expect(getStepFor(0).unit).to.equal('now');
13
12
  expect(getStepFor(1).unit).to.equal('now');
14
13
  expect(getStepFor(45).unit).to.equal('now');
@@ -34,7 +33,6 @@ describe('steps/approximate', function () {
34
33
  units: ['second', 'minute', 'hour', 'day', 'week', 'month', 'year']
35
34
  });
36
35
  };
37
-
38
36
  expect(getStepFor(0)).to.be.undefined;
39
37
  expect(getStepFor(1).unit).to.equal('second');
40
38
  expect(getStepFor(45).unit).to.equal('second');
@@ -1 +1 @@
1
- {"version":3,"file":"approximate.test.js","names":["getStep","steps","describe","it","getStepFor","secondsPassed","now","units","expect","unit","to","equal","factor","granularity","be","undefined"],"sources":["../../source/steps/approximate.test.js"],"sourcesContent":["import getStep from './getStep.js'\r\nimport steps from './approximate.js'\r\n\r\ndescribe('steps/approximate', () => {\r\n\tit('should get step correctly', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tnow: 0,\r\n\t\t\tunits: [\r\n\t\t\t\t'now',\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'week',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(0).unit).to.equal('now')\r\n\t\texpect(getStepFor(1).unit).to.equal('now')\r\n\t\texpect(getStepFor(45).unit).to.equal('now')\r\n\r\n\t\texpect(getStepFor(46).unit).to.equal('minute')\r\n\t\texpect(getStepFor(46).factor).to.equal(60)\r\n\t\texpect(getStepFor(46).granularity).to.be.undefined\r\n\r\n\t\texpect(getStepFor(2.5 * 60 - 1).unit).to.equal('minute')\r\n\t\texpect(getStepFor(2.5 * 60 - 1).factor).to.equal(60)\r\n\t\texpect(getStepFor(2.5 * 60 - 1).granularity).to.be.undefined\r\n\r\n\t\texpect(getStepFor(2.5 * 60).unit).to.equal('minute')\r\n\t\texpect(getStepFor(2.5 * 60).factor).to.equal(60)\r\n\t\texpect(getStepFor(2.5 * 60).granularity).to.equal(5)\r\n\r\n\t\texpect(getStepFor(52.5 * 60 - 1).unit).to.equal('minute')\r\n\t\texpect(getStepFor(52.5 * 60 - 1).factor).to.equal(60)\r\n\t\texpect(getStepFor(52.5 * 60 - 1).granularity).to.equal(5)\r\n\r\n\t\texpect(getStepFor(52.5 * 60).unit).to.equal('hour')\r\n\t\texpect(getStepFor(52.5 * 60).factor).to.equal(60 * 60)\r\n\t})\r\n\r\n\tit('should get step correctly (\"now\" unit not allowed)', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tnow: 0,\r\n\t\t\tunits: [\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'week',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(0)).to.be.undefined\r\n\t\texpect(getStepFor(1).unit).to.equal('second')\r\n\t\texpect(getStepFor(45).unit).to.equal('second')\r\n\t\texpect(getStepFor(46).unit).to.equal('minute')\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,cAApB;AACA,OAAOC,KAAP,MAAkB,kBAAlB;AAEAC,QAAQ,CAAC,mBAAD,EAAsB,YAAM;EACnCC,EAAE,CAAC,2BAAD,EAA8B,YAAM;IACrC,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,aAAD;MAAA,OAAmBL,OAAO,CAACC,KAAD,EAAQI,aAAR,EAAuB;QACnEC,GAAG,EAAE,CAD8D;QAEnEC,KAAK,EAAE,CACN,KADM,EAEN,QAFM,EAGN,QAHM,EAIN,MAJM,EAKN,KALM,EAMN,MANM,EAON,OAPM,EAQN,MARM;MAF4D,CAAvB,CAA1B;IAAA,CAAnB;;IAcAC,MAAM,CAACJ,UAAU,CAAC,CAAD,CAAV,CAAcK,IAAf,CAAN,CAA2BC,EAA3B,CAA8BC,KAA9B,CAAoC,KAApC;IACAH,MAAM,CAACJ,UAAU,CAAC,CAAD,CAAV,CAAcK,IAAf,CAAN,CAA2BC,EAA3B,CAA8BC,KAA9B,CAAoC,KAApC;IACAH,MAAM,CAACJ,UAAU,CAAC,EAAD,CAAV,CAAeK,IAAhB,CAAN,CAA4BC,EAA5B,CAA+BC,KAA/B,CAAqC,KAArC;IAEAH,MAAM,CAACJ,UAAU,CAAC,EAAD,CAAV,CAAeK,IAAhB,CAAN,CAA4BC,EAA5B,CAA+BC,KAA/B,CAAqC,QAArC;IACAH,MAAM,CAACJ,UAAU,CAAC,EAAD,CAAV,CAAeQ,MAAhB,CAAN,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A3B,CAAN,CAA8CH,EAA9C,CAAiDC,KAAjD,CAAuD,CAAvD;IAEAH,MAAM,CAACJ,UAAU,CAAC,OAAO,EAAR,CAAV,CAAsBK,IAAvB,CAAN,CAAmCC,EAAnC,CAAsCC,KAAtC,CAA4C,MAA5C;IACAH,MAAM,CAACJ,UAAU,CAAC,OAAO,EAAR,CAAV,CAAsBQ,MAAvB,CAAN,CAAqCF,EAArC,CAAwCC,KAAxC,CAA8C,KAAK,EAAnD;EACA,CArCC,CAAF;EAuCAR,EAAE,CAAC,oDAAD,EAAuD,YAAM;IAC9D,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,aAAD;MAAA,OAAmBL,OAAO,CAACC,KAAD,EAAQI,aAAR,EAAuB;QACnEC,GAAG,EAAE,CAD8D;QAEnEC,KAAK,EAAE,CACN,QADM,EAEN,QAFM,EAGN,MAHM,EAIN,KAJM,EAKN,MALM,EAMN,OANM,EAON,MAPM;MAF4D,CAAvB,CAA1B;IAAA,CAAnB;;IAaAC,MAAM,CAACJ,UAAU,CAAC,CAAD,CAAX,CAAN,CAAsBM,EAAtB,CAAyBI,EAAzB,CAA4BC,SAA5B;IACAP,MAAM,CAACJ,UAAU,CAAC,CAAD,CAAV,CAAcK,IAAf,CAAN,CAA2BC,EAA3B,CAA8BC,KAA9B,CAAoC,QAApC;IACAH,MAAM,CAACJ,UAAU,CAAC,EAAD,CAAV,CAAeK,IAAhB,CAAN,CAA4BC,EAA5B,CAA+BC,KAA/B,CAAqC,QAArC;IACAH,MAAM,CAACJ,UAAU,CAAC,EAAD,CAAV,CAAeK,IAAhB,CAAN,CAA4BC,EAA5B,CAA+BC,KAA/B,CAAqC,QAArC;EACA,CAlBC,CAAF;AAmBA,CA3DO,CAAR"}
1
+ {"version":3,"file":"approximate.test.js","names":["getStep","steps","describe","it","getStepFor","secondsPassed","now","units","expect","unit","to","equal","factor","granularity","be","undefined"],"sources":["../../source/steps/approximate.test.js"],"sourcesContent":["import getStep from './getStep.js'\r\nimport steps from './approximate.js'\r\n\r\ndescribe('steps/approximate', () => {\r\n\tit('should get step correctly', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tnow: 0,\r\n\t\t\tunits: [\r\n\t\t\t\t'now',\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'week',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(0).unit).to.equal('now')\r\n\t\texpect(getStepFor(1).unit).to.equal('now')\r\n\t\texpect(getStepFor(45).unit).to.equal('now')\r\n\r\n\t\texpect(getStepFor(46).unit).to.equal('minute')\r\n\t\texpect(getStepFor(46).factor).to.equal(60)\r\n\t\texpect(getStepFor(46).granularity).to.be.undefined\r\n\r\n\t\texpect(getStepFor(2.5 * 60 - 1).unit).to.equal('minute')\r\n\t\texpect(getStepFor(2.5 * 60 - 1).factor).to.equal(60)\r\n\t\texpect(getStepFor(2.5 * 60 - 1).granularity).to.be.undefined\r\n\r\n\t\texpect(getStepFor(2.5 * 60).unit).to.equal('minute')\r\n\t\texpect(getStepFor(2.5 * 60).factor).to.equal(60)\r\n\t\texpect(getStepFor(2.5 * 60).granularity).to.equal(5)\r\n\r\n\t\texpect(getStepFor(52.5 * 60 - 1).unit).to.equal('minute')\r\n\t\texpect(getStepFor(52.5 * 60 - 1).factor).to.equal(60)\r\n\t\texpect(getStepFor(52.5 * 60 - 1).granularity).to.equal(5)\r\n\r\n\t\texpect(getStepFor(52.5 * 60).unit).to.equal('hour')\r\n\t\texpect(getStepFor(52.5 * 60).factor).to.equal(60 * 60)\r\n\t})\r\n\r\n\tit('should get step correctly (\"now\" unit not allowed)', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tnow: 0,\r\n\t\t\tunits: [\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'week',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(0)).to.be.undefined\r\n\t\texpect(getStepFor(1).unit).to.equal('second')\r\n\t\texpect(getStepFor(45).unit).to.equal('second')\r\n\t\texpect(getStepFor(46).unit).to.equal('minute')\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,OAAO,MAAM,cAAc;AAClC,OAAOC,KAAK,MAAM,kBAAkB;AAEpCC,QAAQ,CAAC,mBAAmB,EAAE,YAAM;EACnCC,EAAE,CAAC,2BAA2B,EAAE,YAAM;IACrC,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAIC,aAAa;MAAA,OAAKL,OAAO,CAACC,KAAK,EAAEI,aAAa,EAAE;QACnEC,GAAG,EAAE,CAAC;QACNC,KAAK,EAAE,CACN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM;MAER,CAAC,CAAC;IAAA;IAEFC,MAAM,CAACJ,UAAU,CAAC,CAAC,CAAC,CAACK,IAAI,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,KAAK,CAAC;IAC1CH,MAAM,CAACJ,UAAU,CAAC,CAAC,CAAC,CAACK,IAAI,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,KAAK,CAAC;IAC1CH,MAAM,CAACJ,UAAU,CAAC,EAAE,CAAC,CAACK,IAAI,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,KAAK,CAAC;IAE3CH,MAAM,CAACJ,UAAU,CAAC,EAAE,CAAC,CAACK,IAAI,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,QAAQ,CAAC;IAC9CH,MAAM,CAACJ,UAAU,CAAC,EAAE,CAAC,CAACQ,MAAM,CAAC,CAACF,EAAE,CAACC,KAAK,CAAC,EAAE,CAAC;IAC1CH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,CAACJ,UAAU,CAAC,IAAI,GAAG,EAAE,CAAC,CAACK,IAAI,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,MAAM,CAAC;IACnDH,MAAM,CAACJ,UAAU,CAAC,IAAI,GAAG,EAAE,CAAC,CAACQ,MAAM,CAAC,CAACF,EAAE,CAACC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;EACvD,CAAC,CAAC;EAEFR,EAAE,CAAC,oDAAoD,EAAE,YAAM;IAC9D,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAIC,aAAa;MAAA,OAAKL,OAAO,CAACC,KAAK,EAAEI,aAAa,EAAE;QACnEC,GAAG,EAAE,CAAC;QACNC,KAAK,EAAE,CACN,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM;MAER,CAAC,CAAC;IAAA;IAEFC,MAAM,CAACJ,UAAU,CAAC,CAAC,CAAC,CAAC,CAACM,EAAE,CAACI,EAAE,CAACC,SAAS;IACrCP,MAAM,CAACJ,UAAU,CAAC,CAAC,CAAC,CAACK,IAAI,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,QAAQ,CAAC;IAC7CH,MAAM,CAACJ,UAAU,CAAC,EAAE,CAAC,CAACK,IAAI,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,QAAQ,CAAC;IAC9CH,MAAM,CAACJ,UAAU,CAAC,EAAE,CAAC,CAACK,IAAI,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,QAAQ,CAAC;EAC/C,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
@@ -1,12 +1,13 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
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); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import getStepDenominator from './getStepDenominator.js';
8
8
  import getStepMinTime from './getStepMinTime.js';
9
9
  import { getRoundFunction } from '../round.js';
10
+
10
11
  /**
11
12
  * Finds an appropriate `step` of `steps` for the time interval (in seconds).
12
13
  *
@@ -29,74 +30,68 @@ import { getRoundFunction } from '../round.js';
29
30
  *
30
31
  * @return {Object|Object[]} [step] — Either a `step` or `[prevStep, step, nextStep]`.
31
32
  */
32
-
33
33
  export default function getStep(steps, secondsPassed, _ref) {
34
34
  var now = _ref.now,
35
- future = _ref.future,
36
- round = _ref.round,
37
- units = _ref.units,
38
- getNextStep = _ref.getNextStep;
35
+ future = _ref.future,
36
+ round = _ref.round,
37
+ units = _ref.units,
38
+ getNextStep = _ref.getNextStep;
39
39
  // Ignore steps having not-supported time units in `formatAs`.
40
40
  steps = filterStepsByUnits(steps, units);
41
-
42
41
  var step = _getStep(steps, secondsPassed, {
43
42
  now: now,
44
43
  future: future,
45
44
  round: round
46
45
  });
47
-
48
46
  if (getNextStep) {
49
47
  if (step) {
50
48
  var prevStep = steps[steps.indexOf(step) - 1];
51
49
  var nextStep = steps[steps.indexOf(step) + 1];
52
50
  return [prevStep, step, nextStep];
53
51
  }
54
-
55
52
  return [undefined, undefined, steps[0]];
56
53
  }
57
-
58
54
  return step;
59
55
  }
60
-
61
56
  function _getStep(steps, secondsPassed, _ref2) {
62
57
  var now = _ref2.now,
63
- future = _ref2.future,
64
- round = _ref2.round;
65
-
58
+ future = _ref2.future,
59
+ round = _ref2.round;
66
60
  // If no steps fit the conditions then return nothing.
67
61
  if (steps.length === 0) {
68
62
  return;
69
- } // Find the most appropriate step.
70
-
63
+ }
71
64
 
65
+ // Find the most appropriate step.
72
66
  var i = getStepIndex(steps, secondsPassed, {
73
67
  now: now,
74
68
  future: future || secondsPassed < 0,
75
69
  round: round
76
- }); // If no step is applicable the return nothing.
70
+ });
77
71
 
72
+ // If no step is applicable the return nothing.
78
73
  if (i === -1) {
79
74
  return;
80
75
  }
76
+ var step = steps[i];
81
77
 
82
- var step = steps[i]; // Apply granularity to the time amount
78
+ // Apply granularity to the time amount
83
79
  // (and fall back to the previous step
84
80
  // if the first level of granularity
85
81
  // isn't met by this amount)
86
-
87
82
  if (step.granularity) {
88
83
  // Recalculate the amount of seconds passed based on `granularity`.
89
- var secondsPassedGranular = getRoundFunction(round)(Math.abs(secondsPassed) / getStepDenominator(step) / step.granularity) * step.granularity; // If the granularity for this step is too high,
84
+ var secondsPassedGranular = getRoundFunction(round)(Math.abs(secondsPassed) / getStepDenominator(step) / step.granularity) * step.granularity;
85
+ // If the granularity for this step is too high,
90
86
  // then fall back to the previous step.
91
87
  // (if there is any previous step)
92
-
93
88
  if (secondsPassedGranular === 0 && i > 0) {
94
89
  return steps[i - 1];
95
90
  }
96
91
  }
97
-
98
92
  return step;
99
93
  }
94
+
100
95
  /**
101
96
  * Iterates through steps until it finds the maximum one satisfying the `minTime` threshold.
102
97
  * @param {Object} steps - Steps.
@@ -106,56 +101,49 @@ function _getStep(steps, secondsPassed, _ref2) {
106
101
  * @param {number} [i] - Gradation step currently being tested.
107
102
  * @return {number} Gradation step index.
108
103
  */
109
-
110
-
111
104
  function getStepIndex(steps, secondsPassed, options) {
112
105
  var i = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
113
106
  var minTime = getStepMinTime(steps[i], _objectSpread({
114
107
  prevStep: steps[i - 1],
115
108
  timestamp: options.now - secondsPassed * 1000
116
- }, options)); // If `minTime` isn't defined or deduceable for this step, then stop.
117
-
109
+ }, options));
110
+ // If `minTime` isn't defined or deduceable for this step, then stop.
118
111
  if (minTime === undefined) {
119
112
  return i - 1;
120
- } // If the `minTime` threshold for moving from previous step
113
+ }
114
+ // If the `minTime` threshold for moving from previous step
121
115
  // to this step is too high then return the previous step.
122
-
123
-
124
116
  if (Math.abs(secondsPassed) < minTime) {
125
117
  return i - 1;
126
- } // If it's the last step then return it.
127
-
128
-
118
+ }
119
+ // If it's the last step then return it.
129
120
  if (i === steps.length - 1) {
130
121
  return i;
131
- } // Move to the next step.
132
-
133
-
122
+ }
123
+ // Move to the next step.
134
124
  return getStepIndex(steps, secondsPassed, options, i + 1);
135
125
  }
126
+
136
127
  /**
137
128
  * Leaves only allowed steps.
138
129
  * @param {Object[]} steps
139
130
  * @param {string[]} units - Allowed time units.
140
131
  * @return {Object[]}
141
132
  */
142
-
143
-
144
133
  function filterStepsByUnits(steps, units) {
145
134
  return steps.filter(function (_ref3) {
146
135
  var unit = _ref3.unit,
147
- formatAs = _ref3.formatAs;
136
+ formatAs = _ref3.formatAs;
148
137
  // "unit" is now called "formatAs".
149
- unit = unit || formatAs; // If this step has a `unit` defined
138
+ unit = unit || formatAs;
139
+ // If this step has a `unit` defined
150
140
  // then this `unit` must be in the list of allowed `units`.
151
-
152
141
  if (unit) {
153
142
  return units.indexOf(unit) >= 0;
154
- } // A step is not required to specify a `unit`:
143
+ }
144
+ // A step is not required to specify a `unit`:
155
145
  // alternatively, it could specify `format()`.
156
146
  // (see "twitter" style for an example)
157
-
158
-
159
147
  return true;
160
148
  });
161
149
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getStep.js","names":["getStepDenominator","getStepMinTime","getRoundFunction","getStep","steps","secondsPassed","now","future","round","units","getNextStep","filterStepsByUnits","step","_getStep","prevStep","indexOf","nextStep","undefined","length","i","getStepIndex","granularity","secondsPassedGranular","Math","abs","options","minTime","timestamp","filter","unit","formatAs"],"sources":["../../source/steps/getStep.js"],"sourcesContent":["import getStepDenominator from './getStepDenominator.js'\r\nimport getStepMinTime from './getStepMinTime.js'\r\nimport { getRoundFunction } from '../round.js'\r\n\r\n/**\r\n * Finds an appropriate `step` of `steps` for the time interval (in seconds).\r\n *\r\n * @param {Object[]} steps - Time formatting steps.\r\n *\r\n * @param {number} secondsPassed - Time interval (in seconds).\r\n * `< 0` for past dates and `> 0` for future dates.\r\n *\r\n * @param {number} options.now - Current timestamp.\r\n *\r\n * @param {boolean} [options.future] - Whether the date should be formatted as a future one\r\n * instead of a past one.\r\n *\r\n * @param {string} [options.round] - (undocumented) Rounding mechanism.\r\n *\r\n * @param {string[]} [options.units] - A list of allowed time units.\r\n * (Example: ['second', 'minute', 'hour', …])\r\n *\r\n * @param {boolean} [options.getNextStep] - Pass true to return `[step, nextStep]` instead of just `step`.\r\n *\r\n * @return {Object|Object[]} [step] — Either a `step` or `[prevStep, step, nextStep]`.\r\n */\r\nexport default function getStep(steps, secondsPassed, { now, future, round, units, getNextStep }) {\r\n\t// Ignore steps having not-supported time units in `formatAs`.\r\n\tsteps = filterStepsByUnits(steps, units)\r\n\tconst step = _getStep(steps, secondsPassed, { now, future, round })\r\n\tif (getNextStep) {\r\n\t\tif (step) {\r\n\t\t\tconst prevStep = steps[steps.indexOf(step) - 1]\r\n\t\t\tconst nextStep = steps[steps.indexOf(step) + 1]\r\n\t\t\treturn [prevStep, step, nextStep]\r\n\t\t}\r\n\t\treturn [undefined, undefined, steps[0]]\r\n\t}\r\n\treturn step\r\n}\r\n\r\nfunction _getStep(steps, secondsPassed, { now, future, round }) {\r\n\t// If no steps fit the conditions then return nothing.\r\n\tif (steps.length === 0) {\r\n\t\treturn\r\n\t}\r\n\r\n\t// Find the most appropriate step.\r\n\tconst i = getStepIndex(steps, secondsPassed, {\r\n\t\tnow,\r\n\t\tfuture: future || secondsPassed < 0,\r\n\t\tround\r\n\t})\r\n\r\n\t// If no step is applicable the return nothing.\r\n\tif (i === -1) {\r\n\t\treturn\r\n\t}\r\n\r\n\tconst step = steps[i]\r\n\r\n\t// Apply granularity to the time amount\r\n\t// (and fall back to the previous step\r\n\t// if the first level of granularity\r\n\t// isn't met by this amount)\r\n\tif (step.granularity) {\r\n\t\t// Recalculate the amount of seconds passed based on `granularity`.\r\n\t\tconst secondsPassedGranular = getRoundFunction(round)((Math.abs(secondsPassed) / getStepDenominator(step)) / step.granularity) * step.granularity\r\n\t\t// If the granularity for this step is too high,\r\n\t\t// then fall back to the previous step.\r\n\t\t// (if there is any previous step)\r\n\t\tif (secondsPassedGranular === 0 && i > 0) {\r\n\t\t\treturn steps[i - 1]\r\n\t\t}\r\n\t}\r\n\r\n\treturn step\r\n}\r\n\r\n/**\r\n * Iterates through steps until it finds the maximum one satisfying the `minTime` threshold.\r\n * @param {Object} steps - Steps.\r\n * @param {number} secondsPassed - How much seconds have passed since the date till `now`.\r\n * @param {number} options.now - Current timestamp.\r\n * @param {boolean} options.future - Whether the time interval should be formatted as a future one.\r\n * @param {number} [i] - Gradation step currently being tested.\r\n * @return {number} Gradation step index.\r\n */\r\nfunction getStepIndex(steps, secondsPassed, options, i = 0) {\r\n\tconst minTime = getStepMinTime(steps[i], {\r\n\t\tprevStep: steps[i - 1],\r\n\t\ttimestamp: options.now - secondsPassed * 1000,\r\n\t\t...options\r\n\t})\r\n\t// If `minTime` isn't defined or deduceable for this step, then stop.\r\n\tif (minTime === undefined) {\r\n\t\treturn i - 1\r\n\t}\r\n\t// If the `minTime` threshold for moving from previous step\r\n\t// to this step is too high then return the previous step.\r\n\tif (Math.abs(secondsPassed) < minTime) {\r\n\t\treturn i - 1\r\n\t}\r\n\t// If it's the last step then return it.\r\n\tif (i === steps.length - 1) {\r\n\t\treturn i\r\n\t}\r\n\t// Move to the next step.\r\n\treturn getStepIndex(steps, secondsPassed, options, i + 1)\r\n}\r\n\r\n/**\r\n * Leaves only allowed steps.\r\n * @param {Object[]} steps\r\n * @param {string[]} units - Allowed time units.\r\n * @return {Object[]}\r\n */\r\nfunction filterStepsByUnits(steps, units) {\r\n\treturn steps.filter(({ unit, formatAs }) => {\r\n\t\t// \"unit\" is now called \"formatAs\".\r\n\t\tunit = unit || formatAs\r\n\t\t// If this step has a `unit` defined\r\n\t\t// then this `unit` must be in the list of allowed `units`.\r\n\t\tif (unit) {\r\n\t\t\treturn units.indexOf(unit) >= 0\r\n\t\t}\r\n\t\t// A step is not required to specify a `unit`:\r\n\t\t// alternatively, it could specify `format()`.\r\n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GAAcD,aAAa,GAAG;EAFZ,GAG1BoB,OAH0B,EAA9B,CAD2D,CAM3D;;EACA,IAAIC,OAAO,KAAKT,SAAhB,EAA2B;IAC1B,OAAOE,CAAC,GAAG,CAAX;EACA,CAT0D,CAU3D;EACA;;;EACA,IAAII,IAAI,CAACC,GAAL,CAASnB,aAAT,IAA0BqB,OAA9B,EAAuC;IACtC,OAAOP,CAAC,GAAG,CAAX;EACA,CAd0D,CAe3D;;;EACA,IAAIA,CAAC,KAAKf,KAAK,CAACc,MAAN,GAAe,CAAzB,EAA4B;IAC3B,OAAOC,CAAP;EACA,CAlB0D,CAmB3D;;;EACA,OAAOC,YAAY,CAAChB,KAAD,EAAQC,aAAR,EAAuBoB,OAAvB,EAAgCN,CAAC,GAAG,CAApC,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASR,kBAAT,CAA4BP,KAA5B,EAAmCK,KAAnC,EAA0C;EACzC,OAAOL,KAAK,CAACwB,MAAN,CAAa,iBAAwB;IAAA,IAArBC,IAAqB,SAArBA,IAAqB;IAAA,IAAfC,QAAe,SAAfA,QAAe;IAC3C;IACAD,IAAI,GAAGA,IAAI,IAAIC,QAAf,CAF2C,CAG3C;IACA;;IACA,IAAID,IAAJ,EAAU;MACT,OAAOpB,KAAK,CAACM,OAAN,CAAcc,IAAd,KAAuB,CAA9B;IACA,CAP0C,CAQ3C;IACA;IACA;;;IACA,OAAO,IAAP;EACA,CAZM,CAAP;AAaA"}
1
+ {"version":3,"file":"getStep.js","names":["getStepDenominator","getStepMinTime","getRoundFunction","getStep","steps","secondsPassed","_ref","now","future","round","units","getNextStep","filterStepsByUnits","step","_getStep","prevStep","indexOf","nextStep","undefined","_ref2","length","i","getStepIndex","granularity","secondsPassedGranular","Math","abs","options","arguments","minTime","_objectSpread","timestamp","filter","_ref3","unit","formatAs"],"sources":["../../source/steps/getStep.js"],"sourcesContent":["import getStepDenominator from './getStepDenominator.js'\r\nimport getStepMinTime from './getStepMinTime.js'\r\nimport { getRoundFunction } from '../round.js'\r\n\r\n/**\r\n * Finds an appropriate `step` of `steps` for the time interval (in seconds).\r\n *\r\n * @param {Object[]} steps - Time formatting steps.\r\n *\r\n * @param {number} secondsPassed - Time interval (in seconds).\r\n * `< 0` for past dates and `> 0` for future dates.\r\n *\r\n * @param {number} options.now - Current timestamp.\r\n *\r\n * @param {boolean} [options.future] - Whether the date should be formatted as a future one\r\n * instead of a past one.\r\n *\r\n * @param {string} [options.round] - (undocumented) Rounding mechanism.\r\n *\r\n * @param {string[]} [options.units] - A list of allowed time units.\r\n * (Example: ['second', 'minute', 'hour', …])\r\n *\r\n * @param {boolean} [options.getNextStep] - Pass true to return `[step, nextStep]` instead of just `step`.\r\n *\r\n * @return {Object|Object[]} [step] — Either a `step` or `[prevStep, step, nextStep]`.\r\n */\r\nexport default function getStep(steps, secondsPassed, { now, future, round, units, getNextStep }) {\r\n\t// Ignore steps having not-supported time units in `formatAs`.\r\n\tsteps = filterStepsByUnits(steps, units)\r\n\tconst step = _getStep(steps, secondsPassed, { now, future, round })\r\n\tif (getNextStep) {\r\n\t\tif (step) {\r\n\t\t\tconst prevStep = steps[steps.indexOf(step) - 1]\r\n\t\t\tconst nextStep = steps[steps.indexOf(step) + 1]\r\n\t\t\treturn [prevStep, step, nextStep]\r\n\t\t}\r\n\t\treturn [undefined, undefined, steps[0]]\r\n\t}\r\n\treturn step\r\n}\r\n\r\nfunction _getStep(steps, secondsPassed, { now, future, round }) {\r\n\t// If no steps fit the conditions then return nothing.\r\n\tif (steps.length === 0) {\r\n\t\treturn\r\n\t}\r\n\r\n\t// Find the most appropriate step.\r\n\tconst i = getStepIndex(steps, secondsPassed, {\r\n\t\tnow,\r\n\t\tfuture: future || secondsPassed < 0,\r\n\t\tround\r\n\t})\r\n\r\n\t// If no step is applicable the return nothing.\r\n\tif (i === -1) {\r\n\t\treturn\r\n\t}\r\n\r\n\tconst step = steps[i]\r\n\r\n\t// Apply granularity to the time amount\r\n\t// (and fall back to the previous step\r\n\t// if the first level of granularity\r\n\t// isn't met by this amount)\r\n\tif (step.granularity) {\r\n\t\t// Recalculate the amount of seconds passed based on `granularity`.\r\n\t\tconst secondsPassedGranular = getRoundFunction(round)((Math.abs(secondsPassed) / getStepDenominator(step)) / step.granularity) * step.granularity\r\n\t\t// If the granularity for this step is too high,\r\n\t\t// then fall back to the previous step.\r\n\t\t// (if there is any previous step)\r\n\t\tif (secondsPassedGranular === 0 && i > 0) {\r\n\t\t\treturn steps[i - 1]\r\n\t\t}\r\n\t}\r\n\r\n\treturn step\r\n}\r\n\r\n/**\r\n * Iterates through steps until it finds the maximum one satisfying the `minTime` threshold.\r\n * @param {Object} steps - Steps.\r\n * @param {number} secondsPassed - How much seconds have passed since the date till `now`.\r\n * @param {number} options.now - Current timestamp.\r\n * @param {boolean} options.future - Whether the time interval should be formatted as a future one.\r\n * @param {number} [i] - Gradation step currently being tested.\r\n * @return {number} Gradation step index.\r\n */\r\nfunction getStepIndex(steps, secondsPassed, options, i = 0) {\r\n\tconst minTime = getStepMinTime(steps[i], {\r\n\t\tprevStep: steps[i - 1],\r\n\t\ttimestamp: options.now - secondsPassed * 1000,\r\n\t\t...options\r\n\t})\r\n\t// If `minTime` isn't defined or deduceable for this step, then stop.\r\n\tif (minTime === undefined) {\r\n\t\treturn i - 1\r\n\t}\r\n\t// If the `minTime` threshold for moving from previous step\r\n\t// to this step is too high then return the previous step.\r\n\tif (Math.abs(secondsPassed) < minTime) {\r\n\t\treturn i - 1\r\n\t}\r\n\t// If it's the last step then return it.\r\n\tif (i === steps.length - 1) {\r\n\t\treturn i\r\n\t}\r\n\t// Move to the next step.\r\n\treturn getStepIndex(steps, secondsPassed, options, i + 1)\r\n}\r\n\r\n/**\r\n * Leaves only allowed steps.\r\n * @param {Object[]} steps\r\n * @param {string[]} units - Allowed time units.\r\n * @return {Object[]}\r\n */\r\nfunction filterStepsByUnits(steps, units) {\r\n\treturn steps.filter(({ unit, formatAs }) => {\r\n\t\t// \"unit\" is now called \"formatAs\".\r\n\t\tunit = unit || formatAs\r\n\t\t// If this step has a `unit` defined\r\n\t\t// then this `unit` must be in the list of allowed `units`.\r\n\t\tif (unit) {\r\n\t\t\treturn units.indexOf(unit) >= 0\r\n\t\t}\r\n\t\t// A step is not required to specify a `unit`:\r\n\t\t// alternatively, it could specify `format()`.\r\n\t\t// (see \"twitter\" style for an example)\r\n\t\treturn true\r\n\t})\r\n}"],"mappings":";;;;;;AAAA,OAAOA,kBAAkB,MAAM,yBAAyB;AACxD,OAAOC,cAAc,MAAM,qBAAqB;AAChD,SAASC,gBAAgB,QAAQ,aAAa;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,OAAOA,CAACC,KAAK,EAAEC,aAAa,EAAAC,IAAA,EAA8C;EAAA,IAA1CC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IAAEC,MAAM,GAAAF,IAAA,CAANE,MAAM;IAAEC,KAAK,GAAAH,IAAA,CAALG,KAAK;IAAEC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IAAEC,WAAW,GAAAL,IAAA,CAAXK,WAAW;EAC7F;EACAP,KAAK,GAAGQ,kBAAkB,CAACR,KAAK,EAAEM,KAAK,CAAC;EACxC,IAAMG,IAAI,GAAGC,QAAQ,CAACV,KAAK,EAAEC,aAAa,EAAE;IAAEE,GAAG,EAAHA,GAAG;IAAEC,MAAM,EAANA,MAAM;IAAEC,KAAK,EAALA;EAAM,CAAC,CAAC;EACnE,IAAIE,WAAW,EAAE;IAChB,IAAIE,IAAI,EAAE;MACT,IAAME,QAAQ,GAAGX,KAAK,CAACA,KAAK,CAACY,OAAO,CAACH,IAAI,CAAC,GAAG,CAAC,CAAC;MAC/C,IAAMI,QAAQ,GAAGb,KAAK,CAACA,KAAK,CAACY,OAAO,CAACH,IAAI,CAAC,GAAG,CAAC,CAAC;MAC/C,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, {
6
6
  units: ['femtosecond']
7
7
  })).to.be.undefined;
8
- }); // it('should throw if a non-first step does not have a `minTime` or `test()`', () => {
8
+ });
9
+
10
+ // it('should throw if a non-first step does not have a `minTime` or `test()`', () => {
9
11
  // expect(getStep([{ unit: 'second' }], 2, { units: ['second'] })).to.deep.equal({ unit: 'second' })
10
12
  //
11
13
  // expect(() => {
@@ -22,7 +24,9 @@ describe('getStep', function () {
22
24
  getStep(steps, 1.49, {
23
25
  now: 0,
24
26
  units: ['now', 'second']
25
- }).formatAs.should.equal('now'); // And if there's no previous step, then use the current one.
27
+ }).formatAs.should.equal('now');
28
+
29
+ // And if there's no previous step, then use the current one.
26
30
 
27
31
  var firstStep = steps[0];
28
32
  steps.splice(0, 1);
@@ -1 +1 @@
1
- {"version":3,"file":"getStep.test.js","names":["getStep","round","describe","it","expect","units","to","be","undefined","steps","slice","formatAs","should","equal","granularity","now","firstStep","splice","unshift","unit","minTime","id","seconds","threshold"],"sources":["../../source/steps/getStep.test.js"],"sourcesContent":["import getStep from './getStep.js'\r\nimport round from './round.js'\r\n\r\ndescribe('getStep', () => {\r\n\tit('should return nothing if no time units are supported', () => {\r\n\t\texpect(getStep(round, 0, { units: ['femtosecond'] })).to.be.undefined\r\n\t})\r\n\r\n\t// it('should throw if a non-first step does not have a `minTime` or `test()`', () => {\r\n\t// \texpect(getStep([{ unit: 'second' }], 2, { units: ['second'] })).to.deep.equal({ unit: 'second' })\r\n\t//\r\n\t// \texpect(() => {\r\n\t// \t\tgetStep([{ unit: 'second' }, { unit: 'minute' }], 2, { units: ['second', 'minute'] })\r\n\t// \t}).to.throw(\r\n\t// \t\t'Each step must define either `minTime` or `test()`, except for the first one. Got \"undefined\", undefined. Step: {\"unit\":\"minute\"}'\r\n\t// \t)\r\n\t// })\r\n\r\n\tit('should fall back to previous step if granularity is too high for the next step', () => {\r\n\t\tconst steps = round.slice()\r\n\r\n\t\tsteps[1].formatAs.should.equal('second')\r\n\t\tsteps[1].granularity = 3\r\n\r\n\t\tgetStep(steps, 1.49, { now: 0, units: ['now', 'second'] }).formatAs.should.equal('now')\r\n\r\n\t\t// And if there's no previous step, then use the current one.\r\n\r\n\t\tconst firstStep = steps[0]\r\n\t\tsteps.splice(0, 1)\r\n\r\n\t\tgetStep(steps, 1.49, { now: 0, units: ['now', 'second'] }).formatAs.should.equal('second')\r\n\r\n\t\tsteps.unshift(firstStep)\r\n\r\n\t\tdelete steps[1].granularity\r\n\t})\r\n\r\n\tit('should support `minTime` object', () => {\r\n\t\texpect(getStep(\r\n\t\t\t[\r\n\t\t\t\t{ unit: 'second' },\r\n\t\t\t\t{\r\n\t\t\t\t\tminTime: { default: 10 },\r\n\t\t\t\t\tunit: 'minute'\r\n\t\t\t\t}\r\n\t\t\t],\r\n\t\t\t5,\r\n\t\t\t{ now: 0, units: ['second', 'minute'] }\r\n\t\t).unit).to.equal('second')\r\n\r\n\t\texpect(getStep(\r\n\t\t\t[\r\n\t\t\t\t{ unit: 'second' },\r\n\t\t\t\t{\r\n\t\t\t\t\tminTime: { default: 10 },\r\n\t\t\t\t\tunit: 'minute'\r\n\t\t\t\t}\r\n\t\t\t],\r\n\t\t\t10,\r\n\t\t\t{ now: 0, units: ['second', 'minute'] }\r\n\t\t).unit).to.equal('minute')\r\n\r\n\t\texpect(getStep(\r\n\t\t\t[\r\n\t\t\t\t{\r\n\t\t\t\t\tid: 'seconds',\r\n\t\t\t\t\tunit: 'second'\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\tminTime: {\r\n\t\t\t\t\t\tseconds: 20,\r\n\t\t\t\t\t\tdefault: 10\r\n\t\t\t\t\t},\r\n\t\t\t\t\tunit: 'minute'\r\n\t\t\t\t}\r\n\t\t\t],\r\n\t\t\t10,\r\n\t\t\t{ now: 0, units: ['second', 'minute'] }\r\n\t\t).unit).to.equal('second')\r\n\t})\r\n\r\n\tit('should support legacy `threshold()` function', () => {\r\n\t\texpect(getStep(\r\n\t\t\t[\r\n\t\t\t\t{ unit: 'second' },\r\n\t\t\t\t{\r\n\t\t\t\t\tthreshold: () => 10,\r\n\t\t\t\t\tunit: 'minute'\r\n\t\t\t\t}\r\n\t\t\t],\r\n\t\t\t5,\r\n\t\t\t{ now: 0, units: ['second', 'minute'] }\r\n\t\t).unit).to.equal('second')\r\n\r\n\t\texpect(getStep(\r\n\t\t\t[\r\n\t\t\t\t{ unit: 'second' },\r\n\t\t\t\t{\r\n\t\t\t\t\tthreshold: () => 10,\r\n\t\t\t\t\tunit: 'minute'\r\n\t\t\t\t}\r\n\t\t\t],\r\n\t\t\t10,\r\n\t\t\t{ now: 0, units: ['second', 'minute'] }\r\n\t\t).unit).to.equal('minute')\r\n\t})\r\n\r\n\tit('should stop when reaching a step that has no \"minTime\" and for which \"minTime\" could not be deduced', () => {\r\n\t\texpect(getStep(\r\n\t\t\t[\r\n\t\t\t\t{ formatAs: 'second' },\r\n\t\t\t\t{ formatAs: 'unsupported-time-unit' }\r\n\t\t\t],\r\n\t\t\t10,\r\n\t\t\t{ now: 0, units: ['second', 'unsupported-time-unit'] }\r\n\t\t).formatAs).to.equal('second')\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,cAApB;AACA,OAAOC,KAAP,MAAkB,YAAlB;AAEAC,QAAQ,CAAC,SAAD,EAAY,YAAM;EACzBC,EAAE,CAAC,sDAAD,EAAyD,YAAM;IAChEC,MAAM,CAACJ,OAAO,CAACC,KAAD,EAAQ,CAAR,EAAW;MAAEI,KAAK,EAAE,CAAC,aAAD;IAAT,CAAX,CAAR,CAAN,CAAsDC,EAAtD,CAAyDC,EAAzD,CAA4DC,SAA5D;EACA,CAFC,CAAF,CADyB,CAKzB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEAL,EAAE,CAAC,gFAAD,EAAmF,YAAM;IAC1F,IAAMM,KAAK,GAAGR,KAAK,CAACS,KAAN,EAAd;IAEAD,KAAK,CAAC,CAAD,CAAL,CAASE,QAAT,CAAkBC,MAAlB,C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,EAAE,CAAC,qGAAD,EAAwG,YAAM;IAC/GC,MAAM,CAACJ,OAAO,CACb,CACC;MAAEW,QAAQ,EAAE;IAAZ,CADD,EAEC;MAAEA,QAAQ,EAAE;IAAZ,CAFD,CADa,EAKb,EALa,EAMb;MAAEI,GAAG,EAAE,CAAP;MAAUV,KAAK,EAAE,CAAC,QAAD,EAAW,uBAAX;IAAjB,CANa,CAAP,CAOLM,QAPI,CAAN,CAOYL,EAPZ,CAOeO,KAPf,CAOqB,QAPrB;EAQA,CATC,CAAF;AAUA,CAnHO,CAAR"}
1
+ {"version":3,"file":"getStep.test.js","names":["getStep","round","describe","it","expect","units","to","be","undefined","steps","slice","formatAs","should","equal","granularity","now","firstStep","splice","unshift","unit","minTime","id","seconds","threshold"],"sources":["../../source/steps/getStep.test.js"],"sourcesContent":["import getStep from './getStep.js'\r\nimport round from './round.js'\r\n\r\ndescribe('getStep', () => {\r\n\tit('should return nothing if no time units are supported', () => {\r\n\t\texpect(getStep(round, 0, { units: ['femtosecond'] })).to.be.undefined\r\n\t})\r\n\r\n\t// it('should throw if a non-first step does not have a `minTime` or `test()`', () => {\r\n\t// \texpect(getStep([{ unit: 'second' }], 2, { units: ['second'] })).to.deep.equal({ unit: 'second' })\r\n\t//\r\n\t// \texpect(() => {\r\n\t// \t\tgetStep([{ unit: 'second' }, { unit: 'minute' }], 2, { units: ['second', 'minute'] })\r\n\t// \t}).to.throw(\r\n\t// \t\t'Each step must define either `minTime` or `test()`, except for the first one. Got \"undefined\", undefined. Step: {\"unit\":\"minute\"}'\r\n\t// \t)\r\n\t// })\r\n\r\n\tit('should fall back to previous step if granularity is too high for the next step', () => {\r\n\t\tconst steps = round.slice()\r\n\r\n\t\tsteps[1].formatAs.should.equal('second')\r\n\t\tsteps[1].granularity = 3\r\n\r\n\t\tgetStep(steps, 1.49, { now: 0, units: ['now', 'second'] }).formatAs.should.equal('now')\r\n\r\n\t\t// And if there's no previous step, then use the current one.\r\n\r\n\t\tconst firstStep = steps[0]\r\n\t\tsteps.splice(0, 1)\r\n\r\n\t\tgetStep(steps, 1.49, { now: 0, units: ['now', 'second'] }).formatAs.should.equal('second')\r\n\r\n\t\tsteps.unshift(firstStep)\r\n\r\n\t\tdelete steps[1].granularity\r\n\t})\r\n\r\n\tit('should support `minTime` object', () => {\r\n\t\texpect(getStep(\r\n\t\t\t[\r\n\t\t\t\t{ unit: 'second' },\r\n\t\t\t\t{\r\n\t\t\t\t\tminTime: { default: 10 },\r\n\t\t\t\t\tunit: 'minute'\r\n\t\t\t\t}\r\n\t\t\t],\r\n\t\t\t5,\r\n\t\t\t{ now: 0, units: ['second', 'minute'] }\r\n\t\t).unit).to.equal('second')\r\n\r\n\t\texpect(getStep(\r\n\t\t\t[\r\n\t\t\t\t{ unit: 'second' },\r\n\t\t\t\t{\r\n\t\t\t\t\tminTime: { default: 10 },\r\n\t\t\t\t\tunit: 'minute'\r\n\t\t\t\t}\r\n\t\t\t],\r\n\t\t\t10,\r\n\t\t\t{ now: 0, units: ['second', 'minute'] }\r\n\t\t).unit).to.equal('minute')\r\n\r\n\t\texpect(getStep(\r\n\t\t\t[\r\n\t\t\t\t{\r\n\t\t\t\t\tid: 'seconds',\r\n\t\t\t\t\tunit: 'second'\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\tminTime: {\r\n\t\t\t\t\t\tseconds: 20,\r\n\t\t\t\t\t\tdefault: 10\r\n\t\t\t\t\t},\r\n\t\t\t\t\tunit: 'minute'\r\n\t\t\t\t}\r\n\t\t\t],\r\n\t\t\t10,\r\n\t\t\t{ now: 0, units: ['second', 'minute'] }\r\n\t\t).unit).to.equal('second')\r\n\t})\r\n\r\n\tit('should support legacy `threshold()` function', () => {\r\n\t\texpect(getStep(\r\n\t\t\t[\r\n\t\t\t\t{ unit: 'second' },\r\n\t\t\t\t{\r\n\t\t\t\t\tthreshold: () => 10,\r\n\t\t\t\t\tunit: 'minute'\r\n\t\t\t\t}\r\n\t\t\t],\r\n\t\t\t5,\r\n\t\t\t{ now: 0, units: ['second', 'minute'] }\r\n\t\t).unit).to.equal('second')\r\n\r\n\t\texpect(getStep(\r\n\t\t\t[\r\n\t\t\t\t{ unit: 'second' },\r\n\t\t\t\t{\r\n\t\t\t\t\tthreshold: () => 10,\r\n\t\t\t\t\tunit: 'minute'\r\n\t\t\t\t}\r\n\t\t\t],\r\n\t\t\t10,\r\n\t\t\t{ now: 0, units: ['second', 'minute'] }\r\n\t\t).unit).to.equal('minute')\r\n\t})\r\n\r\n\tit('should stop when reaching a step that has no \"minTime\" and for which \"minTime\" could not be deduced', () => {\r\n\t\texpect(getStep(\r\n\t\t\t[\r\n\t\t\t\t{ formatAs: 'second' },\r\n\t\t\t\t{ formatAs: 'unsupported-time-unit' }\r\n\t\t\t],\r\n\t\t\t10,\r\n\t\t\t{ now: 0, units: ['second', 'unsupported-time-unit'] }\r\n\t\t).formatAs).to.equal('second')\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,OAAO,MAAM,cAAc;AAClC,OAAOC,KAAK,MAAM,YAAY;AAE9BC,QAAQ,CAAC,SAAS,EAAE,YAAM;EACzBC,EAAE,CAAC,sDAAsD,EAAE,YAAM;IAChEC,MAAM,CAACJ,OAAO,CAACC,KAAK,EAAE,CAAC,EAAE;MAAEI,KAAK,EAAE,CAAC,aAAa;IAAE,CAAC,CAAC,CAAC,CAACC,EAAE,CAACC,EAAE,CAACC,SAAS;EACtE,CAAC,CAAC;;EAEF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEAL,EAAE,CAAC,gFAAgF,EAAE,YAAM;IAC1F,IAAMM,KAAK,GAAGR,KAAK,CAACS,KAAK,CAAC,CAAC;IAE3BD,KAAK,CAAC,CAAC,CAAC,CAACE,QAAQ,CAACC,MAAM,CAACC,KAAK,CAAC,QAAQ,CAAC;IACxCJ,KAAK,CAAC,CAAC,CAAC,CAACK,WAAW,GAAG,CAAC;IAExBd,OAAO,CAACS,KAAK,EAAE,IAAI,EAAE;MAAE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AEA,QAAQ,EAAE;IAAwB,CAAC,CACrC,EACD,EAAE,EACF;MAAEI,GAAG,EAAE,CAAC;MAAEV,KAAK,EAAE,CAAC,QAAQ,EAAE,uBAAuB;IAAE,CACtD,CAAC,CAACM,QAAQ,CAAC,CAACL,EAAE,CAACO,KAAK,CAAC,QAAQ,CAAC;EAC/B,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
@@ -3,9 +3,8 @@ export default function getStepDenominator(step) {
3
3
  // `factor` is a legacy property.
4
4
  if (step.factor !== undefined) {
5
5
  return step.factor;
6
- } // "unit" is now called "formatAs".
7
-
8
-
6
+ }
7
+ // "unit" is now called "formatAs".
9
8
  return getSecondsInUnit(step.unit || step.formatAs) || 1;
10
9
  }
11
10
  //# sourceMappingURL=getStepDenominator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getStepDenominator.js","names":["getSecondsInUnit","getStepDenominator","step","factor","undefined","unit","formatAs"],"sources":["../../source/steps/getStepDenominator.js"],"sourcesContent":["import { getSecondsInUnit } from './units.js'\r\n\r\nexport default function getStepDenominator(step) {\r\n\t// `factor` is a legacy property.\r\n\tif (step.factor !== undefined) {\r\n\t\treturn step.factor\r\n\t}\r\n\t// \"unit\" is now called \"formatAs\".\r\n\treturn getSecondsInUnit(step.unit || step.formatAs) || 1\r\n}"],"mappings":"AAAA,SAASA,gBAAT,QAAiC,YAAjC;AAEA,eAAe,SAASC,kBAAT,CAA4BC,IAA5B,EAAkC;EAChD;EACA,IAAIA,IAAI,CAACC,MAAL,KAAgBC,SAApB,EAA+B;IAC9B,OAAOF,IAAI,CAACC,MAAZ;EACA,CAJ+C,CAKhD;;;EACA,OAAOH,gBAAgB,CAACE,IAAI,CAACG,IAAL,IAAaH,IAAI,CAACI,QAAnB,CAAhB,IAAgD,CAAvD;AACA"}
1
+ {"version":3,"file":"getStepDenominator.js","names":["getSecondsInUnit","getStepDenominator","step","factor","undefined","unit","formatAs"],"sources":["../../source/steps/getStepDenominator.js"],"sourcesContent":["import { getSecondsInUnit } from './units.js'\r\n\r\nexport default function getStepDenominator(step) {\r\n\t// `factor` is a legacy property.\r\n\tif (step.factor !== undefined) {\r\n\t\treturn step.factor\r\n\t}\r\n\t// \"unit\" is now called \"formatAs\".\r\n\treturn getSecondsInUnit(step.unit || step.formatAs) || 1\r\n}"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,YAAY;AAE7C,eAAe,SAASC,kBAAkBA,CAACC,IAAI,EAAE;EAChD;EACA,IAAIA,IAAI,CAACC,MAAM,KAAKC,SAAS,EAAE;IAC9B,OAAOF,IAAI,CAACC,MAAM;EACnB;EACA;EACA,OAAOH,gBAAgB,CAACE,IAAI,CAACG,IAAI,IAAIH,IAAI,CAACI,QAAQ,CAAC,IAAI,CAAC;AACzD","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"getStepDenominator.test.js","names":["getStepDenominator","describe","it","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,OAAOA,kBAAP,MAA+B,yBAA/B;AAEAC,QAAQ,CAAC,oBAAD,EAAuB,YAAM;EACpCC,EAAE,CAAC,sCAAD,EAAyC,YAAM;IAChDF,kBAAkB,CAAC;MAAEG,IAAI,EAAE;IAAR,CAAD,CAAlB,CAAuCC,MAAvC,CAA8CC,KAA9C,CAAoD,EAApD;EACA,CAFC,CAAF;EAIAH,EAAE,CAAC,4CAAD,EAA+C,YAAM;IACtDF,kBAAkB,CAAC;MAAEM,QAAQ,EAAE;IAAZ,CAAD,CAAlB,CAA2CF,MAA3C,CAAkDC,KAAlD,CAAwD,CAAxD;EACA,CAFC,CAAF;AAGA,CARO,CAAR"}
1
+ {"version":3,"file":"getStepDenominator.test.js","names":["getStepDenominator","describe","it","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,OAAOA,kBAAkB,MAAM,yBAAyB;AAExDC,QAAQ,CAAC,oBAAoB,EAAE,YAAM;EACpCC,EAAE,CAAC,sCAAsC,EAAE,YAAM;IAChDF,kBAAkB,CAAC;MAAEG,IAAI,EAAE;IAAS,CAAC,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,EAAE,CAAC;EACxD,CAAC,CAAC;EAEFH,EAAE,CAAC,4CAA4C,EAAE,YAAM;IACtDF,kBAAkB,CAAC;MAAEM,QAAQ,EAAE;IAAS,CAAC,CAAC,CAACF,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC;EAC3D,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
@@ -1,39 +1,35 @@
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
+ // "threshold_for_xxx" is a legacy property.
13
12
  if (prevStep) {
14
13
  if (prevStep.id || prevStep.unit) {
15
14
  minTime = step["threshold_for_".concat(prevStep.id || prevStep.unit)];
16
15
  }
17
16
  }
18
-
19
17
  if (minTime === undefined) {
20
18
  // "threshold" is a legacy property.
21
19
  if (step.threshold !== undefined) {
22
20
  // "threshold" is a legacy name for "minTime".
23
- minTime = step.threshold; // "threshold" function is deprecated.
24
-
21
+ minTime = step.threshold;
22
+ // "threshold" function is deprecated.
25
23
  if (typeof minTime === 'function') {
26
24
  minTime = minTime(now, future);
27
25
  }
28
26
  }
29
27
  }
30
-
31
28
  if (minTime === undefined) {
32
29
  minTime = step.minTime;
33
- } // A deprecated way of specifying a different threshold
30
+ }
31
+ // A deprecated way of specifying a different threshold
34
32
  // depending on the previous step's unit.
35
-
36
-
37
33
  if (_typeof(minTime) === 'object') {
38
34
  if (prevStep && prevStep.id && minTime[prevStep.id] !== undefined) {
39
35
  minTime = minTime[prevStep.id];
@@ -41,7 +37,6 @@ export default function getStepMinTime(step, _ref) {
41
37
  minTime = minTime["default"];
42
38
  }
43
39
  }
44
-
45
40
  if (typeof minTime === 'function') {
46
41
  minTime = minTime(timestamp, {
47
42
  future: future,
@@ -51,10 +46,9 @@ export default function getStepMinTime(step, _ref) {
51
46
  });
52
47
  }
53
48
  });
54
- } // Evaluate the `test()` function.
49
+ }
50
+ // Evaluate the `test()` function.
55
51
  // `test()` function is deprecated.
56
-
57
-
58
52
  if (minTime === undefined) {
59
53
  if (step.test) {
60
54
  if (step.test(timestamp, {
@@ -69,7 +63,6 @@ export default function getStepMinTime(step, _ref) {
69
63
  }
70
64
  }
71
65
  }
72
-
73
66
  if (minTime === undefined) {
74
67
  if (prevStep) {
75
68
  if (step.formatAs && prevStep.formatAs) {
@@ -81,33 +74,28 @@ export default function getStepMinTime(step, _ref) {
81
74
  // The first step's `minTime` is `0` by default.
82
75
  minTime = 0;
83
76
  }
84
- } // Warn if no `minTime` was defined or could be deduced.
85
-
86
-
77
+ }
78
+ // Warn if no `minTime` was defined or could be deduced.
87
79
  if (minTime === undefined) {
88
80
  console.warn('[javascript-time-ago] A step should specify `minTime`:\n' + JSON.stringify(step, null, 2));
89
81
  }
90
-
91
82
  return minTime;
92
83
  }
93
-
94
84
  function _getMinTimeForUnit(toUnit, fromUnit, _ref2) {
95
85
  var round = _ref2.round;
96
- var toUnitAmount = getSecondsInUnit(toUnit); // if (!fromUnit) {
86
+ var toUnitAmount = getSecondsInUnit(toUnit);
87
+ // if (!fromUnit) {
97
88
  // return toUnitAmount;
98
89
  // }
99
90
  // if (!fromUnit) {
100
91
  // fromUnit = getPreviousUnitFor(toUnit)
101
92
  // }
102
-
103
93
  var fromUnitAmount;
104
-
105
94
  if (fromUnit === 'now') {
106
95
  fromUnitAmount = getSecondsInUnit(toUnit);
107
96
  } else {
108
97
  fromUnitAmount = getSecondsInUnit(fromUnit);
109
98
  }
110
-
111
99
  if (toUnitAmount !== undefined && fromUnitAmount !== undefined) {
112
100
  return toUnitAmount - fromUnitAmount * (1 - getDiffRatioToNextRoundedNumber(round));
113
101
  }