javascript-time-ago 2.5.11 → 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 (433) 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/qu.json +46 -46
  281. package/locale/qu.json.js +46 -46
  282. package/locale/rhg/package.json +16 -0
  283. package/locale/rhg.json +159 -0
  284. package/locale/rhg.json.d.ts +4 -0
  285. package/locale/rhg.json.js +159 -0
  286. package/locale/sl.json +12 -12
  287. package/locale/sl.json.js +12 -12
  288. package/locale/sr-Cyrl-BA.json +2 -2
  289. package/locale/sr-Cyrl-BA.json.js +2 -2
  290. package/locale/sr-Latn-BA.json +2 -2
  291. package/locale/sr-Latn-BA.json.js +2 -2
  292. package/locale/sv.json +1 -1
  293. package/locale/sv.json.js +1 -1
  294. package/locale/syr/package.json +16 -0
  295. package/locale/syr.json +303 -0
  296. package/locale/syr.json.d.ts +4 -0
  297. package/locale/syr.json.js +303 -0
  298. package/locale/ti.json +6 -6
  299. package/locale/ti.json.js +6 -6
  300. package/locale/tn/package.json +16 -0
  301. package/locale/tn.json +159 -0
  302. package/locale/tn.json.d.ts +4 -0
  303. package/locale/tn.json.js +159 -0
  304. package/locale/to.json +26 -26
  305. package/locale/to.json.js +26 -26
  306. package/locale/uk.json +1 -1
  307. package/locale/uk.json.js +1 -1
  308. package/locale/ur-IN.json +9 -6
  309. package/locale/ur-IN.json.js +9 -6
  310. package/locale/vec/package.json +16 -0
  311. package/locale/vec.json +267 -0
  312. package/locale/vec.json.d.ts +4 -0
  313. package/locale/vec.json.js +267 -0
  314. package/locale/xnr/package.json +16 -0
  315. package/locale/xnr.json +159 -0
  316. package/locale/xnr.json.d.ts +4 -0
  317. package/locale/xnr.json.js +159 -0
  318. package/locale/yo-BJ.json +17 -17
  319. package/locale/yo-BJ.json.js +17 -17
  320. package/locale/yo.json +17 -17
  321. package/locale/yo.json.js +17 -17
  322. package/modules/LocaleDataStore.js +2 -3
  323. package/modules/LocaleDataStore.js.map +1 -1
  324. package/modules/PropTypes.js +11 -7
  325. package/modules/PropTypes.js.map +1 -1
  326. package/modules/TimeAgo.js +135 -174
  327. package/modules/TimeAgo.js.map +1 -1
  328. package/modules/TimeAgo.test.js +126 -115
  329. package/modules/TimeAgo.test.js.map +1 -1
  330. package/modules/cache.js +6 -22
  331. package/modules/cache.js.map +1 -1
  332. package/modules/cache.test.js.map +1 -1
  333. package/modules/isStyleObject.js +9 -7
  334. package/modules/isStyleObject.js.map +1 -1
  335. package/modules/isStyleObject.test.js.map +1 -1
  336. package/modules/locale.js +6 -16
  337. package/modules/locale.js.map +1 -1
  338. package/modules/locale.test.js +0 -4
  339. package/modules/locale.test.js.map +1 -1
  340. package/modules/round.js +2 -3
  341. package/modules/round.js.map +1 -1
  342. package/modules/steps/approximate.js +6 -2
  343. package/modules/steps/approximate.js.map +1 -1
  344. package/modules/steps/approximate.test.js +0 -2
  345. package/modules/steps/approximate.test.js.map +1 -1
  346. package/modules/steps/getStep.js +36 -48
  347. package/modules/steps/getStep.js.map +1 -1
  348. package/modules/steps/getStep.test.js +6 -2
  349. package/modules/steps/getStep.test.js.map +1 -1
  350. package/modules/steps/getStepDenominator.js +2 -3
  351. package/modules/steps/getStepDenominator.js.map +1 -1
  352. package/modules/steps/getStepDenominator.test.js.map +1 -1
  353. package/modules/steps/getStepMinTime.js +17 -29
  354. package/modules/steps/getStepMinTime.js.map +1 -1
  355. package/modules/steps/getStepMinTime.test.js.map +1 -1
  356. package/modules/steps/getTimeToNextUpdate.js +19 -31
  357. package/modules/steps/getTimeToNextUpdate.js.map +1 -1
  358. package/modules/steps/getTimeToNextUpdate.test.js +27 -18
  359. package/modules/steps/getTimeToNextUpdate.test.js.map +1 -1
  360. package/modules/steps/getTimeToNextUpdateForUnit.js +4 -10
  361. package/modules/steps/getTimeToNextUpdateForUnit.js.map +1 -1
  362. package/modules/steps/getTimeToNextUpdateForUnit.test.js +0 -4
  363. package/modules/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
  364. package/modules/steps/helpers.js +1 -1
  365. package/modules/steps/helpers.js.map +1 -1
  366. package/modules/steps/helpers.test.js.map +1 -1
  367. package/modules/steps/index.js +2 -1
  368. package/modules/steps/index.js.map +1 -1
  369. package/modules/steps/renameLegacyProperties.js +6 -13
  370. package/modules/steps/renameLegacyProperties.js.map +1 -1
  371. package/modules/steps/renameLegacyProperties.test.js.map +1 -1
  372. package/modules/steps/round.js.map +1 -1
  373. package/modules/steps/round.test.js +0 -3
  374. package/modules/steps/round.test.js.map +1 -1
  375. package/modules/steps/units.js +5 -9
  376. package/modules/steps/units.js.map +1 -1
  377. package/modules/style/approximate.js +5 -1
  378. package/modules/style/approximate.js.map +1 -1
  379. package/modules/style/approximateTime.js +6 -2
  380. package/modules/style/approximateTime.js.map +1 -1
  381. package/modules/style/approximateTime.test.js +115 -70
  382. package/modules/style/approximateTime.test.js.map +1 -1
  383. package/modules/style/getStyleByName.js +4 -17
  384. package/modules/style/getStyleByName.js.map +1 -1
  385. package/modules/style/mini.js +8 -4
  386. package/modules/style/mini.js.map +1 -1
  387. package/modules/style/mini.test.js +14 -20
  388. package/modules/style/mini.test.js.map +1 -1
  389. package/modules/style/miniMinute.js +6 -6
  390. package/modules/style/miniMinute.js.map +1 -1
  391. package/modules/style/miniMinute.test.js +10 -12
  392. package/modules/style/miniMinute.test.js.map +1 -1
  393. package/modules/style/miniMinuteNow.js +6 -6
  394. package/modules/style/miniMinuteNow.js.map +1 -1
  395. package/modules/style/miniMinuteNow.test.js +10 -12
  396. package/modules/style/miniMinuteNow.test.js.map +1 -1
  397. package/modules/style/miniNow.js +6 -6
  398. package/modules/style/miniNow.js.map +1 -1
  399. package/modules/style/miniNow.test.js +10 -12
  400. package/modules/style/miniNow.test.js.map +1 -1
  401. package/modules/style/renameLegacyProperties.js +8 -10
  402. package/modules/style/renameLegacyProperties.js.map +1 -1
  403. package/modules/style/renameLegacyProperties.test.js +0 -1
  404. package/modules/style/renameLegacyProperties.test.js.map +1 -1
  405. package/modules/style/round.js +3 -2
  406. package/modules/style/round.js.map +1 -1
  407. package/modules/style/round.test.js +50 -62
  408. package/modules/style/round.test.js.map +1 -1
  409. package/modules/style/roundMinute.js +8 -7
  410. package/modules/style/roundMinute.js.map +1 -1
  411. package/modules/style/roundMinute.test.js +19 -22
  412. package/modules/style/roundMinute.test.js.map +1 -1
  413. package/modules/style/twitter.js +35 -32
  414. package/modules/style/twitter.js.map +1 -1
  415. package/modules/style/twitter.test.js +48 -50
  416. package/modules/style/twitter.test.js.map +1 -1
  417. package/modules/style/twitterFirstMinute.js +8 -7
  418. package/modules/style/twitterFirstMinute.js.map +1 -1
  419. package/modules/style/twitterFirstMinute.test.js +15 -18
  420. package/modules/style/twitterFirstMinute.test.js.map +1 -1
  421. package/modules/style/twitterMinute.js +6 -6
  422. package/modules/style/twitterMinute.js.map +1 -1
  423. package/modules/style/twitterMinute.test.js +19 -20
  424. package/modules/style/twitterMinute.test.js.map +1 -1
  425. package/modules/style/twitterMinuteNow.js +6 -6
  426. package/modules/style/twitterMinuteNow.js.map +1 -1
  427. package/modules/style/twitterMinuteNow.test.js +19 -20
  428. package/modules/style/twitterMinuteNow.test.js.map +1 -1
  429. package/modules/style/twitterNow.js +6 -6
  430. package/modules/style/twitterNow.js.map +1 -1
  431. package/modules/style/twitterNow.test.js +17 -19
  432. package/modules/style/twitterNow.test.js.map +1 -1
  433. package/package.json +261 -4
