javascript-time-ago 2.5.11 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (452) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/README.md +410 -272
  3. package/bundle/javascript-time-ago.js +1 -1
  4. package/bundle/javascript-time-ago.js.map +1 -1
  5. package/bundle/javascript-time-ago.min.js +1 -1
  6. package/bundle/javascript-time-ago.min.js.map +1 -1
  7. package/commonjs/FullDateFormatter.js +72 -0
  8. package/commonjs/FullDateFormatter.js.map +1 -0
  9. package/commonjs/FullDateFormatter.test.js +26 -0
  10. package/commonjs/FullDateFormatter.test.js.map +1 -0
  11. package/commonjs/LocaleDataStore.js +2 -5
  12. package/commonjs/LocaleDataStore.js.map +1 -1
  13. package/commonjs/PropTypes.js +12 -12
  14. package/commonjs/PropTypes.js.map +1 -1
  15. package/commonjs/TimeAgo.js +300 -253
  16. package/commonjs/TimeAgo.js.map +1 -1
  17. package/commonjs/TimeAgo.test.js +214 -135
  18. package/commonjs/TimeAgo.test.js.map +1 -1
  19. package/commonjs/cache.js +7 -25
  20. package/commonjs/cache.js.map +1 -1
  21. package/commonjs/cache.test.js +1 -3
  22. package/commonjs/cache.test.js.map +1 -1
  23. package/commonjs/isStyleObject.js +9 -9
  24. package/commonjs/isStyleObject.js.map +1 -1
  25. package/commonjs/isStyleObject.test.js +1 -3
  26. package/commonjs/isStyleObject.test.js.map +1 -1
  27. package/commonjs/locale.js +6 -19
  28. package/commonjs/locale.js.map +1 -1
  29. package/commonjs/locale.test.js +2 -11
  30. package/commonjs/locale.test.js.map +1 -1
  31. package/commonjs/round.js +2 -5
  32. package/commonjs/round.js.map +1 -1
  33. package/commonjs/steps/approximate.js +1 -4
  34. package/commonjs/steps/approximate.js.map +1 -1
  35. package/commonjs/steps/approximate.test.js +1 -6
  36. package/commonjs/steps/approximate.test.js.map +1 -1
  37. package/commonjs/steps/getStep.js +36 -53
  38. package/commonjs/steps/getStep.js.map +1 -1
  39. package/commonjs/steps/getStep.test.js +7 -7
  40. package/commonjs/steps/getStep.test.js.map +1 -1
  41. package/commonjs/steps/getStepDenominator.js +2 -5
  42. package/commonjs/steps/getStepDenominator.js.map +1 -1
  43. package/commonjs/steps/getStepDenominator.test.js +1 -3
  44. package/commonjs/steps/getStepDenominator.test.js.map +1 -1
  45. package/commonjs/steps/getStepMinTime.js +31 -39
  46. package/commonjs/steps/getStepMinTime.js.map +1 -1
  47. package/commonjs/steps/getStepMinTime.test.js +1 -3
  48. package/commonjs/steps/getStepMinTime.test.js.map +1 -1
  49. package/commonjs/steps/getTimeToNextUpdate.js +27 -41
  50. package/commonjs/steps/getTimeToNextUpdate.js.map +1 -1
  51. package/commonjs/steps/getTimeToNextUpdate.test.js +29 -25
  52. package/commonjs/steps/getTimeToNextUpdate.test.js.map +1 -1
  53. package/commonjs/steps/getTimeToNextUpdateForUnit.js +3 -12
  54. package/commonjs/steps/getTimeToNextUpdateForUnit.js.map +1 -1
  55. package/commonjs/steps/getTimeToNextUpdateForUnit.test.js +1 -7
  56. package/commonjs/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
  57. package/commonjs/steps/helpers.js +1 -2
  58. package/commonjs/steps/helpers.js.map +1 -1
  59. package/commonjs/steps/helpers.test.js +0 -1
  60. package/commonjs/steps/helpers.test.js.map +1 -1
  61. package/commonjs/steps/index.js +1 -6
  62. package/commonjs/steps/index.js.map +1 -1
  63. package/commonjs/steps/renameLegacyProperties.js +6 -14
  64. package/commonjs/steps/renameLegacyProperties.js.map +1 -1
  65. package/commonjs/steps/renameLegacyProperties.test.js +1 -3
  66. package/commonjs/steps/renameLegacyProperties.test.js.map +1 -1
  67. package/commonjs/steps/round.js +1 -2
  68. package/commonjs/steps/round.js.map +1 -1
  69. package/commonjs/steps/round.test.js +1 -7
  70. package/commonjs/steps/round.test.js.map +1 -1
  71. package/commonjs/steps/units.js +10 -21
  72. package/commonjs/steps/units.js.map +1 -1
  73. package/commonjs/style/approximate.js +2 -6
  74. package/commonjs/style/approximate.js.map +1 -1
  75. package/commonjs/style/approximateTime.js +2 -6
  76. package/commonjs/style/approximateTime.js.map +1 -1
  77. package/commonjs/style/approximateTime.test.js +116 -75
  78. package/commonjs/style/approximateTime.test.js.map +1 -1
  79. package/commonjs/style/getStyleByName.js +3 -29
  80. package/commonjs/style/getStyleByName.js.map +1 -1
  81. package/commonjs/style/mini.js +9 -6
  82. package/commonjs/style/mini.js.map +1 -1
  83. package/commonjs/style/mini.test.js +15 -25
  84. package/commonjs/style/mini.test.js.map +1 -1
  85. package/commonjs/style/miniMinute.js +8 -13
  86. package/commonjs/style/miniMinute.js.map +1 -1
  87. package/commonjs/style/miniMinute.test.js +11 -17
  88. package/commonjs/style/miniMinute.test.js.map +1 -1
  89. package/commonjs/style/miniMinuteNow.js +8 -13
  90. package/commonjs/style/miniMinuteNow.js.map +1 -1
  91. package/commonjs/style/miniMinuteNow.test.js +11 -17
  92. package/commonjs/style/miniMinuteNow.test.js.map +1 -1
  93. package/commonjs/style/miniNow.js +8 -13
  94. package/commonjs/style/miniNow.js.map +1 -1
  95. package/commonjs/style/miniNow.test.js +11 -17
  96. package/commonjs/style/miniNow.test.js.map +1 -1
  97. package/commonjs/style/renameLegacyProperties.js +7 -13
  98. package/commonjs/style/renameLegacyProperties.js.map +1 -1
  99. package/commonjs/style/renameLegacyProperties.test.js +1 -4
  100. package/commonjs/style/renameLegacyProperties.test.js.map +1 -1
  101. package/commonjs/style/round.js +2 -6
  102. package/commonjs/style/round.js.map +1 -1
  103. package/commonjs/style/round.test.js +51 -67
  104. package/commonjs/style/round.test.js.map +1 -1
  105. package/commonjs/style/roundMinute.js +8 -13
  106. package/commonjs/style/roundMinute.js.map +1 -1
  107. package/commonjs/style/roundMinute.test.js +20 -27
  108. package/commonjs/style/roundMinute.test.js.map +1 -1
  109. package/commonjs/style/twitter.js +34 -39
  110. package/commonjs/style/twitter.js.map +1 -1
  111. package/commonjs/style/twitter.test.js +54 -57
  112. package/commonjs/style/twitter.test.js.map +1 -1
  113. package/commonjs/style/twitterFirstMinute.js +10 -15
  114. package/commonjs/style/twitterFirstMinute.js.map +1 -1
  115. package/commonjs/style/twitterFirstMinute.test.js +16 -23
  116. package/commonjs/style/twitterFirstMinute.test.js.map +1 -1
  117. package/commonjs/style/twitterMinute.js +8 -13
  118. package/commonjs/style/twitterMinute.js.map +1 -1
  119. package/commonjs/style/twitterMinute.test.js +20 -25
  120. package/commonjs/style/twitterMinute.test.js.map +1 -1
  121. package/commonjs/style/twitterMinuteNow.js +8 -13
  122. package/commonjs/style/twitterMinuteNow.js.map +1 -1
  123. package/commonjs/style/twitterMinuteNow.test.js +20 -25
  124. package/commonjs/style/twitterMinuteNow.test.js.map +1 -1
  125. package/commonjs/style/twitterNow.js +8 -13
  126. package/commonjs/style/twitterNow.js.map +1 -1
  127. package/commonjs/style/twitterNow.test.js +18 -24
  128. package/commonjs/style/twitterNow.test.js.map +1 -1
  129. package/full-date-formatter/index.cjs +4 -0
  130. package/full-date-formatter/index.cjs.js +9 -0
  131. package/full-date-formatter/index.d.ts +6 -0
  132. package/full-date-formatter/index.js +1 -0
  133. package/full-date-formatter/package.json +15 -0
  134. package/index.cjs +1 -1
  135. package/index.cjs.js +2 -2
  136. package/index.d.ts +14 -4
  137. package/index.js +3 -1
  138. package/load-all-locales/index.cjs +32 -0
  139. package/load-all-locales/index.cjs.js +32 -0
  140. package/load-all-locales/index.js +64 -0
  141. package/locale/ak/package.json +16 -0
  142. package/locale/ak.json +267 -0
  143. package/locale/ak.json.d.ts +4 -0
  144. package/locale/ak.json.js +267 -0
  145. package/locale/bal-Latn/package.json +16 -0
  146. package/locale/bal-Latn.json +240 -0
  147. package/locale/bal-Latn.json.d.ts +4 -0
  148. package/locale/bal-Latn.json.js +240 -0
  149. package/locale/be-tarask/package.json +16 -0
  150. package/locale/be-tarask.json +259 -0
  151. package/locale/be-tarask.json.d.ts +4 -0
  152. package/locale/be-tarask.json.js +259 -0
  153. package/locale/blo/package.json +16 -0
  154. package/locale/blo.json +159 -0
  155. package/locale/blo.json.d.ts +4 -0
  156. package/locale/blo.json.js +159 -0
  157. package/locale/bn.json +5 -2
  158. package/locale/bn.json.js +5 -2
  159. package/locale/bs.json +8 -2
  160. package/locale/bs.json.js +8 -2
  161. package/locale/ccp.json +2 -8
  162. package/locale/ccp.json.js +2 -8
  163. package/locale/csw/package.json +16 -0
  164. package/locale/csw.json +180 -0
  165. package/locale/csw.json.d.ts +4 -0
  166. package/locale/csw.json.js +180 -0
  167. package/locale/cy.json +6 -12
  168. package/locale/cy.json.js +6 -12
  169. package/locale/doi/package.json +16 -0
  170. package/locale/doi.json +159 -0
  171. package/locale/doi.json.d.ts +4 -0
  172. package/locale/doi.json.js +159 -0
  173. package/locale/en-AU.json +12 -12
  174. package/locale/en-AU.json.js +12 -12
  175. package/locale/en-CZ/package.json +16 -0
  176. package/locale/en-CZ.json +219 -0
  177. package/locale/en-CZ.json.d.ts +4 -0
  178. package/locale/en-CZ.json.js +219 -0
  179. package/locale/en-ES/package.json +16 -0
  180. package/locale/en-ES.json +219 -0
  181. package/locale/en-ES.json.d.ts +4 -0
  182. package/locale/en-ES.json.js +219 -0
  183. package/locale/en-FR/package.json +16 -0
  184. package/locale/en-FR.json +219 -0
  185. package/locale/en-FR.json.d.ts +4 -0
  186. package/locale/en-FR.json.js +219 -0
  187. package/locale/en-GS/package.json +16 -0
  188. package/locale/en-GS.json +219 -0
  189. package/locale/en-GS.json.d.ts +4 -0
  190. package/locale/en-GS.json.js +219 -0
  191. package/locale/en-HU/package.json +16 -0
  192. package/locale/en-HU.json +219 -0
  193. package/locale/en-HU.json.d.ts +4 -0
  194. package/locale/en-HU.json.js +219 -0
  195. package/locale/en-ID/package.json +16 -0
  196. package/locale/en-ID.json +219 -0
  197. package/locale/en-ID.json.d.ts +4 -0
  198. package/locale/en-ID.json.js +219 -0
  199. package/locale/en-IT/package.json +16 -0
  200. package/locale/en-IT.json +219 -0
  201. package/locale/en-IT.json.d.ts +4 -0
  202. package/locale/en-IT.json.js +219 -0
  203. package/locale/en-NO/package.json +16 -0
  204. package/locale/en-NO.json +219 -0
  205. package/locale/en-NO.json.d.ts +4 -0
  206. package/locale/en-NO.json.js +219 -0
  207. package/locale/en-PL/package.json +16 -0
  208. package/locale/en-PL.json +219 -0
  209. package/locale/en-PL.json.d.ts +4 -0
  210. package/locale/en-PL.json.js +219 -0
  211. package/locale/en-PT/package.json +16 -0
  212. package/locale/en-PT.json +219 -0
  213. package/locale/en-PT.json.d.ts +4 -0
  214. package/locale/en-PT.json.js +219 -0
  215. package/locale/en-RO/package.json +16 -0
  216. package/locale/en-RO.json +219 -0
  217. package/locale/en-RO.json.d.ts +4 -0
  218. package/locale/en-RO.json.js +219 -0
  219. package/locale/en-SK/package.json +16 -0
  220. package/locale/en-SK.json +219 -0
  221. package/locale/en-SK.json.d.ts +4 -0
  222. package/locale/en-SK.json.js +219 -0
  223. package/locale/es-MX.json +12 -9
  224. package/locale/es-MX.json.js +12 -9
  225. package/locale/es-SV.json +2 -2
  226. package/locale/es-SV.json.js +2 -2
  227. package/locale/eu.json +24 -24
  228. package/locale/eu.json.js +24 -24
  229. package/locale/ha.json +119 -65
  230. package/locale/ha.json.js +119 -65
  231. package/locale/he.json +0 -6
  232. package/locale/he.json.js +0 -6
  233. package/locale/hi-Latn.json +2 -2
  234. package/locale/hi-Latn.json.js +2 -2
  235. package/locale/ht/package.json +16 -0
  236. package/locale/ht.json +207 -0
  237. package/locale/ht.json.d.ts +4 -0
  238. package/locale/ht.json.js +207 -0
  239. package/locale/id.json +1 -1
  240. package/locale/id.json.js +1 -1
  241. package/locale/ie/package.json +16 -0
  242. package/locale/ie.json +159 -0
  243. package/locale/ie.json.d.ts +4 -0
  244. package/locale/ie.json.js +159 -0
  245. package/locale/ig.json +17 -17
  246. package/locale/ig.json.js +17 -17
  247. package/locale/ii/package.json +16 -0
  248. package/locale/ii.json +165 -0
  249. package/locale/ii.json.d.ts +4 -0
  250. package/locale/ii.json.js +165 -0
  251. package/locale/is.json +4 -1
  252. package/locale/is.json.js +4 -1
  253. package/locale/kaa/package.json +16 -0
  254. package/locale/kaa.json +159 -0
  255. package/locale/kaa.json.d.ts +4 -0
  256. package/locale/kaa.json.js +159 -0
  257. package/locale/kok-Latn/package.json +16 -0
  258. package/locale/kok-Latn.json +159 -0
  259. package/locale/kok-Latn.json.d.ts +4 -0
  260. package/locale/kok-Latn.json.js +159 -0
  261. package/locale/kok.json +8 -8
  262. package/locale/kok.json.js +8 -8
  263. package/locale/ks.json +9 -9
  264. package/locale/ks.json.js +9 -9
  265. package/locale/ku.json +55 -46
  266. package/locale/ku.json.js +55 -46
  267. package/locale/lld/package.json +16 -0
  268. package/locale/lld.json +291 -0
  269. package/locale/lld.json.d.ts +4 -0
  270. package/locale/lld.json.js +291 -0
  271. package/locale/mi.json +22 -22
  272. package/locale/mi.json.js +22 -22
  273. package/locale/ms-Arab/package.json +16 -0
  274. package/locale/ms-Arab.json +159 -0
  275. package/locale/ms-Arab.json.d.ts +4 -0
  276. package/locale/ms-Arab.json.js +159 -0
  277. package/locale/nb.json +2 -2
  278. package/locale/nb.json.js +2 -2
  279. package/locale/ne.json +1 -1
  280. package/locale/ne.json.js +1 -1
  281. package/locale/nn.json +4 -4
  282. package/locale/nn.json.js +4 -4
  283. package/locale/no.json +2 -2
  284. package/locale/no.json.js +2 -2
  285. package/locale/nqo/package.json +16 -0
  286. package/locale/nqo.json +159 -0
  287. package/locale/nqo.json.d.ts +4 -0
  288. package/locale/nqo.json.js +159 -0
  289. package/locale/om/package.json +16 -0
  290. package/locale/om.json +213 -0
  291. package/locale/om.json.d.ts +4 -0
  292. package/locale/om.json.js +213 -0
  293. package/locale/or.json +1 -1
  294. package/locale/or.json.js +1 -1
  295. package/locale/qu.json +46 -46
  296. package/locale/qu.json.js +46 -46
  297. package/locale/rhg/package.json +16 -0
  298. package/locale/rhg.json +159 -0
  299. package/locale/rhg.json.d.ts +4 -0
  300. package/locale/rhg.json.js +159 -0
  301. package/locale/sl.json +12 -12
  302. package/locale/sl.json.js +12 -12
  303. package/locale/sr-Cyrl-BA.json +2 -2
  304. package/locale/sr-Cyrl-BA.json.js +2 -2
  305. package/locale/sr-Latn-BA.json +2 -2
  306. package/locale/sr-Latn-BA.json.js +2 -2
  307. package/locale/sv.json +1 -1
  308. package/locale/sv.json.js +1 -1
  309. package/locale/syr/package.json +16 -0
  310. package/locale/syr.json +303 -0
  311. package/locale/syr.json.d.ts +4 -0
  312. package/locale/syr.json.js +303 -0
  313. package/locale/ti.json +6 -6
  314. package/locale/ti.json.js +6 -6
  315. package/locale/tn/package.json +16 -0
  316. package/locale/tn.json +159 -0
  317. package/locale/tn.json.d.ts +4 -0
  318. package/locale/tn.json.js +159 -0
  319. package/locale/to.json +26 -26
  320. package/locale/to.json.js +26 -26
  321. package/locale/uk.json +1 -1
  322. package/locale/uk.json.js +1 -1
  323. package/locale/ur-IN.json +9 -6
  324. package/locale/ur-IN.json.js +9 -6
  325. package/locale/vec/package.json +16 -0
  326. package/locale/vec.json +267 -0
  327. package/locale/vec.json.d.ts +4 -0
  328. package/locale/vec.json.js +267 -0
  329. package/locale/xnr/package.json +16 -0
  330. package/locale/xnr.json +159 -0
  331. package/locale/xnr.json.d.ts +4 -0
  332. package/locale/xnr.json.js +159 -0
  333. package/locale/yo-BJ.json +17 -17
  334. package/locale/yo-BJ.json.js +17 -17
  335. package/locale/yo.json +17 -17
  336. package/locale/yo.json.js +17 -17
  337. package/modules/FullDateFormatter.js +67 -0
  338. package/modules/FullDateFormatter.js.map +1 -0
  339. package/modules/FullDateFormatter.test.js +22 -0
  340. package/modules/FullDateFormatter.test.js.map +1 -0
  341. package/modules/LocaleDataStore.js +2 -3
  342. package/modules/LocaleDataStore.js.map +1 -1
  343. package/modules/PropTypes.js +11 -7
  344. package/modules/PropTypes.js.map +1 -1
  345. package/modules/TimeAgo.js +299 -237
  346. package/modules/TimeAgo.js.map +1 -1
  347. package/modules/TimeAgo.test.js +217 -119
  348. package/modules/TimeAgo.test.js.map +1 -1
  349. package/modules/cache.js +6 -22
  350. package/modules/cache.js.map +1 -1
  351. package/modules/cache.test.js.map +1 -1
  352. package/modules/isStyleObject.js +9 -7
  353. package/modules/isStyleObject.js.map +1 -1
  354. package/modules/isStyleObject.test.js.map +1 -1
  355. package/modules/locale.js +6 -16
  356. package/modules/locale.js.map +1 -1
  357. package/modules/locale.test.js +0 -4
  358. package/modules/locale.test.js.map +1 -1
  359. package/modules/round.js +2 -3
  360. package/modules/round.js.map +1 -1
  361. package/modules/steps/approximate.js +6 -2
  362. package/modules/steps/approximate.js.map +1 -1
  363. package/modules/steps/approximate.test.js +0 -2
  364. package/modules/steps/approximate.test.js.map +1 -1
  365. package/modules/steps/getStep.js +36 -48
  366. package/modules/steps/getStep.js.map +1 -1
  367. package/modules/steps/getStep.test.js +6 -2
  368. package/modules/steps/getStep.test.js.map +1 -1
  369. package/modules/steps/getStepDenominator.js +2 -3
  370. package/modules/steps/getStepDenominator.js.map +1 -1
  371. package/modules/steps/getStepDenominator.test.js.map +1 -1
  372. package/modules/steps/getStepMinTime.js +31 -36
  373. package/modules/steps/getStepMinTime.js.map +1 -1
  374. package/modules/steps/getStepMinTime.test.js.map +1 -1
  375. package/modules/steps/getTimeToNextUpdate.js +28 -32
  376. package/modules/steps/getTimeToNextUpdate.js.map +1 -1
  377. package/modules/steps/getTimeToNextUpdate.test.js +27 -18
  378. package/modules/steps/getTimeToNextUpdate.test.js.map +1 -1
  379. package/modules/steps/getTimeToNextUpdateForUnit.js +4 -10
  380. package/modules/steps/getTimeToNextUpdateForUnit.js.map +1 -1
  381. package/modules/steps/getTimeToNextUpdateForUnit.test.js +0 -4
  382. package/modules/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
  383. package/modules/steps/helpers.js +1 -1
  384. package/modules/steps/helpers.js.map +1 -1
  385. package/modules/steps/helpers.test.js.map +1 -1
  386. package/modules/steps/index.js +2 -1
  387. package/modules/steps/index.js.map +1 -1
  388. package/modules/steps/renameLegacyProperties.js +6 -13
  389. package/modules/steps/renameLegacyProperties.js.map +1 -1
  390. package/modules/steps/renameLegacyProperties.test.js.map +1 -1
  391. package/modules/steps/round.js.map +1 -1
  392. package/modules/steps/round.test.js +0 -3
  393. package/modules/steps/round.test.js.map +1 -1
  394. package/modules/steps/units.js +5 -9
  395. package/modules/steps/units.js.map +1 -1
  396. package/modules/style/approximate.js +5 -1
  397. package/modules/style/approximate.js.map +1 -1
  398. package/modules/style/approximateTime.js +6 -2
  399. package/modules/style/approximateTime.js.map +1 -1
  400. package/modules/style/approximateTime.test.js +115 -70
  401. package/modules/style/approximateTime.test.js.map +1 -1
  402. package/modules/style/getStyleByName.js +4 -17
  403. package/modules/style/getStyleByName.js.map +1 -1
  404. package/modules/style/mini.js +8 -4
  405. package/modules/style/mini.js.map +1 -1
  406. package/modules/style/mini.test.js +14 -20
  407. package/modules/style/mini.test.js.map +1 -1
  408. package/modules/style/miniMinute.js +6 -6
  409. package/modules/style/miniMinute.js.map +1 -1
  410. package/modules/style/miniMinute.test.js +10 -12
  411. package/modules/style/miniMinute.test.js.map +1 -1
  412. package/modules/style/miniMinuteNow.js +6 -6
  413. package/modules/style/miniMinuteNow.js.map +1 -1
  414. package/modules/style/miniMinuteNow.test.js +10 -12
  415. package/modules/style/miniMinuteNow.test.js.map +1 -1
  416. package/modules/style/miniNow.js +6 -6
  417. package/modules/style/miniNow.js.map +1 -1
  418. package/modules/style/miniNow.test.js +10 -12
  419. package/modules/style/miniNow.test.js.map +1 -1
  420. package/modules/style/renameLegacyProperties.js +8 -10
  421. package/modules/style/renameLegacyProperties.js.map +1 -1
  422. package/modules/style/renameLegacyProperties.test.js +0 -1
  423. package/modules/style/renameLegacyProperties.test.js.map +1 -1
  424. package/modules/style/round.js +3 -2
  425. package/modules/style/round.js.map +1 -1
  426. package/modules/style/round.test.js +50 -62
  427. package/modules/style/round.test.js.map +1 -1
  428. package/modules/style/roundMinute.js +8 -7
  429. package/modules/style/roundMinute.js.map +1 -1
  430. package/modules/style/roundMinute.test.js +19 -22
  431. package/modules/style/roundMinute.test.js.map +1 -1
  432. package/modules/style/twitter.js +36 -33
  433. package/modules/style/twitter.js.map +1 -1
  434. package/modules/style/twitter.test.js +53 -52
  435. package/modules/style/twitter.test.js.map +1 -1
  436. package/modules/style/twitterFirstMinute.js +8 -7
  437. package/modules/style/twitterFirstMinute.js.map +1 -1
  438. package/modules/style/twitterFirstMinute.test.js +15 -18
  439. package/modules/style/twitterFirstMinute.test.js.map +1 -1
  440. package/modules/style/twitterMinute.js +6 -6
  441. package/modules/style/twitterMinute.js.map +1 -1
  442. package/modules/style/twitterMinute.test.js +19 -20
  443. package/modules/style/twitterMinute.test.js.map +1 -1
  444. package/modules/style/twitterMinuteNow.js +6 -6
  445. package/modules/style/twitterMinuteNow.js.map +1 -1
  446. package/modules/style/twitterMinuteNow.test.js +19 -20
  447. package/modules/style/twitterMinuteNow.test.js.map +1 -1
  448. package/modules/style/twitterNow.js +6 -6
  449. package/modules/style/twitterNow.js.map +1 -1
  450. package/modules/style/twitterNow.test.js +17 -19
  451. package/modules/style/twitterNow.test.js.map +1 -1
  452. package/package.json +275 -13