@@ -1 +1 @@
1
- {"version":3,"file":"locale.test.js","names":["describe","it","intlDateTimeFormatSupportedLocale","should","equal","arrayToObject","array","reduce","object","locale","choose","locales","defaultLocale","concat","chooseLocale","_","includes","expect","to"],"sources":["../source/locale.test.js"],"sourcesContent":["import chooseLocale, { intlDateTimeFormatSupportedLocale } from './locale.js'\r\n\r\ndescribe('locale', () => {\r\n\tit(`should tell if can use Intl for date formatting`, () => {\r\n\t\tintlDateTimeFormatSupportedLocale('en').should.equal('en')\r\n\t\tintlDateTimeFormatSupportedLocale('en-XX').should.equal('en-XX')\r\n\t\tintlDateTimeFormatSupportedLocale(['en', 'ru']).should.equal('en')\r\n\t})\r\n\r\n\tit(`should choose the most appropriate locale`, () => {\r\n\t\tfunction arrayToObject(array) {\r\n\t\t\treturn array.reduce((object, locale) => {\r\n\t\t\t\tobject[locale] = true\r\n\t\t\t\treturn object\r\n\t\t\t}, {})\r\n\t\t}\r\n\r\n\t\tfunction choose(locale, locales, defaultLocale = 'en') {\r\n\t\t\tif (typeof locale === 'string') {\r\n\t\t\t\tlocale = [locale]\r\n\t\t\t}\r\n\t\t\tlocale = locale.concat(defaultLocale)\r\n\t\t\treturn chooseLocale(locale, _ => locales.includes(_))\r\n\t\t}\r\n\r\n\t\tchoose('ru-RU', ['en', 'ru']).should.equal('ru')\r\n\t\tchoose('en-GB', ['en', 'ru']).should.equal('en')\r\n\t\tchoose('fr-FR', ['en', 'ru']).should.equal('en')\r\n\t\tchoose(['fr-FR', 'de-DE'], ['en', 'ru']).should.equal('en')\r\n\t\tchoose(['fr-FR', 'de-DE'], ['en', 'de']).should.equal('de')\r\n\t\tchoose(['fr-FR', 'de-DE'], ['en', 'de', 'fr']).should.equal('fr')\r\n\t\tchoose('fr-FR', ['en', 'fr-FR']).should.equal('fr-FR')\r\n\r\n\t\texpect(() => choose('fr-FR', ['de', 'ru'])).to.throw(\r\n\t\t\t'No locale data has been registered for any of the locales: fr-FR'\r\n\t\t)\r\n\t})\r\n})"],"mappings":";;;;AAAA;;;;;;AAEAA,QAAQ,CAAC,QAAD,EAAW,YAAM;EACxBC,EAAE,oDAAoD,YAAM;IAC3D,IAAAC,yCAAA,EAAkC,IAAlC,EAAwCC,MAAxC,CAA+CC,KAA/C,CAAqD,IAArD;IACA,IAAAF,yCAAA,EAAkC,OAAlC,EAA2CC,MAA3C,CAAkDC,KAAlD,CAAwD,OAAxD;IACA,IAAAF,yCAAA,EAAkC,CAAC,IAAD,EAAO,IAAP,CAAlC,EAAgDC,MAAhD,CAAuDC,KAAvD,CAA6D,IAA7D;EACA,CAJC,CAAF;EAMAH,EAAE,8CAA8C,YAAM;IACrD,SAASI,aAAT,CAAuBC,KAAvB,EAA8B;MAC7B,OAAOA,KAAK,CAACC,MAAN,CAAa,UAACC,MAAD,EAASC,MAAT,EAAoB;QACvCD,MAAM,CAACC,MAAD,CAAN,GAAiB,IAAjB;QACA,OAAOD,MAAP;MACA,CAHM,EAGJ,EAHI,CAAP;IAIA;;IAED,SAASE,MAAT,CAAgBD,MAAhB,EAAwBE,OAAxB,EAAuD;MAAA,IAAtBC,aAAsB,uEAAN,IAAM;;MACtD,IAAI,OAAOH,MAAP,KAAkB,QAAtB,EAAgC;QAC/BA,MAAM,GAAG,CAACA,MAAD,CAAT;MACA;;MACDA,MAAM,GAAGA,MAAM,CAACI,MAAP,CAAcD,aAAd,CAAT;MACA,OAAO,IAAAE,kBAAA,EAAaL,MAAb,EAAqB,UAAAM,CAAC;QAAA,OAAIJ,OAAO,CAACK,QAAR,CAAiBD,CAAjB,CAAJ;MAAA,CAAtB,CAAP;IACA;;IAEDL,MAAM,CAAC,OAAD,EAAU,CAAC,IAAD,EAAO,IAAP,CAAV,CAAN,CAA8BP,MAA9B,CAAqCC,KAArC,CAA2C,IAA3C;IACAM,MAAM,CAAC,OAAD,EAAU,CAAC,IAAD,EAAO,IAAP,CAAV,CAAN,CAA8BP,MAA9B,CAAqCC,KAArC,CAA2C,IAA3C;IACAM,MAAM,CAAC,OAAD,EAAU,CAAC,IAAD,EAAO,IAAP,CAAV,CAAN,CAA8BP,MAA9B,CAAqCC,KAArC,CAA2C,IAA3C;IACAM,MAAM,CAAC,CAAC,OAAD,EAAU,OAAV,CAAD,EAAqB,CAAC,IAAD,EAAO,IAAP,CAArB,CAAN,CAAyCP,MAAzC,CAAgDC,KAAhD,CAAsD,IAAtD;IACAM,MAAM,CAAC,CAAC,OAAD,EAAU,OAAV,CAAD,EAAqB,CAAC,IAAD,EAAO,IAAP,CAArB,CAAN,CAAyCP,MAAzC,CAAgDC,KAAhD,CAAsD,IAAtD;IACAM,MAAM,CAAC,CAAC,OAAD,EAAU,OAAV,CAAD,EAAqB,CAAC,IAAD,EAAO,IAAP,EAAa,IAAb,CAArB,CAAN,CAA+CP,MAA/C,CAAsDC,KAAtD,CAA4D,IAA5D;IACAM,MAAM,CAAC,OAAD,EAAU,CAAC,IAAD,EAAO,OAAP,CAAV,CAAN,CAAiCP,MAAjC,CAAwCC,KAAxC,CAA8C,OAA9C;IAEAa,MAAM,CAAC;MAAA,OAAMP,MAAM,CAAC,OAAD,EAAU,CAAC,IAAD,EAAO,IAAP,CAAV,CAAZ;IAAA,CAAD,CAAN,CAA4CQ,EAA5C,UACC,kEADD;EAGA,CA3BC,CAAF;AA4BA,CAnCO,CAAR"}
1
+ {"version":3,"file":"locale.test.js","names":["_locale","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","describe","it","intlDateTimeFormatSupportedLocale","should","equal","arrayToObject","array","reduce","object","locale","choose","locales","defaultLocale","arguments","length","undefined","concat","chooseLocale","_","includes","expect","to"],"sources":["../source/locale.test.js"],"sourcesContent":["import chooseLocale, { intlDateTimeFormatSupportedLocale } from './locale.js'\r\n\r\ndescribe('locale', () => {\r\n\tit(`should tell if can use Intl for date formatting`, () => {\r\n\t\tintlDateTimeFormatSupportedLocale('en').should.equal('en')\r\n\t\tintlDateTimeFormatSupportedLocale('en-XX').should.equal('en-XX')\r\n\t\tintlDateTimeFormatSupportedLocale(['en', 'ru']).should.equal('en')\r\n\t})\r\n\r\n\tit(`should choose the most appropriate locale`, () => {\r\n\t\tfunction arrayToObject(array) {\r\n\t\t\treturn array.reduce((object, locale) => {\r\n\t\t\t\tobject[locale] = true\r\n\t\t\t\treturn object\r\n\t\t\t}, {})\r\n\t\t}\r\n\r\n\t\tfunction choose(locale, locales, defaultLocale = 'en') {\r\n\t\t\tif (typeof locale === 'string') {\r\n\t\t\t\tlocale = [locale]\r\n\t\t\t}\r\n\t\t\tlocale = locale.concat(defaultLocale)\r\n\t\t\treturn chooseLocale(locale, _ => locales.includes(_))\r\n\t\t}\r\n\r\n\t\tchoose('ru-RU', ['en', 'ru']).should.equal('ru')\r\n\t\tchoose('en-GB', ['en', 'ru']).should.equal('en')\r\n\t\tchoose('fr-FR', ['en', 'ru']).should.equal('en')\r\n\t\tchoose(['fr-FR', 'de-DE'], ['en', 'ru']).should.equal('en')\r\n\t\tchoose(['fr-FR', 'de-DE'], ['en', 'de']).should.equal('de')\r\n\t\tchoose(['fr-FR', 'de-DE'], ['en', 'de', 'fr']).should.equal('fr')\r\n\t\tchoose('fr-FR', ['en', 'fr-FR']).should.equal('fr-FR')\r\n\r\n\t\texpect(() => choose('fr-FR', ['de', 'ru'])).to.throw(\r\n\t\t\t'No locale data has been registered for any of the locales: fr-FR'\r\n\t\t)\r\n\t})\r\n})"],"mappings":";;;AAAA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA6E,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6B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AE,IAAI,CAAC,CAAC,CAACP,MAAM,CAACC,KAAK,CAAC,IAAI,CAAC;IAC3DM,MAAM,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAACP,MAAM,CAACC,KAAK,CAAC,IAAI,CAAC;IACjEM,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAACP,MAAM,CAACC,KAAK,CAAC,OAAO,CAAC;IAEtDgB,MAAM,CAAC;MAAA,OAAMV,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAAA,EAAC,CAACW,EAAE,SAAM,CACnD,kEACD,CAAC;EACF,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
package/commonjs/round.js CHANGED
@@ -5,25 +5,22 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getDiffRatioToNextRoundedNumber = getDiffRatioToNextRoundedNumber;
7
7
  exports.getRoundFunction = getRoundFunction;
8
-
9
8
  function getRoundFunction(round) {
10
9
  switch (round) {
11
10
  case 'floor':
12
11
  return Math.floor;
13
-
14
12
  default:
15
13
  return Math.round;
16
14
  }
17
- } // For non-negative numbers.
18
-
15
+ }
19
16
 
17
+ // For non-negative numbers.
20
18
  function getDiffRatioToNextRoundedNumber(round) {
21
19
  switch (round) {
22
20
  case 'floor':
23
21
  // Math.floor(x) = x
24
22
  // Math.floor(x + 1) = x + 1
25
23
  return 1;
26
-
27
24
  default:
28
25
  // Math.round(x) = x
29
26
  // Math.round(x + 0.5) = x + 1
@@ -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":";;;;;;;;AAAO,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;;;AACO,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":";;;;;;;AAAO,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;AACO,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":[]}
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  var _units = require("./units.js");
9
-
10
8
  // "factor" is a legacy property.
11
9
  // Developers shouldn't need to use it in their custom steps.
12
10
  // "threshold" is a legacy name of "min".
@@ -38,7 +36,7 @@ var _units = require("./units.js");
38
36
  // a year ago
39
37
  // 2 years ago
40
38
  // …
41
- var _default = [{
39
+ var _default = exports["default"] = [{
42
40
  // This step returns the amount of seconds
43
41
  // by dividing the amount of seconds by `1`.
44
42
  factor: 1,
@@ -129,5 +127,4 @@ var _default = [{
129
127
  // "year" labels are used for formatting the output.
130
128
  unit: 'year'
131
129
  }];
132
- exports["default"] = _default;
133
130
  //# sourceMappingURL=approximate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"approximate.js","names":["factor","unit","threshold","threshold_for_now","minute","granularity","hour","threshold_for_minute","day","week","month","year"],"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;;AAEA;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;eACe,CACd;EACC;EACA;EACAA,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,EAAEI,aALT;EAMI;EACHH,IAAI,EAAE;AAPP,CApBc,EA6Bd;EACC;EACAC,SAAS,EAAE,MAAME,aAFlB;EAGC;EACA;EACA;EACA;EACA;EACA;EACAC,WAAW,EAAE,CATd;EAUC;EACA;EACAL,MAAM,EAAEI,aAZT;EAaC;EACAH,IAAI,EAAE;AAdP,CA7Bc,EA6Cd;EACC;EACAC,SAAS,EAAE,OAAOE,aAFnB;EAGC;EACA;EACAJ,MAAM,EAAE,MAAMM,WALf;EAMC;EACA;EACAL,IAAI,EAAE;AARP,CA7Cc,EAuDd;EACC;EACAC,SAAS,EAAE,OAAOE,aAFnB;EAGCG,oBAAoB,EAAE,OAAOH,aAH9B;EAIC;EACA;EACAJ,MAAM,EAAEM,WANT;EAOC;EACAL,IAAI,EAAE;AARP,CAvDc,EAiEd;EACC;EACAC,SAAS,EAAG,OAAO,EAAR,GAAcM,UAF1B;EAGC;EACA;EACAR,MAAM,EAAEQ,UALT;EAMC;EACAP,IAAI,EAAE;AAPP,CAjEc,EA0Ed;EACC;EACAC,SAAS,EAAE,MAAMM,UAFlB;EAGC;EACA;EACAR,MAAM,EAAES,WALT;EAMC;EACAR,IAAI,EAAE;AAPP,CA1Ec,EAmFd;EACC;EACAC,SAAS,EAAE,MAAMO,WAFlB;EAGC;EACA;EACAT,MAAM,EAAEU,YALT;EAMC;EACAT,IAAI,EAAE;AAPP,CAnFc,EA4Fd;EACC;EACAC,SAAS,EAAE,OAAOQ,YAFnB;EAGC;EACA;EACAV,MAAM,EAAEW,WALT;EAMC;EACAV,IAAI,EAAE;AAPP,CA5Fc,C"}
1
+ {"version":3,"file":"approximate.js","names":["_units","require","_default","exports","factor","unit","threshold","threshold_for_now","minute","granularity","hour","threshold_for_minute","day","week","month","year"],"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,IAAAA,MAAA,GAAAC,OAAA;AAEA;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;AAAA,IAAAC,QAAA,GAAAC,OAAA,cACe,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,EAAEI,aAAM;EACX;EACHH,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAE,GAAG,GAAGE,aAAM;EACvB;EACA;EACA;EACA;EACA;EACA;EACAC,WAAW,EAAE,CAAC;EACd;EACA;EACAL,MAAM,EAAEI,aAAM;EACd;EACAH,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAE,IAAI,GAAGE,aAAM;EACxB;EACA;EACAJ,MAAM,EAAE,GAAG,GAAGM,WAAI;EAClB;EACA;EACAL,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAE,IAAI,GAAGE,aAAM;EACxBG,oBAAoB,EAAE,IAAI,GAAGH,aAAM;EACnC;EACA;EACAJ,MAAM,EAAEM,WAAI;EACZ;EACAL,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAG,IAAI,GAAG,EAAE,GAAIM,UAAG;EAC5B;EACA;EACAR,MAAM,EAAEQ,UAAG;EACX;EACAP,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAE,GAAG,GAAGM,UAAG;EACpB;EACA;EACAR,MAAM,EAAES,WAAI;EACZ;EACAR,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAE,GAAG,GAAGO,WAAI;EACrB;EACA;EACAT,MAAM,EAAEU,YAAK;EACb;EACAT,IAAI,EAAE;AACP,CAAC,EACD;EACC;EACAC,SAAS,EAAE,IAAI,GAAGQ,YAAK;EACvB;EACA;EACAV,MAAM,EAAEW,WAAI;EACZ;EACAV,IAAI,EAAE;AACP,CAAC,CACD","ignoreList":[]}
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _getStep = _interopRequireDefault(require("./getStep.js"));
4
-
5
4
  var _approximate = _interopRequireDefault(require("./approximate.js"));
6
-
7
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8
-
5
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
6
  describe('steps/approximate', function () {
10
7
  it('should get step correctly', function () {
11
8
  var getStepFor = function getStepFor(secondsPassed) {
@@ -14,7 +11,6 @@ describe('steps/approximate', function () {
14
11
  units: ['now', 'second', 'minute', 'hour', 'day', 'week', 'month', 'year']
15
12
  });
16
13
  };
17
-
18
14
  expect(getStepFor(0).unit).to.equal('now');
19
15
  expect(getStepFor(1).unit).to.equal('now');
20
16
  expect(getStepFor(45).unit).to.equal('now');
@@ -40,7 +36,6 @@ describe('steps/approximate', function () {
40
36
  units: ['second', 'minute', 'hour', 'day', 'week', 'month', 'year']
41
37
  });
42
38
  };
43
-
44
39
  expect(getStepFor(0)).to.be.undefined;
45
40
  expect(getStepFor(1).unit).to.equal('second');
46
41
  expect(getStepFor(45).unit).to.equal('second');
@@ -1 +1 @@
1
- {"version":3,"file":"approximate.test.js","names":["describe","it","getStepFor","secondsPassed","getStep","steps","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;;AACA;;;;AAEAA,QAAQ,CAAC,mBAAD,EAAsB,YAAM;EACnCC,EAAE,CAAC,2BAAD,EAA8B,YAAM;IACrC,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,aAAD;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EAEN,QAFM,EAGN,MAHM,EAIN,KAJM,EAKN,MALM,EAMN,OANM,EAON,MAPM;MAF4D,CAA9B,CAAnB;IAAA,CAAnB;;IAaAC,MAAM,CAACN,UAAU,CAAC,CAAD,CAAX,CAAN,CAAsBQ,EAAtB,CAAyBI,EAAzB,CAA4BC,SAA5B;IACAP,MAAM,CAACN,UAAU,CAAC,CAAD,CAAV,CAAcO,IAAf,CAAN,CAA2BC,EAA3B,CAA8BC,KAA9B,CAAoC,QAApC;IACAH,MAAM,CAACN,UAAU,CAAC,EAAD,CAAV,CAAeO,IAAhB,CAAN,CAA4BC,EAA5B,CAA+BC,KAA/B,CAAqC,QAArC;IACAH,MAAM,CAACN,UAAU,CAAC,EAAD,CAAV,CAAeO,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","_interopRequireDefault","require","_approximate","e","__esModule","describe","it","getStepFor","secondsPassed","getStep","steps","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,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAEpC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,uBAAK,EAAEF,aAAa,EAAE;QACnEG,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,CAACN,UAAU,CAAC,CAAC,CAAC,CAAC,CAACQ,EAAE,CAACI,EAAE,CAACC,SAAS;IACrCP,MAAM,CAACN,UAAU,CAAC,CAAC,CAAC,CAACO,IAAI,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,QAAQ,CAAC;IAC7CH,MAAM,CAACN,UAAU,CAAC,EAAE,CAAC,CAACO,IAAI,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,QAAQ,CAAC;IAC9CH,MAAM,CAACN,UAAU,CAAC,EAAE,CAAC,CAACO,IAAI,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,QAAQ,CAAC;EAC/C,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = getStep;
7
-
8
7
  var _getStepDenominator = _interopRequireDefault(require("./getStepDenominator.js"));
9
-
10
8
  var _getStepMinTime = _interopRequireDefault(require("./getStepMinTime.js"));
11
-
12
9
  var _round = require("../round.js");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
-
16
- 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; }
17
-
18
- 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; }
19
-
20
- 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; }
21
-
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
+ 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); }
12
+ 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; }
13
+ 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; }
14
+ 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; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
16
+ 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); }
22
17
  /**
23
18
  * Finds an appropriate `step` of `steps` for the time interval (in seconds).
24
19
  *
@@ -43,71 +38,66 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
43
38
  */
44
39
  function getStep(steps, secondsPassed, _ref) {
45
40
  var now = _ref.now,
46
- future = _ref.future,
47
- round = _ref.round,
48
- units = _ref.units,
49
- getNextStep = _ref.getNextStep;
41
+ future = _ref.future,
42
+ round = _ref.round,
43
+ units = _ref.units,
44
+ getNextStep = _ref.getNextStep;
50
45
  // Ignore steps having not-supported time units in `formatAs`.
51
46
  steps = filterStepsByUnits(steps, units);
52
-
53
47
  var step = _getStep(steps, secondsPassed, {
54
48
  now: now,
55
49
  future: future,
56
50
  round: round
57
51
  });
58
-
59
52
  if (getNextStep) {
60
53
  if (step) {
61
54
  var prevStep = steps[steps.indexOf(step) - 1];
62
55
  var nextStep = steps[steps.indexOf(step) + 1];
63
56
  return [prevStep, step, nextStep];
64
57
  }
65
-
66
58
  return [undefined, undefined, steps[0]];
67
59
  }
68
-
69
60
  return step;
70
61
  }
71
-
72
62
  function _getStep(steps, secondsPassed, _ref2) {
73
63
  var now = _ref2.now,
74
- future = _ref2.future,
75
- round = _ref2.round;
76
-
64
+ future = _ref2.future,
65
+ round = _ref2.round;
77
66
  // If no steps fit the conditions then return nothing.
78
67
  if (steps.length === 0) {
79
68
  return;
80
- } // Find the most appropriate step.
81
-
69
+ }
82
70
 
71
+ // Find the most appropriate step.
83
72
  var i = getStepIndex(steps, secondsPassed, {
84
73
  now: now,
85
74
  future: future || secondsPassed < 0,
86
75
  round: round
87
- }); // If no step is applicable the return nothing.
76
+ });
88
77
 