@@ -1,8 +1,16 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
1
7
  import TimeAgo from './TimeAgo.js';
2
- import { getLocaleData } from './LocaleDataStore.js'; // Load locale specific relative date/time messages
8
+ import { getLocaleData } from './LocaleDataStore.js';
3
9
 
4
- import english from '../locale/en.json' assert { type: 'json' }; // Just so this function code is covered.
10
+ // Load locale specific relative date/time messages
11
+ import english from '../locale/en.json' assert { type: 'json' };
5
12
 
13
+ // Just so this function code is covered.
6
14
  TimeAgo.setDefaultLocale('en');
7
15
  describe("javascript-time-ago", function () {
8
16
  it('should default to "round-minute" style', function () {
@@ -40,8 +48,8 @@ describe("javascript-time-ago", function () {
40
48
  }, {
41
49
  future: true,
42
50
  now: 0
43
- }).should.equal('now'); // `flavour` is a legacy name of `labels` property.
44
-
51
+ }).should.equal('now');
52
+ // `flavour` is a legacy name of `labels` property.
45
53
  timeAgo.format(0, {
46
54
  flavour: 'mini'
47
55
  }, {
@@ -61,8 +69,8 @@ describe("javascript-time-ago", function () {
61
69
  }, {
62
70
  future: true,
63
71
  now: 0
64
- }).should.equal('in 0 minutes'); // `gradation` is a legacy name of `steps` property.
65
-
72
+ }).should.equal('in 0 minutes');
73
+ // `gradation` is a legacy name of `steps` property.
66
74
  timeAgo.format(0, {
67
75
  gradation: [{
68
76
  formatAs: 'minute'
@@ -135,16 +143,16 @@ describe("javascript-time-ago", function () {
135
143
  past: '{0} minute(s) ago',
136
144
  future: 'in {0} minute(s)'
137
145
  };
138
- TimeAgo.addLocale(english); // Past.
139
-
146
+ TimeAgo.addLocale(english);
147
+ // Past.
140
148
  timeAgo.format(Date.now() - 60 * 1000, {
141
149
  labels: 'long-time'
142
- }).should.equal('1 minute(s) ago'); // Future (covers an "else" branch).
143
-
150
+ }).should.equal('1 minute(s) ago');
151
+ // Future (covers an "else" branch).
144
152
  timeAgo.format(Date.now() + 60 * 1000, {
145
153
  labels: 'long-time'
146
- }).should.equal('in 1 minute(s)'); // Undo.
147
-
154
+ }).should.equal('in 1 minute(s)');
155
+ // Undo.
148
156
  english['long-time'].minute = englishLongTimeMinute;
149
157
  timeAgo.format(Date.now() - 60 * 1000, {
150
158
  labels: 'long-time'
@@ -157,43 +165,43 @@ describe("javascript-time-ago", function () {
157
165
  }).should.equal('in a moment');
158
166
  });
159
167
  it('should accept a string style name argument', function () {
160
- var timeAgo = new TimeAgo('en'); // "mini".
161
-
168
+ var timeAgo = new TimeAgo('en');
169
+ // "mini".
162
170
  timeAgo.format(Date.now() - 0 * 1000, 'mini').should.equal('0s');
163
- timeAgo.format(Date.now() - 1 * 1000, 'mini').should.equal('1s'); // "mini-now".
164
-
171
+ timeAgo.format(Date.now() - 1 * 1000, 'mini').should.equal('1s');
172
+ // "mini-now".
165
173
  timeAgo.format(Date.now() - 0 * 1000, 'mini-now').should.equal('now');
166
- timeAgo.format(Date.now() - 1 * 1000, 'mini-now').should.equal('1s'); // "mini-minute-now".
167
-
174
+ timeAgo.format(Date.now() - 1 * 1000, 'mini-now').should.equal('1s');
175
+ // "mini-minute-now".
168
176
  timeAgo.format(Date.now() - 29 * 1000, 'mini-minute-now').should.equal('now');
169
- timeAgo.format(Date.now() - 60 * 1000, 'mini-minute-now').should.equal('1m'); // "mini-minute".
170
-
177
+ timeAgo.format(Date.now() - 60 * 1000, 'mini-minute-now').should.equal('1m');
178
+ // "mini-minute".
171
179
  timeAgo.format(Date.now() - 29 * 1000, 'mini-minute').should.equal('0m');
172
- timeAgo.format(Date.now() - 60 * 1000, 'mini-minute').should.equal('1m'); // "twitter".
173
-
180
+ timeAgo.format(Date.now() - 60 * 1000, 'mini-minute').should.equal('1m');
181
+ // "twitter".
174
182
  timeAgo.format(Date.now() - 0 * 1000, 'twitter').should.equal('0s');
175
- timeAgo.format(Date.now() - 1 * 1000, 'twitter').should.equal('1s'); // "twitter-now".
176
-
183
+ timeAgo.format(Date.now() - 1 * 1000, 'twitter').should.equal('1s');
184
+ // "twitter-now".
177
185
  timeAgo.format(Date.now() - 0 * 1000, 'twitter-now').should.equal('now');
178
- timeAgo.format(Date.now() - 1 * 1000, 'twitter-now').should.equal('1s'); // "twitter-minute-now".
179
-
186
+ timeAgo.format(Date.now() - 1 * 1000, 'twitter-now').should.equal('1s');
187
+ // "twitter-minute-now".
180
188
  timeAgo.format(Date.now() - 29 * 1000, 'twitter-minute-now').should.equal('now');
181
- timeAgo.format(Date.now() - 60 * 1000, 'twitter-minute-now').should.equal('1m'); // "twitter-minute".
182
-
189
+ timeAgo.format(Date.now() - 60 * 1000, 'twitter-minute-now').should.equal('1m');
190
+ // "twitter-minute".
183
191
  timeAgo.format(Date.now() - 29 * 1000, 'twitter-minute').should.equal('0m');
184
- timeAgo.format(Date.now() - 60 * 1000, 'twitter-minute').should.equal('1m'); // "twitter-first-minute".
185
-
192
+ timeAgo.format(Date.now() - 60 * 1000, 'twitter-minute').should.equal('1m');
193
+ // "twitter-first-minute".
186
194
  timeAgo.format(Date.now() - 29 * 1000, 'twitter-first-minute').should.equal('');
187
- timeAgo.format(Date.now() - 60 * 1000, 'twitter-first-minute').should.equal('1m'); // "approximate".
188
-
189
- timeAgo.format(Date.now() - 45 * 1000, 'approximate').should.equal('just now'); // "convenient" style was renamed to "approximate".
190
-
195
+ timeAgo.format(Date.now() - 60 * 1000, 'twitter-first-minute').should.equal('1m');
196
+ // "approximate".
197
+ timeAgo.format(Date.now() - 45 * 1000, 'approximate').should.equal('just now');
198
+ // "convenient" style was renamed to "approximate".
191
199
  timeAgo.format(Date.now() - 45 * 1000, 'convenient').should.equal('just now');
192
- timeAgo.format(Date.now() - 45 * 1000, 'round').should.equal('45 seconds ago'); // "default" style was renamed to "round".
193
-
200
+ timeAgo.format(Date.now() - 45 * 1000, 'round').should.equal('45 seconds ago');
201
+ // "default" style was renamed to "round".
194
202
  timeAgo.format(Date.now() - 45 * 1000, 'default').should.equal('45 seconds ago');
195
- timeAgo.format(Date.now() - 29 * 1000, 'round-minute').should.equal('just now'); // "time" style was renamed to "approximate-time".
196
-
203
+ timeAgo.format(Date.now() - 29 * 1000, 'round-minute').should.equal('just now');
204
+ // "time" style was renamed to "approximate-time".
197
205
  timeAgo.format(Date.now() - 2 * 60 * 1000, 'time').should.equal('2 minutes');
198
206
  timeAgo.format(Date.now() - 2 * 60 * 1000, 'approximate-time').should.equal('2 minutes');
199
207
  timeAgo.format(Date.now(), 'exotic').should.equal('just now');
@@ -213,11 +221,9 @@ describe("javascript-time-ago", function () {
213
221
  });
214
222
  it('should not accept anything but Dates and timestamps', function () {
215
223
  var timeAgo = new TimeAgo('en');
216
-
217
224
  var thrower = function thrower() {
218
225
  return timeAgo.format('Jan 14, 2017');
219
226
  };
220
-
221
227
  thrower.should["throw"]('Unsupported relative time formatter input: string, Jan 14, 2017');
222
228
  });
223
229
  it('should return an empty string if the specified units are not available in locale data', function () {
@@ -227,28 +233,45 @@ describe("javascript-time-ago", function () {
227
233
  }).should.equal('');
228
234
  });
229
235
  it('should format for a style with "custom" function', function () {
230
- var timeAgo = new TimeAgo('en'); // `custom` returns a string
231
-
236
+ var timeAgo = new TimeAgo('en');
232
237
  timeAgo.format(Date.now(), {
238
+ // `custom` returns a string
233
239
  custom: function custom(_ref) {
234
240
  var now = _ref.now,
235
- time = _ref.time,
236
- date = _ref.date,
237
- locale = _ref.locale;
241
+ time = _ref.time,
242
+ date = _ref.date,
243
+ locale = _ref.locale;
238
244
  return locale;
239
245
  }
240
- }).should.equal('en'); // `custom` returns `undefined`
241
-
246
+ }).should.equal('en');
242
247
  timeAgo.format(Date.now(), {
248
+ // `custom` returns `undefined`
243
249
  custom: function custom(_ref2) {
244
250
  var now = _ref2.now,
245
- time = _ref2.time,
246
- date = _ref2.date,
247
- locale = _ref2.locale;
251
+ time = _ref2.time,
252
+ date = _ref2.date,
253
+ locale = _ref2.locale;
248
254
  return;
249
255
  }
250
256
  }).should.equal('just now');
251
257
  });
258
+ it('should throw an error when formating for a style with "custom" function and `getTimeToNextUpdate: true` parameter is passed', function () {
259
+ var timeAgo = new TimeAgo('en');
260
+ expect(function () {
261
+ timeAgo.format(Date.now(), {
262
+ // `custom` returns a string.
263
+ custom: function custom(_ref3) {
264
+ var now = _ref3.now,
265
+ time = _ref3.time,
266
+ date = _ref3.date,
267
+ locale = _ref3.locale;
268
+ return locale;
269
+ }
270
+ }, {
271
+ getTimeToNextUpdate: true
272
+ });
273
+ }).to["throw"]('not supported');
274
+ });
252
275
  it('should format future dates', function () {
253
276
  new TimeAgo('en').format(Date.now() + 60 * 60 * 1000).should.equal('in 1 hour');
254
277
  new TimeAgo('ru').format(Date.now() + 60 * 1000).should.equal('через 1 минуту');
@@ -258,7 +281,9 @@ describe("javascript-time-ago", function () {
258
281
  new TimeAgo('en').format(Date.now()).should.equal('just now');
259
282
  new TimeAgo('en').format(Date.now(), 'approximate', {
260
283
  future: true
261
- }).should.equal('in a moment'); // Non-"now" unit, "long" style.
284
+ }).should.equal('in a moment');
285
+
286
+ // Non-"now" unit, "long" style.
262
287
  // const style = {
263
288
  // gradation: [{
264
289
  // factor: 1,
@@ -268,8 +293,8 @@ describe("javascript-time-ago", function () {
268
293
  // }
269
294
  // new TimeAgo('en').format(Date.now(), style).should.equal('0 seconds ago')
270
295
  // new TimeAgo('en').format(Date.now(), style, { future: true }).should.equal('in 0 seconds')
271
- // Non-"now" unit, "mini" style.
272
296
 
297
+ // Non-"now" unit, "mini" style.
273
298
  var style2 = {
274
299
  style: [{
275
300
  unit: 'year'
@@ -328,9 +353,65 @@ describe("javascript-time-ago", function () {
328
353
  }).should.equal('in 0 seconds');
329
354
  english['mini'].second = secondLabels;
330
355
  });
356
+ it('should refresh the label when `refresh` parameter is passed', function () {
357
+ var refreshedTimes = 0;
358
+ var timeAgo = new TimeAgo('en');
359
+ // in 1 second -> in 0 seconds.
360
+ var _timeAgo$format = timeAgo.format(1000, 'twitter', {
361
+ refresh: function refresh(text) {
362
+ if (refreshedTimes === 0) {
363
+ expect(text).to.equal('0s');
364
+ } else {
365
+ throw new Error('Refresh should have been cancelled');
366
+ }
367
+ refreshedTimes++;
368
+ },
369
+ now: 0,
370
+ round: 'floor'
371
+ }),
372
+ _timeAgo$format2 = _slicedToArray(_timeAgo$format, 2),
373
+ text = _timeAgo$format2[0],
374
+ cancelRefresh = _timeAgo$format2[1];
375
+ expect(text).to.equal('1s');
376
+ expect(cancelRefresh).to.be.a('function');
377
+ // Sidenote: `timeToNextUpdate` is `1`.
378
+ var timeToNextUpdate = 1;
379
+ return delay(timeToNextUpdate + 1).then(function () {
380
+ expect(refreshedTimes).to.equal(1);
381
+ cancelRefresh();
382
+ });
383
+ });
384
+ it('should get time to next update (capped)', function () {
385
+ var timeAgo = new TimeAgo('en');
386
+ // in 1 second -> in 0 seconds.
387
+ timeAgo.format(0.5 * 365 * 24 * 60 * 60 * 1000, 'twitter', {
388
+ getTimeToNextUpdate: true,
389
+ now: 0,
390
+ round: 'floor'
391
+ }).should.deep.equal(['Jul 2', 2147483647]);
392
+ });
393
+ it('should get time to next update (capped)', function () {
394
+ var timeAgo = new TimeAgo('en');
395
+ // in 1 second -> in 0 seconds.
396
+ timeAgo.format(0.5 * 365 * 24 * 60 * 60 * 1000, 'twitter', {
397
+ getTimeToNextUpdate: true,
398
+ getTimeToNextUpdateUncapped: true,
399
+ now: 0,
400
+ round: 'floor'
401
+ }).should.deep.equal(['Jul 2', 15681600001]);
402
+ });
403
+ it('should get time to next update (uncapped)', function () {
404
+ var timeAgo = new TimeAgo('en');
405
+ // in 1 second -> in 0 seconds.
406
+ timeAgo.format(1000, 'twitter', {
407
+ getTimeToNextUpdate: true,
408
+ now: 0,
409
+ round: 'floor'
410
+ }).should.deep.equal(['1s', 1]);
411
+ });
331
412
  it('should get time to next update (round: "floor")', function () {
332
- var timeAgo = new TimeAgo('en'); // in 1 second -> in 0 seconds.
333
-
413
+ var timeAgo = new TimeAgo('en');
414
+ // in 1 second -> in 0 seconds.
334
415
  timeAgo.format(1000, 'twitter', {
335
416
  getTimeToNextUpdate: true,
336
417
  now: 0,
@@ -338,62 +419,63 @@ describe("javascript-time-ago", function () {
338
419
  }).should.deep.equal(['1s', 1]);
339
420
  });
340
421
  it('should get time to next update (round: "round")', function () {
341
- var timeAgo = new TimeAgo('en'); // in 1 second -> in 0 seconds.
342
-
422
+ var timeAgo = new TimeAgo('en');
423
+ // in 1 second -> in 0 seconds.
343
424
  timeAgo.format(1000, 'twitter', {
344
425
  getTimeToNextUpdate: true,
345
426
  now: 0
346
427
  }).should.deep.equal(['1s', 501]);
347
428
  });
348
429
  it('should get time to next update ("mini-now" style) (round: "floor")', function () {
349
- var timeAgo = new TimeAgo('en'); // In 1 minute.
350
-
430
+ var timeAgo = new TimeAgo('en');
431
+ // In 1 minute.
351
432
  timeAgo.format(60 * 1000, 'mini-now', {
352
433
  getTimeToNextUpdate: true,
353
434
  now: 0,
354
435
  round: 'floor'
355
- }).should.deep.equal(['1m', 1]); // Almost in 1 minute.
356
-
436
+ }).should.deep.equal(['1m', 1]);
437
+ // Almost in 1 minute.
357
438
  timeAgo.format(60 * 1000, 'mini-now', {
358
439
  getTimeToNextUpdate: true,
359
440
  now: 1,
360
441
  round: 'floor'
361
- }).should.deep.equal(['59s', 1000]); // In 1 second.
362
-
442
+ }).should.deep.equal(['59s', 1000]);
443
+ // In 1 second.
363
444
  timeAgo.format(60 * 1000, 'mini-now', {
364
445
  getTimeToNextUpdate: true,
365
446
  now: 59 * 1000,
366
447
  round: 'floor'
367
- }).should.deep.equal(['1s', 1]); // Almost in 1 second.
368
-
448
+ }).should.deep.equal(['1s', 1]);
449
+ // Almost in 1 second.
369
450
  timeAgo.format(60 * 1000, 'mini-now', {
370
451
  getTimeToNextUpdate: true,
371
452
  now: 59 * 1000 + 1,
372
453
  round: 'floor'
373
- }).should.deep.equal(['now', // Right after zero point.
374
- 1000]); // Zero point (future to past).
454
+ }).should.deep.equal(['now',
455
+ // Right after zero point.
456
+ 1000]);
457
+ // Zero point (future to past).
375
458
  // `future: true`.
376
-
377
459
  timeAgo.format(60 * 1000, 'mini-now', {
378
460
  getTimeToNextUpdate: true,
379
461
  now: 60 * 1000,
380
462
  future: true,
381
463
  round: 'floor'
382
- }).should.deep.equal(['now', 1]); // Zero point (future to past).
464
+ }).should.deep.equal(['now', 1]);
465
+ // Zero point (future to past).
383
466
  // `future: false`.
384
-
385
467
  timeAgo.format(60 * 1000, 'mini-now', {
386
468
  getTimeToNextUpdate: true,
387
469
  now: 60 * 1000,
388
470
  round: 'floor'
389
- }).should.deep.equal(['now', 1000]); // Right after zero point (past).
390
-
471
+ }).should.deep.equal(['now', 1000]);
472
+ // Right after zero point (past).
391
473
  timeAgo.format(60 * 1000, 'mini-now', {
392
474
  getTimeToNextUpdate: true,
393
475
  now: 60 * 1000 + 1,
394
476
  round: 'floor'
395
- }).should.deep.equal(['now', 1000 - 1]); // 1 second ago.
396
-
477
+ }).should.deep.equal(['now', 1000 - 1]);
478
+ // 1 second ago.
397
479
  timeAgo.format(60 * 1000, 'mini-now', {
398
480
  getTimeToNextUpdate: true,
399
481
  now: 60 * 1000 + 1000,
@@ -401,57 +483,59 @@ describe("javascript-time-ago", function () {
401
483
  }).should.deep.equal(['1s', 1000]);
402
484
  });