78
+ // If no step is applicable the return nothing.
89
79
  if (i === -1) {
90
80
  return;
91
81
  }
82
+ var step = steps[i];
92
83
 
93
- var step = steps[i]; // Apply granularity to the time amount
84
+ // Apply granularity to the time amount
94
85
  // (and fall back to the previous step
95
86
  // if the first level of granularity
96
87
  // isn't met by this amount)
97
-
98
88
  if (step.granularity) {
99
89
  // Recalculate the amount of seconds passed based on `granularity`.
100
- var secondsPassedGranular = (0, _round.getRoundFunction)(round)(Math.abs(secondsPassed) / (0, _getStepDenominator["default"])(step) / step.granularity) * step.granularity; // If the granularity for this step is too high,
90
+ var secondsPassedGranular = (0, _round.getRoundFunction)(round)(Math.abs(secondsPassed) / (0, _getStepDenominator["default"])(step) / step.granularity) * step.granularity;
91
+ // If the granularity for this step is too high,
101
92
  // then fall back to the previous step.
102
93
  // (if there is any previous step)
103
-
104
94
  if (secondsPassedGranular === 0 && i > 0) {
105
95
  return steps[i - 1];
106
96
  }
107
97
  }
108
-
109
98
  return step;
110
99
  }
100
+
111
101
  /**
112
102
  * Iterates through steps until it finds the maximum one satisfying the `minTime` threshold.
113
103
  * @param {Object} steps - Steps.
@@ -117,56 +107,49 @@ function _getStep(steps, secondsPassed, _ref2) {
117
107
  * @param {number} [i] - Gradation step currently being tested.
118
108
  * @return {number} Gradation step index.
119
109
  */