403
485
  it('should get time to next update ("mini-now" style) (round: "round")', function () {
404
- var timeAgo = new TimeAgo('en'); // In 1 minute.
405
-
486
+ var timeAgo = new TimeAgo('en');
487
+ // In 1 minute.
406
488
  timeAgo.format(60 * 1000, 'mini-now', {
407
489
  getTimeToNextUpdate: true,
408
490
  now: 0
409
- }).should.deep.equal(['1m', 500 + 1]); // Almost in 1 minute.
410
-
491
+ }).should.deep.equal(['1m', 500 + 1]);
492
+ // Almost in 1 minute.
411
493
  timeAgo.format(60 * 1000, 'mini-now', {
412
494
  getTimeToNextUpdate: true,
413
495
  now: 500 + 1
414
- }).should.deep.equal(['59s', 1000]); // In 1 second.
415
-
496
+ }).should.deep.equal(['59s', 1000]);
497
+ // In 1 second.
416
498
  timeAgo.format(60 * 1000, 'mini-now', {
417
499
  getTimeToNextUpdate: true,
418
500
  now: 59.5 * 1000
419
- }).should.deep.equal(['1s', 1]); // Almost in 1 second.
420
-
501
+ }).should.deep.equal(['1s', 1]);
502
+ // Almost in 1 second.
421
503
  timeAgo.format(60 * 1000, 'mini-now', {
422
504
  getTimeToNextUpdate: true,
423
505
  now: 59.5 * 1000 + 1
424
- }).should.deep.equal(['now', // Right after zero point.
425
- 500]); // Zero point (future to past).
506
+ }).should.deep.equal(['now',
507
+ // Right after zero point.
508
+ 500]);
509
+ // Zero point (future to past).
426
510
  // `future: true`.