120
-
121
-
122
110
  function getStepIndex(steps, secondsPassed, options) {
123
111
  var i = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
124
112
  var minTime = (0, _getStepMinTime["default"])(steps[i], _objectSpread({
125
113
  prevStep: steps[i - 1],
126
114
  timestamp: options.now - secondsPassed * 1000
127
- }, options)); // If `minTime` isn't defined or deduceable for this step, then stop.
128
-
115
+ }, options));
116
+ // If `minTime` isn't defined or deduceable for this step, then stop.
129
117
  if (minTime === undefined) {
130
118
  return i - 1;
131
- } // If the `minTime` threshold for moving from previous step
119
+ }
120
+ // If the `minTime` threshold for moving from previous step
132
121
  // to this step is too high then return the previous step.
133
-
134
-
135
122
  if (Math.abs(secondsPassed) < minTime) {
136
123
  return i - 1;
137
- } // If it's the last step then return it.
138
-
139
-
124
+ }
125
+ // If it's the last step then return it.
140
126
  if (i === steps.length - 1) {
141
127
  return i;
142
- } // Move to the next step.
143
-
144
-
128
+ }
129
+ // Move to the next step.
145
130
  return getStepIndex(steps, secondsPassed, options, i + 1);
146
131
  }
132
+
147
133
  /**
148
134
  * Leaves only allowed steps.
149
135
  * @param {Object[]} steps
150
136
  * @param {string[]} units - Allowed time units.
151
137
  * @return {Object[]}
152
138
  */