427
-
428
511
  timeAgo.format(60 * 1000, 'mini-now', {
429
512
  getTimeToNextUpdate: true,
430
513
  now: 60 * 1000,
431
514
  future: true
432
- }).should.deep.equal(['now', 1]); // Zero point (future to past).
515
+ }).should.deep.equal(['now', 1]);
516
+ // Zero point (future to past).
433
517
  // `future: false`.
434
-
435
518
  timeAgo.format(60 * 1000, 'mini-now', {
436
519
  getTimeToNextUpdate: true,
437
520
  now: 60 * 1000
438
- }).should.deep.equal(['now', 500]); // Right after zero point (past).
439
-
521
+ }).should.deep.equal(['now', 500]);
522
+ // Right after zero point (past).
440
523
  timeAgo.format(60 * 1000, 'mini-now', {
441
524
  getTimeToNextUpdate: true,
442
525
  now: 60 * 1000 + 1
443
- }).should.deep.equal(['now', 500 - 1]); // 1 second ago.
444
-
526
+ }).should.deep.equal(['now', 500 - 1]);
527
+ // 1 second ago.
445
528
  timeAgo.format(60 * 1000, 'mini-now', {
446
529
  getTimeToNextUpdate: true,
447
530
  now: 60 * 1000 + 500
448
531
  }).should.deep.equal(['1s', 1000]);
449
532
  });
450
533
  it('should get time to next update (first step has non-zero "minTime") (round: "floor")', function () {
451
- var timeAgo = new TimeAgo('en'); // Future.
534
+ var timeAgo = new TimeAgo('en');
535
+
536
+ // Future.
452
537
  // Inside the first step.
453
538
  // Updates soon.
454
-
455
539
  timeAgo.format(60 * 1000, {
456
540
  steps: [{
457
541
  formatAs: 'minute',
@@ -462,10 +546,11 @@ describe("javascript-time-ago", function () {
462
546
  }, {
463
547
  getTimeToNextUpdate: true,
464
548
  now: -0.5 * 1000
465
- }).should.deep.equal(['1m', 0.5 * 1000 + 1]); // Future.
549
+ }).should.deep.equal(['1m', 0.5 * 1000 + 1]);
550
+
551
+ // Future.
466
552
  // Outside of the first step.
467
553
  // Updates right after zero point.
468
-
469
554
  timeAgo.format(60 * 1000, {
470
555
  steps: [{
471
556
  formatAs: 'minute',
@@ -476,10 +561,11 @@ describe("javascript-time-ago", function () {
476
561
  }, {
477
562
  getTimeToNextUpdate: true,
478
563
  now: 1 * 1000
479
- }).should.deep.equal(['', 59 * 1000 + 1]); // Zero point.
564
+ }).should.deep.equal(['', 59 * 1000 + 1]);
565
+
566
+ // Zero point.
480
567
  // Outside of the first step.
481
568
  // Updates at the first step's `minTime`.
482
-
483
569
  timeAgo.format(60 * 1000, {
484
570
  steps: [{
485
571
  formatAs: 'minute',
@@ -490,10 +576,11 @@ describe("javascript-time-ago", function () {
490
576
  }, {
491
577
  getTimeToNextUpdate: true,
492
578
  now: 60 * 1000
493
- }).should.deep.equal(['', 60 * 1000]); // Past.
579
+ }).should.deep.equal(['', 60 * 1000]);
580
+
581
+ // Past.
494
582
  // Inside the first step.
495
583
  // Updates at the next minute.
496
-
497
584
  timeAgo.format(60 * 1000, {
498
585
  steps: [{
499
586
  formatAs: 'minute',
@@ -504,50 +591,51 @@ describe("javascript-time-ago", function () {
504
591
  }, {
505
592
  getTimeToNextUpdate: true,
506
593
  now: 60 * 1000 + 60 * 1000
507
- }).should.deep.equal(['1m', 60 * 1000]); // Almost in 1 minute.
594
+ }).should.deep.equal(['1m', 60 * 1000]);
508
595
 
596
+ // Almost in 1 minute.
509
597
  timeAgo.format(60 * 1000, 'mini-now', {
510
598
  getTimeToNextUpdate: true,
511
599
  now: 1,
512
600
  round: 'floor'
513
- }).should.deep.equal(['59s', 1000]); // In 1 second.
514
-
601
+ }).should.deep.equal(['59s', 1000]);
602
+ // In 1 second.
515
603
  timeAgo.format(60 * 1000, 'mini-now', {
516
604
  getTimeToNextUpdate: true,
517
605
  now: 59 * 1000,
518
606
  round: 'floor'
519
- }).should.deep.equal(['1s', 1]); // Almost in 1 second.
607
+ }).should.deep.equal(['1s', 1]);
608
+ // Almost in 1 second.
520
609
  // Updates right after the zero point.
521
-
522
610
  timeAgo.format(60 * 1000, 'mini-now', {
523
611
  getTimeToNextUpdate: true,
524
612
  now: 59 * 1000 + 1,
525
613
  round: 'floor'
526
- }).should.deep.equal(['now', 1000]); // Zero point (future to past).
614
+ }).should.deep.equal(['now', 1000]);
615
+ // Zero point (future to past).
527
616
  // `future: true`.
528
617
  // Updates right after zero point.
529
-
530
618
  timeAgo.format(60 * 1000, 'mini-now', {
531
619
  getTimeToNextUpdate: true,
532
620
  now: 60 * 1000,
533
621
  future: true,
534
622
  round: 'floor'
535
- }).should.deep.equal(['now', 1]); // Zero point (future to past).
623
+ }).should.deep.equal(['now', 1]);
624
+ // Zero point (future to past).
536
625
  // `future: false`.
537
626
  // Updates at the next second.
538
-
539
627
  timeAgo.format(60 * 1000, 'mini-now', {
540
628
  getTimeToNextUpdate: true,
541
629
  now: 60 * 1000,
542
630
  round: 'floor'
543
- }).should.deep.equal(['now', 1000]); // Right after zero point (past).
544
-
631
+ }).should.deep.equal(['now', 1000]);
632
+ // Right after zero point (past).
545
633
  timeAgo.format(60 * 1000, 'mini-now', {
546
634
  getTimeToNextUpdate: true,
547
635
  now: 60 * 1000 + 1,
548
636
  round: 'floor'
549
- }).should.deep.equal(['now', 1000 - 1]); // 1 second ago.
550
-
637
+ }).should.deep.equal(['now', 1000 - 1]);
638
+ // 1 second ago.
551
639
  timeAgo.format(60 * 1000, 'mini-now', {
552
640
  getTimeToNextUpdate: true,
553
641
  now: 60 * 1000 + 1000,
@@ -559,8 +647,8 @@ describe("javascript-time-ago", function () {
559
647
  timeAgo.format(Date.now(), {
560
648
  labels: 'long',
561
649
  steps: [{
562
- format: function format(date, locale, _ref3) {
563
- var formatAs = _ref3.formatAs;
650
+ format: function format(date, locale, _ref4) {
651
+ var formatAs = _ref4.formatAs;
564
652
  return formatAs('second', 1);
565
653
  }
566
654
  }]
@@ -569,8 +657,8 @@ describe("javascript-time-ago", function () {
569
657
  it('should support `polyfill: false` option', function () {
570
658
  var timeAgo = new TimeAgo('en', {
571
659
  polyfill: false
572
- }); // Still uses "now" labels, even when not polyfilled.
573
-
660
+ });
661
+ // Still uses "now" labels, even when not polyfilled.
574
662
  timeAgo.format(0, 'round', {
575
663
  now: 0
576
664
  }).should.equal('just now');
@@ -622,12 +710,17 @@ describe("javascript-time-ago", function () {
622
710
  TimeAgo.addDefaultLocale({
623
711
  locale: 'el'
624
712
  });
625
- TimeAgo.getDefaultLocale().should.equal('el'); // expect(() => {
626
-
713
+ TimeAgo.getDefaultLocale().should.equal('el');
714
+ // Doesn't throw an error because the same locale is already specified as default.
627
715
  TimeAgo.addDefaultLocale({
628
716
  locale: 'el'
629
- }); // }).to.throw('`TimeAgo.addDefaultLocale()` can only be called once')
630
-
717
+ });
718
+ // Could throw an error or output an error message because another locale is already specified as default.
719
+ // expect(() => {
720
+ TimeAgo.addDefaultLocale({
721
+ locale: 'es'
722
+ });
723
+ // }).to.throw('but you have already added "el" as the default locale.')
631
724
  TimeAgo.setDefaultLocale('en');
632
725
  });
633
726
  it('should support "floor" rounding', function () {
@@ -658,4 +751,9 @@ describe("javascript-time-ago", function () {
658
751
  }).should.equal('2m');
659
752
  });
660
753
  });
754
+ function delay(delayTime) {
755
+ return new Promise(function (resolve) {
756
+ setTimeout(resolve, delayTime);
757
+ });
758
+ }
661
759
  //# sourceMappingURL=TimeAgo.test.js.map