153
-
154
-
155
139
  function filterStepsByUnits(steps, units) {
156
140
  return steps.filter(function (_ref3) {
157
141
  var unit = _ref3.unit,
158
- formatAs = _ref3.formatAs;
142
+ formatAs = _ref3.formatAs;
159
143
  // "unit" is now called "formatAs".
160
- unit = unit || formatAs; // If this step has a `unit` defined
144
+ unit = unit || formatAs;
145
+ // If this step has a `unit` defined
161
146
  // then this `unit` must be in the list of allowed `units`.
162
-
163
147
  if (unit) {
164
148
  return units.indexOf(unit) >= 0;
165
- } // A step is not required to specify a `unit`:
149
+ }
150
+ // A step is not required to specify a `unit`:
166
151
  // alternatively, it could specify `format()`.
167
152
  // (see "twitter" style for an example)
168
-
169
-
170
153
  return true;
171
154
  });
172
155
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getStep.js","names":["getStep","steps","secondsPassed","now","future","round","units","getNextStep","filterStepsByUnits","step","_getStep","prevStep","indexOf","nextStep","undefined","length","i","getStepIndex","granularity","secondsPassedGranular","getRoundFunction","Math","abs","getStepDenominator","options","minTime","getStepMinTime","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\t\t// (see \"twitter\" style for an example)\r\n\t\treturn true\r\n\t})\r\n}"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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OAAOT,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,EAAuBsB,OAAvB,EAAgCR,CAAC,GAAG,CAApC,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASR,kBAAT,CAA4BP,KAA5B,EAAmCK,KAAnC,EAA0C;EACzC,OAAOL,KAAK,CAAC2B,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,OAAOvB,KAAK,CAACM,OAAN,CAAciB,IAAd,KAAuB,CAA9B;IACA,CAP0C,CAQ3C;IACA;IACA;;;IACA,OAAO,IAAP;EACA,CAZM,CAAP;AAaA"}
1
+ {"version":3,"file":"getStep.js","names":["_getStepDenominator","_interopRequireDefault","require","_getStepMinTime","_round","e","__esModule","_typeof","o","Symbol","iterator","constructor","prototype","ownKeys","r","t","Object","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","toPrimitive","call","TypeError","String","Number","getStep","steps","secondsPassed","_ref","now","future","round","units","getNextStep","filterStepsByUnits","step","_getStep","prevStep","indexOf","nextStep","undefined","_ref2","getStepIndex","granularity","secondsPassedGranular","getRoundFunction","Math","abs","getStepDenominator","options","minTime","getStepMinTime","timestamp","_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,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAA8C,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAAA,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;AAAA,SAAAK,QAAAR,CAAA,EAAAS,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAZ,CAAA,OAAAW,MAAA,CAAAE,qBAAA,QAAAV,CAAA,GAAAQ,MAAA,CAAAE,qBAAA,CAAAb,CAAA,GAAAS,CAAA,KAAAN,CAAA,GAAAA,CAAA,CAAAW,MAAA,WAAAL,CAAA,WAAAE,MAAA,CAAAI,wBAAA,CAAAf,CAAA,EAAAS,CAAA,EAAAO,UAAA,OAAAN,CAAA,CAAAO,IAAA,CAAAC,KAAA,CAAAR,CAAA,EAAAP,CAAA,YAAAO,CAAA;AAAA,SAAAS,cAAAnB,CAAA,aAAAS,CAAA,MAAAA,CAAA,GAAAW,SA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CAACpB,GAAG,GAAGF,aAAa,GAAG;EAAI,GAC1CsB,OAAO,CACV,CAAC;EACF;EACA,IAAIC,OAAO,KAAKV,SAAS,EAAE;IAC1B,OAAOtB,CAAC,GAAG,CAAC;EACb;EACA;EACA;EACA,IAAI4B,IAAI,CAACC,GAAG,CAACpB,aAAa,CAAC,GAAGuB,OAAO,EAAE;IACtC,OAAOhC,CAAC,GAAG,CAAC;EACb;EACA;EACA,IAAIA,CAAC,KAAKQ,KAAK,CAAClB,MAAM,GAAG,CAAC,EAAE;IAC3B,OAAOU,CAAC;EACT;EACA;EACA,OAAOwB,YAAY,CAAChB,KAAK,EAAEC,aAAa,EAAEsB,OAAO,EAAE/B,CAAC,GAAG,CAAC,CAAC;AAC1D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASgB,kBAAkBA,CAACR,KAAK,EAAEM,KAAK,EAAE;EACzC,OAAON,KAAK,CAACzB,MAAM,CAAC,UAAAoD,KAAA,EAAwB;IAAA,IAArBC,IAAI,GAAAD,KAAA,CAAJC,IAAI;MAAEC,QAAQ,GAAAF,KAAA,CAARE,QAAQ;IACpC;IACAD,IAAI,GAAGA,IAAI,IAAIC,QAAQ;IACvB;IACA;IACA,IAAID,IAAI,EAAE;MACT,OAAOtB,KAAK,CAACM,OAAO,CAACgB,IAAI,CAAC,IAAI,CAAC;IAChC;IACA;IACA;IACA;IACA,OAAO,IAAI;EACZ,CAAC,CAAC;AACH","ignoreList":[]}
@@ -1,17 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _getStep = _interopRequireDefault(require("./getStep.js"));
4
-
5
4
  var _round = _interopRequireDefault(require("./round.js"));
6
-
7
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8
-
5
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
6
  describe('getStep', function () {
10
7
  it('should return nothing if no time units are supported', function () {
11
8
  expect((0, _getStep["default"])(_round["default"], 0, {
12
9
  units: ['femtosecond']
13
10
  })).to.be.undefined;
14
- }); // it('should throw if a non-first step does not have a `minTime` or `test()`', () => {
11
+ });
12
+
13
+ // it('should throw if a non-first step does not have a `minTime` or `test()`', () => {
15
14
  // expect(getStep([{ unit: 'second' }], 2, { units: ['second'] })).to.deep.equal({ unit: 'second' })
16
15
  //
17
16
  // expect(() => {
@@ -23,13 +22,14 @@ describe('getStep', function () {
23
22
 
24
23
  it('should fall back to previous step if granularity is too high for the next step', function () {
25
24
  var steps = _round["default"].slice();
26
-
27
25
  steps[1].formatAs.should.equal('second');
28
26
  steps[1].granularity = 3;
29
27
  (0, _getStep["default"])(steps, 1.49, {
30
28
  now: 0,
31
29
  units: ['now', 'second']
32
- }).formatAs.should.equal('now'); // And if there's no previous step, then use the current one.
30
+ }).formatAs.should.equal('now');
31
+
32
+ // And if there's no previous step, then use the current one.
33
33
 
34
34
  var firstStep = steps[0];
35
35
  steps.splice(0, 1);
@@ -1 +1 @@
1
- {"version":3,"file":"getStep.test.js","names":["describe","it","expect","getStep","round","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;;AACA;;;;AAEAA,QAAQ,CAAC,SAAD,EAAY,YAAM;EACzBC,EAAE,CAAC,sDAAD,EAAyD,YAAM;IAChEC,MAAM,CAAC,IAAAC,mBAAA,EAAQC,iBAAR,EAAe,CAAf,EAAkB;MAAEC,KAAK,EAAE,CAAC,aAAD;IAAT,CAAlB,CAAD,CAAN,CAAsDC,EAAtD,CAAyDC,EAAzD,CAA4DC,SAA5D;EACA,CAFC,CAAF,CADyB,CAKzB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEAP,EAAE,CAAC,gFAAD,EAAmF,YAAM;IAC1F,IAAMQ,KAAK,GAAGL,iBAAA,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B,CATM,EAULc,IAVI,CAAN,CAUQb,EAVR,CAUWO,KAVX,CAUiB,QAVjB;EAWA,CAxBC,CAAF;EA0BAZ,EAAE,CAAC,qGAAD,EAAwG,YAAM;IAC/GC,MAAM,CAAC,IAAAC,mBAAA,EACN,CACC;MAAEQ,QAAQ,EAAE;IAAZ,CADD,EAEC;MAAEA,QAAQ,EAAE;IAAZ,CAFD,CADM,EAKN,EALM,EAMN;MAAEI,GAAG,EAAE,CAAP;MAAUV,KAAK,EAAE,CAAC,QAAD,EAAW,uBAAX;IAAjB,CANM,EAOLM,QAPI,CAAN,CAOYL,EAPZ,CAOeO,KAPf,CAOqB,QAPrB;EAQA,CATC,CAAF;AAUA,CAnHO,CAAR"}
1
+ {"version":3,"file":"getStep.test.js","names":["_getStep","_interopRequireDefault","require","_round","e","__esModule","describe","it","expect","getStep","round","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,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8B,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAE9BE,QAAQ,CAAC,SAAS,EAAE,YAAM;EACzBC,EAAE,CAAC,sDAAsD,EAAE,YAAM;IAChEC,MAAM,CAAC,IAAAC,mBAAO,EAACC,iBAAK,EAAE,CAAC,EAAE;MAAEC,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;;EAEAP,EAAE,CAAC,gFAAgF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P,CAAC,CACD,EACD,EAAE,EACF;MAAEJ,GAAG,EAAE,CAAC;MAAEV,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ;IAAE,CACvC,CAAC,CAACc,IAAI,CAAC,CAACb,EAAE,CAACO,KAAK,CAAC,QAAQ,CAAC;EAC3B,CAAC,CAAC;EAEFZ,EAAE,CAAC,qGAAqG,EAAE,YAAM;IAC/GC,MAAM,CAAC,IAAAC,mBAAO,EACb,CACC;MAAEQ,QAAQ,EAAE;IAAS,CAAC,EACtB;MAAEA,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":[]}
@@ -4,16 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = getStepDenominator;
7
-
8
7
  var _units = require("./units.js");
9
-
10
8
  function getStepDenominator(step) {
11
9
  // `factor` is a legacy property.
12
10
  if (step.factor !== undefined) {
13
11
  return step.factor;
14
- } // "unit" is now called "formatAs".
15
-
16
-
12
+ }
13
+ // "unit" is now called "formatAs".
17
14
  return (0, _units.getSecondsInUnit)(step.unit || step.formatAs) || 1;
18
15
  }
19
16
  //# sourceMappingURL=getStepDenominator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getStepDenominator.js","names":["getStepDenominator","step","factor","undefined","getSecondsInUnit","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;;AAEe,SAASA,kBAAT,CAA4BC,IAA5B,EAAkC;EAChD;EACA,IAAIA,IAAI,CAACC,MAAL,KAAgBC,SAApB,EAA+B;IAC9B,OAAOF,IAAI,CAACC,MAAZ;EACA,CAJ+C,CAKhD;;;EACA,OAAO,IAAAE,uBAAA,EAAiBH,IAAI,CAACI,IAAL,IAAaJ,IAAI,CAACK,QAAnC,KAAgD,CAAvD;AACA"}
1
+ {"version":3,"file":"getStepDenominator.js","names":["_units","require","getStepDenominator","step","factor","undefined","getSecondsInUnit","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,IAAAA,MAAA,GAAAC,OAAA;AAEe,SAASC,kBAAkBA,CAACC,IAAI,EAAE;EAChD;EACA,IAAIA,IAAI,CAACC,MAAM,KAAKC,SAAS,EAAE;IAC9B,OAAOF,IAAI,CAACC,MAAM;EACnB;EACA;EACA,OAAO,IAAAE,uBAAgB,EAACH,IAAI,CAACI,IAAI,IAAIJ,IAAI,CAACK,QAAQ,CAAC,IAAI,CAAC;AACzD","ignoreList":[]}
@@ -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":[]}