javascript-time-ago 2.5.10 → 2.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (439) hide show
  1. package/bundle/javascript-time-ago.js +1 -1
  2. package/bundle/javascript-time-ago.js.map +1 -1
  3. package/bundle/javascript-time-ago.min.js +1 -1
  4. package/bundle/javascript-time-ago.min.js.map +1 -1
  5. package/commonjs/LocaleDataStore.js +2 -5
  6. package/commonjs/LocaleDataStore.js.map +1 -1
  7. package/commonjs/PropTypes.js +12 -12
  8. package/commonjs/PropTypes.js.map +1 -1
  9. package/commonjs/TimeAgo.js +135 -190
  10. package/commonjs/TimeAgo.js.map +1 -1
  11. package/commonjs/TimeAgo.test.js +124 -130
  12. package/commonjs/TimeAgo.test.js.map +1 -1
  13. package/commonjs/cache.js +7 -25
  14. package/commonjs/cache.js.map +1 -1
  15. package/commonjs/cache.test.js +1 -3
  16. package/commonjs/cache.test.js.map +1 -1
  17. package/commonjs/isStyleObject.js +9 -9
  18. package/commonjs/isStyleObject.js.map +1 -1
  19. package/commonjs/isStyleObject.test.js +1 -3
  20. package/commonjs/isStyleObject.test.js.map +1 -1
  21. package/commonjs/locale.js +6 -19
  22. package/commonjs/locale.js.map +1 -1
  23. package/commonjs/locale.test.js +2 -11
  24. package/commonjs/locale.test.js.map +1 -1
  25. package/commonjs/round.js +2 -5
  26. package/commonjs/round.js.map +1 -1
  27. package/commonjs/steps/approximate.js +1 -4
  28. package/commonjs/steps/approximate.js.map +1 -1
  29. package/commonjs/steps/approximate.test.js +1 -6
  30. package/commonjs/steps/approximate.test.js.map +1 -1
  31. package/commonjs/steps/getStep.js +36 -53
  32. package/commonjs/steps/getStep.js.map +1 -1
  33. package/commonjs/steps/getStep.test.js +7 -7
  34. package/commonjs/steps/getStep.test.js.map +1 -1
  35. package/commonjs/steps/getStepDenominator.js +2 -5
  36. package/commonjs/steps/getStepDenominator.js.map +1 -1
  37. package/commonjs/steps/getStepDenominator.test.js +1 -3
  38. package/commonjs/steps/getStepDenominator.test.js.map +1 -1
  39. package/commonjs/steps/getStepMinTime.js +17 -32
  40. package/commonjs/steps/getStepMinTime.js.map +1 -1
  41. package/commonjs/steps/getStepMinTime.test.js +1 -3
  42. package/commonjs/steps/getStepMinTime.test.js.map +1 -1
  43. package/commonjs/steps/getTimeToNextUpdate.js +19 -41
  44. package/commonjs/steps/getTimeToNextUpdate.js.map +1 -1
  45. package/commonjs/steps/getTimeToNextUpdate.test.js +29 -25
  46. package/commonjs/steps/getTimeToNextUpdate.test.js.map +1 -1
  47. package/commonjs/steps/getTimeToNextUpdateForUnit.js +3 -12
  48. package/commonjs/steps/getTimeToNextUpdateForUnit.js.map +1 -1
  49. package/commonjs/steps/getTimeToNextUpdateForUnit.test.js +1 -7
  50. package/commonjs/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
  51. package/commonjs/steps/helpers.js +1 -2
  52. package/commonjs/steps/helpers.js.map +1 -1
  53. package/commonjs/steps/helpers.test.js +0 -1
  54. package/commonjs/steps/helpers.test.js.map +1 -1
  55. package/commonjs/steps/index.js +1 -6
  56. package/commonjs/steps/index.js.map +1 -1
  57. package/commonjs/steps/renameLegacyProperties.js +6 -14
  58. package/commonjs/steps/renameLegacyProperties.js.map +1 -1
  59. package/commonjs/steps/renameLegacyProperties.test.js +1 -3
  60. package/commonjs/steps/renameLegacyProperties.test.js.map +1 -1
  61. package/commonjs/steps/round.js +1 -2
  62. package/commonjs/steps/round.js.map +1 -1
  63. package/commonjs/steps/round.test.js +1 -7
  64. package/commonjs/steps/round.test.js.map +1 -1
  65. package/commonjs/steps/units.js +10 -21
  66. package/commonjs/steps/units.js.map +1 -1
  67. package/commonjs/style/approximate.js +2 -6
  68. package/commonjs/style/approximate.js.map +1 -1
  69. package/commonjs/style/approximateTime.js +2 -6
  70. package/commonjs/style/approximateTime.js.map +1 -1
  71. package/commonjs/style/approximateTime.test.js +116 -75
  72. package/commonjs/style/approximateTime.test.js.map +1 -1
  73. package/commonjs/style/getStyleByName.js +3 -29
  74. package/commonjs/style/getStyleByName.js.map +1 -1
  75. package/commonjs/style/mini.js +9 -6
  76. package/commonjs/style/mini.js.map +1 -1
  77. package/commonjs/style/mini.test.js +15 -25
  78. package/commonjs/style/mini.test.js.map +1 -1
  79. package/commonjs/style/miniMinute.js +8 -13
  80. package/commonjs/style/miniMinute.js.map +1 -1
  81. package/commonjs/style/miniMinute.test.js +11 -17
  82. package/commonjs/style/miniMinute.test.js.map +1 -1
  83. package/commonjs/style/miniMinuteNow.js +8 -13
  84. package/commonjs/style/miniMinuteNow.js.map +1 -1
  85. package/commonjs/style/miniMinuteNow.test.js +11 -17
  86. package/commonjs/style/miniMinuteNow.test.js.map +1 -1
  87. package/commonjs/style/miniNow.js +8 -13
  88. package/commonjs/style/miniNow.js.map +1 -1
  89. package/commonjs/style/miniNow.test.js +11 -17
  90. package/commonjs/style/miniNow.test.js.map +1 -1
  91. package/commonjs/style/renameLegacyProperties.js +7 -13
  92. package/commonjs/style/renameLegacyProperties.js.map +1 -1
  93. package/commonjs/style/renameLegacyProperties.test.js +1 -4
  94. package/commonjs/style/renameLegacyProperties.test.js.map +1 -1
  95. package/commonjs/style/round.js +2 -6
  96. package/commonjs/style/round.js.map +1 -1
  97. package/commonjs/style/round.test.js +51 -67
  98. package/commonjs/style/round.test.js.map +1 -1
  99. package/commonjs/style/roundMinute.js +8 -13
  100. package/commonjs/style/roundMinute.js.map +1 -1
  101. package/commonjs/style/roundMinute.test.js +20 -27
  102. package/commonjs/style/roundMinute.test.js.map +1 -1
  103. package/commonjs/style/twitter.js +34 -38
  104. package/commonjs/style/twitter.js.map +1 -1
  105. package/commonjs/style/twitter.test.js +49 -55
  106. package/commonjs/style/twitter.test.js.map +1 -1
  107. package/commonjs/style/twitterFirstMinute.js +10 -15
  108. package/commonjs/style/twitterFirstMinute.js.map +1 -1
  109. package/commonjs/style/twitterFirstMinute.test.js +16 -23
  110. package/commonjs/style/twitterFirstMinute.test.js.map +1 -1
  111. package/commonjs/style/twitterMinute.js +8 -13
  112. package/commonjs/style/twitterMinute.js.map +1 -1
  113. package/commonjs/style/twitterMinute.test.js +20 -25
  114. package/commonjs/style/twitterMinute.test.js.map +1 -1
  115. package/commonjs/style/twitterMinuteNow.js +8 -13
  116. package/commonjs/style/twitterMinuteNow.js.map +1 -1
  117. package/commonjs/style/twitterMinuteNow.test.js +20 -25
  118. package/commonjs/style/twitterMinuteNow.test.js.map +1 -1
  119. package/commonjs/style/twitterNow.js +8 -13
  120. package/commonjs/style/twitterNow.js.map +1 -1
  121. package/commonjs/style/twitterNow.test.js +18 -24
  122. package/commonjs/style/twitterNow.test.js.map +1 -1
  123. package/load-all-locales/index.cjs +32 -0
  124. package/load-all-locales/index.cjs.js +32 -0
  125. package/load-all-locales/index.js +64 -0
  126. package/locale/ak/package.json +16 -0
  127. package/locale/ak.json +267 -0
  128. package/locale/ak.json.d.ts +4 -0
  129. package/locale/ak.json.js +267 -0
  130. package/locale/bal-Latn/package.json +16 -0
  131. package/locale/bal-Latn.json +240 -0
  132. package/locale/bal-Latn.json.d.ts +4 -0
  133. package/locale/bal-Latn.json.js +240 -0
  134. package/locale/be-tarask/package.json +16 -0
  135. package/locale/be-tarask.json +259 -0
  136. package/locale/be-tarask.json.d.ts +4 -0
  137. package/locale/be-tarask.json.js +259 -0
  138. package/locale/blo/package.json +16 -0
  139. package/locale/blo.json +159 -0
  140. package/locale/blo.json.d.ts +4 -0
  141. package/locale/blo.json.js +159 -0
  142. package/locale/bn.json +5 -2
  143. package/locale/bn.json.js +5 -2
  144. package/locale/bs.json +8 -2
  145. package/locale/bs.json.js +8 -2
  146. package/locale/ccp.json +2 -8
  147. package/locale/ccp.json.js +2 -8
  148. package/locale/csw/package.json +16 -0
  149. package/locale/csw.json +180 -0
  150. package/locale/csw.json.d.ts +4 -0
  151. package/locale/csw.json.js +180 -0
  152. package/locale/cy.json +6 -12
  153. package/locale/cy.json.js +6 -12
  154. package/locale/doi/package.json +16 -0
  155. package/locale/doi.json +159 -0
  156. package/locale/doi.json.d.ts +4 -0
  157. package/locale/doi.json.js +159 -0
  158. package/locale/en-AU.json +12 -12
  159. package/locale/en-AU.json.js +12 -12
  160. package/locale/en-CZ/package.json +16 -0
  161. package/locale/en-CZ.json +219 -0
  162. package/locale/en-CZ.json.d.ts +4 -0
  163. package/locale/en-CZ.json.js +219 -0
  164. package/locale/en-ES/package.json +16 -0
  165. package/locale/en-ES.json +219 -0
  166. package/locale/en-ES.json.d.ts +4 -0
  167. package/locale/en-ES.json.js +219 -0
  168. package/locale/en-FR/package.json +16 -0
  169. package/locale/en-FR.json +219 -0
  170. package/locale/en-FR.json.d.ts +4 -0
  171. package/locale/en-FR.json.js +219 -0
  172. package/locale/en-GS/package.json +16 -0
  173. package/locale/en-GS.json +219 -0
  174. package/locale/en-GS.json.d.ts +4 -0
  175. package/locale/en-GS.json.js +219 -0
  176. package/locale/en-HU/package.json +16 -0
  177. package/locale/en-HU.json +219 -0
  178. package/locale/en-HU.json.d.ts +4 -0
  179. package/locale/en-HU.json.js +219 -0
  180. package/locale/en-ID/package.json +16 -0
  181. package/locale/en-ID.json +219 -0
  182. package/locale/en-ID.json.d.ts +4 -0
  183. package/locale/en-ID.json.js +219 -0
  184. package/locale/en-IT/package.json +16 -0
  185. package/locale/en-IT.json +219 -0
  186. package/locale/en-IT.json.d.ts +4 -0
  187. package/locale/en-IT.json.js +219 -0
  188. package/locale/en-NO/package.json +16 -0
  189. package/locale/en-NO.json +219 -0
  190. package/locale/en-NO.json.d.ts +4 -0
  191. package/locale/en-NO.json.js +219 -0
  192. package/locale/en-PL/package.json +16 -0
  193. package/locale/en-PL.json +219 -0
  194. package/locale/en-PL.json.d.ts +4 -0
  195. package/locale/en-PL.json.js +219 -0
  196. package/locale/en-PT/package.json +16 -0
  197. package/locale/en-PT.json +219 -0
  198. package/locale/en-PT.json.d.ts +4 -0
  199. package/locale/en-PT.json.js +219 -0
  200. package/locale/en-RO/package.json +16 -0
  201. package/locale/en-RO.json +219 -0
  202. package/locale/en-RO.json.d.ts +4 -0
  203. package/locale/en-RO.json.js +219 -0
  204. package/locale/en-SK/package.json +16 -0
  205. package/locale/en-SK.json +219 -0
  206. package/locale/en-SK.json.d.ts +4 -0
  207. package/locale/en-SK.json.js +219 -0
  208. package/locale/es-MX.json +12 -9
  209. package/locale/es-MX.json.js +12 -9
  210. package/locale/es-SV.json +2 -2
  211. package/locale/es-SV.json.js +2 -2
  212. package/locale/eu.json +24 -24
  213. package/locale/eu.json.js +24 -24
  214. package/locale/ha.json +119 -65
  215. package/locale/ha.json.js +119 -65
  216. package/locale/he.json +0 -6
  217. package/locale/he.json.js +0 -6
  218. package/locale/hi-Latn.json +2 -2
  219. package/locale/hi-Latn.json.js +2 -2
  220. package/locale/ht/package.json +16 -0
  221. package/locale/ht.json +207 -0
  222. package/locale/ht.json.d.ts +4 -0
  223. package/locale/ht.json.js +207 -0
  224. package/locale/id.json +1 -1
  225. package/locale/id.json.js +1 -1
  226. package/locale/ie/package.json +16 -0
  227. package/locale/ie.json +159 -0
  228. package/locale/ie.json.d.ts +4 -0
  229. package/locale/ie.json.js +159 -0
  230. package/locale/ig.json +17 -17
  231. package/locale/ig.json.js +17 -17
  232. package/locale/ii/package.json +16 -0
  233. package/locale/ii.json +165 -0
  234. package/locale/ii.json.d.ts +4 -0
  235. package/locale/ii.json.js +165 -0
  236. package/locale/is.json +4 -1
  237. package/locale/is.json.js +4 -1
  238. package/locale/kaa/package.json +16 -0
  239. package/locale/kaa.json +159 -0
  240. package/locale/kaa.json.d.ts +4 -0
  241. package/locale/kaa.json.js +159 -0
  242. package/locale/kok-Latn/package.json +16 -0
  243. package/locale/kok-Latn.json +159 -0
  244. package/locale/kok-Latn.json.d.ts +4 -0
  245. package/locale/kok-Latn.json.js +159 -0
  246. package/locale/kok.json +8 -8
  247. package/locale/kok.json.js +8 -8
  248. package/locale/ks.json +9 -9
  249. package/locale/ks.json.js +9 -9
  250. package/locale/ku.json +55 -46
  251. package/locale/ku.json.js +55 -46
  252. package/locale/lld/package.json +16 -0
  253. package/locale/lld.json +291 -0
  254. package/locale/lld.json.d.ts +4 -0
  255. package/locale/lld.json.js +291 -0
  256. package/locale/mi.json +22 -22
  257. package/locale/mi.json.js +22 -22
  258. package/locale/ms-Arab/package.json +16 -0
  259. package/locale/ms-Arab.json +159 -0
  260. package/locale/ms-Arab.json.d.ts +4 -0
  261. package/locale/ms-Arab.json.js +159 -0
  262. package/locale/nb.json +2 -2
  263. package/locale/nb.json.js +2 -2
  264. package/locale/ne.json +1 -1
  265. package/locale/ne.json.js +1 -1
  266. package/locale/nn.json +4 -4
  267. package/locale/nn.json.js +4 -4
  268. package/locale/no.json +2 -2
  269. package/locale/no.json.js +2 -2
  270. package/locale/nqo/package.json +16 -0
  271. package/locale/nqo.json +159 -0
  272. package/locale/nqo.json.d.ts +4 -0
  273. package/locale/nqo.json.js +159 -0
  274. package/locale/om/package.json +16 -0
  275. package/locale/om.json +213 -0
  276. package/locale/om.json.d.ts +4 -0
  277. package/locale/om.json.js +213 -0
  278. package/locale/or.json +1 -1
  279. package/locale/or.json.js +1 -1
  280. package/locale/pl.json +59 -0
  281. package/locale/pl.json.js +59 -0
  282. package/locale/qu.json +46 -46
  283. package/locale/qu.json.js +46 -46
  284. package/locale/rhg/package.json +16 -0
  285. package/locale/rhg.json +159 -0
  286. package/locale/rhg.json.d.ts +4 -0
  287. package/locale/rhg.json.js +159 -0
  288. package/locale/sl.json +12 -12
  289. package/locale/sl.json.js +12 -12
  290. package/locale/sr-Cyrl-BA.json +2 -2
  291. package/locale/sr-Cyrl-BA.json.js +2 -2
  292. package/locale/sr-Latn-BA.json +2 -2
  293. package/locale/sr-Latn-BA.json.js +2 -2
  294. package/locale/sv.json +1 -1
  295. package/locale/sv.json.js +1 -1
  296. package/locale/syr/package.json +16 -0
  297. package/locale/syr.json +303 -0
  298. package/locale/syr.json.d.ts +4 -0
  299. package/locale/syr.json.js +303 -0
  300. package/locale/ti.json +6 -6
  301. package/locale/ti.json.js +6 -6
  302. package/locale/tn/package.json +16 -0
  303. package/locale/tn.json +159 -0
  304. package/locale/tn.json.d.ts +4 -0
  305. package/locale/tn.json.js +159 -0
  306. package/locale/to.json +26 -26
  307. package/locale/to.json.js +26 -26
  308. package/locale/uk.json +1 -1
  309. package/locale/uk.json.js +1 -1
  310. package/locale/ur-IN.json +9 -6
  311. package/locale/ur-IN.json.js +9 -6
  312. package/locale/vec/package.json +16 -0
  313. package/locale/vec.json +267 -0
  314. package/locale/vec.json.d.ts +4 -0
  315. package/locale/vec.json.js +267 -0
  316. package/locale/xnr/package.json +16 -0
  317. package/locale/xnr.json +159 -0
  318. package/locale/xnr.json.d.ts +4 -0
  319. package/locale/xnr.json.js +159 -0
  320. package/locale/yo-BJ.json +17 -17
  321. package/locale/yo-BJ.json.js +17 -17
  322. package/locale/yo.json +17 -17
  323. package/locale/yo.json.js +17 -17
  324. package/locale-more-styles/pl/long-time.json +30 -0
  325. package/locale-more-styles/pl/mini.json +9 -0
  326. package/locale-more-styles/pl/now.json +7 -0
  327. package/locale-more-styles/pl/short-time.json +12 -0
  328. package/modules/LocaleDataStore.js +2 -3
  329. package/modules/LocaleDataStore.js.map +1 -1
  330. package/modules/PropTypes.js +11 -7
  331. package/modules/PropTypes.js.map +1 -1
  332. package/modules/TimeAgo.js +135 -174
  333. package/modules/TimeAgo.js.map +1 -1
  334. package/modules/TimeAgo.test.js +126 -115
  335. package/modules/TimeAgo.test.js.map +1 -1
  336. package/modules/cache.js +6 -22
  337. package/modules/cache.js.map +1 -1
  338. package/modules/cache.test.js.map +1 -1
  339. package/modules/isStyleObject.js +9 -7
  340. package/modules/isStyleObject.js.map +1 -1
  341. package/modules/isStyleObject.test.js.map +1 -1
  342. package/modules/locale.js +6 -16
  343. package/modules/locale.js.map +1 -1
  344. package/modules/locale.test.js +0 -4
  345. package/modules/locale.test.js.map +1 -1
  346. package/modules/round.js +2 -3
  347. package/modules/round.js.map +1 -1
  348. package/modules/steps/approximate.js +6 -2
  349. package/modules/steps/approximate.js.map +1 -1
  350. package/modules/steps/approximate.test.js +0 -2
  351. package/modules/steps/approximate.test.js.map +1 -1
  352. package/modules/steps/getStep.js +36 -48
  353. package/modules/steps/getStep.js.map +1 -1
  354. package/modules/steps/getStep.test.js +6 -2
  355. package/modules/steps/getStep.test.js.map +1 -1
  356. package/modules/steps/getStepDenominator.js +2 -3
  357. package/modules/steps/getStepDenominator.js.map +1 -1
  358. package/modules/steps/getStepDenominator.test.js.map +1 -1
  359. package/modules/steps/getStepMinTime.js +17 -29
  360. package/modules/steps/getStepMinTime.js.map +1 -1
  361. package/modules/steps/getStepMinTime.test.js.map +1 -1
  362. package/modules/steps/getTimeToNextUpdate.js +19 -31
  363. package/modules/steps/getTimeToNextUpdate.js.map +1 -1
  364. package/modules/steps/getTimeToNextUpdate.test.js +27 -18
  365. package/modules/steps/getTimeToNextUpdate.test.js.map +1 -1
  366. package/modules/steps/getTimeToNextUpdateForUnit.js +4 -10
  367. package/modules/steps/getTimeToNextUpdateForUnit.js.map +1 -1
  368. package/modules/steps/getTimeToNextUpdateForUnit.test.js +0 -4
  369. package/modules/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
  370. package/modules/steps/helpers.js +1 -1
  371. package/modules/steps/helpers.js.map +1 -1
  372. package/modules/steps/helpers.test.js.map +1 -1
  373. package/modules/steps/index.js +2 -1
  374. package/modules/steps/index.js.map +1 -1
  375. package/modules/steps/renameLegacyProperties.js +6 -13
  376. package/modules/steps/renameLegacyProperties.js.map +1 -1
  377. package/modules/steps/renameLegacyProperties.test.js.map +1 -1
  378. package/modules/steps/round.js.map +1 -1
  379. package/modules/steps/round.test.js +0 -3
  380. package/modules/steps/round.test.js.map +1 -1
  381. package/modules/steps/units.js +5 -9
  382. package/modules/steps/units.js.map +1 -1
  383. package/modules/style/approximate.js +5 -1
  384. package/modules/style/approximate.js.map +1 -1
  385. package/modules/style/approximateTime.js +6 -2
  386. package/modules/style/approximateTime.js.map +1 -1
  387. package/modules/style/approximateTime.test.js +115 -70
  388. package/modules/style/approximateTime.test.js.map +1 -1
  389. package/modules/style/getStyleByName.js +4 -17
  390. package/modules/style/getStyleByName.js.map +1 -1
  391. package/modules/style/mini.js +8 -4
  392. package/modules/style/mini.js.map +1 -1
  393. package/modules/style/mini.test.js +14 -20
  394. package/modules/style/mini.test.js.map +1 -1
  395. package/modules/style/miniMinute.js +6 -6
  396. package/modules/style/miniMinute.js.map +1 -1
  397. package/modules/style/miniMinute.test.js +10 -12
  398. package/modules/style/miniMinute.test.js.map +1 -1
  399. package/modules/style/miniMinuteNow.js +6 -6
  400. package/modules/style/miniMinuteNow.js.map +1 -1
  401. package/modules/style/miniMinuteNow.test.js +10 -12
  402. package/modules/style/miniMinuteNow.test.js.map +1 -1
  403. package/modules/style/miniNow.js +6 -6
  404. package/modules/style/miniNow.js.map +1 -1
  405. package/modules/style/miniNow.test.js +10 -12
  406. package/modules/style/miniNow.test.js.map +1 -1
  407. package/modules/style/renameLegacyProperties.js +8 -10
  408. package/modules/style/renameLegacyProperties.js.map +1 -1
  409. package/modules/style/renameLegacyProperties.test.js +0 -1
  410. package/modules/style/renameLegacyProperties.test.js.map +1 -1
  411. package/modules/style/round.js +3 -2
  412. package/modules/style/round.js.map +1 -1
  413. package/modules/style/round.test.js +50 -62
  414. package/modules/style/round.test.js.map +1 -1
  415. package/modules/style/roundMinute.js +8 -7
  416. package/modules/style/roundMinute.js.map +1 -1
  417. package/modules/style/roundMinute.test.js +19 -22
  418. package/modules/style/roundMinute.test.js.map +1 -1
  419. package/modules/style/twitter.js +35 -32
  420. package/modules/style/twitter.js.map +1 -1
  421. package/modules/style/twitter.test.js +48 -50
  422. package/modules/style/twitter.test.js.map +1 -1
  423. package/modules/style/twitterFirstMinute.js +8 -7
  424. package/modules/style/twitterFirstMinute.js.map +1 -1
  425. package/modules/style/twitterFirstMinute.test.js +15 -18
  426. package/modules/style/twitterFirstMinute.test.js.map +1 -1
  427. package/modules/style/twitterMinute.js +6 -6
  428. package/modules/style/twitterMinute.js.map +1 -1
  429. package/modules/style/twitterMinute.test.js +19 -20
  430. package/modules/style/twitterMinute.test.js.map +1 -1
  431. package/modules/style/twitterMinuteNow.js +6 -6
  432. package/modules/style/twitterMinuteNow.js.map +1 -1
  433. package/modules/style/twitterMinuteNow.test.js +19 -20
  434. package/modules/style/twitterMinuteNow.test.js.map +1 -1
  435. package/modules/style/twitterNow.js +6 -6
  436. package/modules/style/twitterNow.js.map +1 -1
  437. package/modules/style/twitterNow.test.js +17 -19
  438. package/modules/style/twitterNow.test.js.map +1 -1
  439. package/package.json +261 -4
@@ -1,25 +1,16 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
-
3
- function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
-
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
7
4
  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."); }
8
-
9
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
-
11
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
12
-
13
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
14
-
15
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
-
17
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
-
19
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
20
-
21
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
22
-
5
+ 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; } }
6
+ 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; }
7
+ 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; } }
8
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
9
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
10
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
11
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
13
+ 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); }
23
14
  import RelativeTimeFormatPolyfill from 'relative-time-format';
24
15
  import Cache from './cache.js';
25
16
  import chooseLocale from './locale.js';
@@ -30,11 +21,12 @@ import getTimeToNextUpdate from './steps/getTimeToNextUpdate.js';
30
21
  import { addLocaleData, getLocaleData } from './LocaleDataStore.js';
31
22
  import defaultStyle from './style/roundMinute.js';
32
23
  import getStyleByName from './style/getStyleByName.js';
33
- import { getRoundFunction } from './round.js'; // Valid time units.
24
+ import { getRoundFunction } from './round.js';
34
25
 
35
- var UNITS = ['now', // The rest are the same as in `Intl.RelativeTimeFormat`.
26
+ // Valid time units.
27
+ var UNITS = ['now',
28
+ // The rest are the same as in `Intl.RelativeTimeFormat`.
36
29
  'second', 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'];
37
-
38
30
  var TimeAgo = /*#__PURE__*/function () {
39
31
  /**
40
32
  * @param {(string|string[])} locales=[] - Preferred locales (or locale).
@@ -42,46 +34,44 @@ var TimeAgo = /*#__PURE__*/function () {
42
34
  */
43
35
  function TimeAgo() {
44
36
  var locales = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
45
-
46
37
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
47
- polyfill = _ref.polyfill;
48
-
38
+ polyfill = _ref.polyfill;
49
39
  _classCallCheck(this, TimeAgo);
50
-
51
40
  // Convert `locales` to an array.
52
41
  if (typeof locales === 'string') {
53
42
  locales = [locales];
54
- } // Choose the most appropriate locale
43
+ }
44
+
45
+ // Choose the most appropriate locale
55
46
  // from the list of `locales` added by the user.
56
47
  // For example, new TimeAgo("en-US") -> "en".
57
-
58
-
59
48
  this.locale = chooseLocale(locales.concat(TimeAgo.getDefaultLocale()), getLocaleData);
60
-
61
49
  if (typeof Intl !== 'undefined') {
62
50
  // Use `Intl.NumberFormat` for formatting numbers (when available).
63
51
  if (Intl.NumberFormat) {
64
52
  this.numberFormat = new Intl.NumberFormat(this.locale);
65
53
  }
66
- } // Some people have requested the ability to use native
54
+ }
55
+
56
+ // Some people have requested the ability to use native
67
57
  // `Intl.RelativeTimeFormat` and `Intl.PluralRules`
68
58
  // instead of the polyfills.
69
59
  // https://github.com/catamphetamine/javascript-time-ago/issues/21
70
-
71
-
72
60
  if (polyfill === false) {
73
61
  this.IntlRelativeTimeFormat = Intl.RelativeTimeFormat;
74
62
  this.IntlPluralRules = Intl.PluralRules;
75
63
  } else {
76
64
  this.IntlRelativeTimeFormat = RelativeTimeFormatPolyfill;
77
65
  this.IntlPluralRules = RelativeTimeFormatPolyfill.PluralRules;
78
- } // Cache `Intl.RelativeTimeFormat` instance.
79
-
66
+ }
80
67
 
81
- this.relativeTimeFormatCache = new Cache(); // Cache `Intl.PluralRules` instance.
68
+ // Cache `Intl.RelativeTimeFormat` instance.
69
+ this.relativeTimeFormatCache = new Cache();
82
70
 
71
+ // Cache `Intl.PluralRules` instance.
83
72
  this.pluralRulesCache = new Cache();
84
73
  }
74
+
85
75
  /**
86
76
  * Formats relative date/time.
87
77
  *
@@ -103,8 +93,6 @@ var TimeAgo = /*#__PURE__*/function () {
103
93
  *
104
94
  * @return {string} The formatted relative date/time. If no eligible `step` is found, then an empty string is returned.
105
95
  */
106
-
107
-
108
96
  _createClass(TimeAgo, [{
109
97
  key: "format",
110
98
  value: function format(input, style, options) {
@@ -116,45 +104,42 @@ var TimeAgo = /*#__PURE__*/function () {
116
104
  options = {};
117
105
  }
118
106
  }
119
-
120
107
  if (!style) {
121
108
  style = defaultStyle;
122
109
  }
123
-
124
110
  if (typeof style === 'string') {
125
111
  style = getStyleByName(style);
126
112
  }
113
+ var timestamp = getTimestamp(input);
127
114
 
128
- var timestamp = getTimestamp(input); // Get locale messages for this type of labels.
115
+ // Get locale messages for this type of labels.
129
116
  // "flavour" is a legacy name for "labels".
130
-
131
117
  var _this$getLabels = this.getLabels(style.flavour || style.labels),
132
- labels = _this$getLabels.labels,
133
- labelsType = _this$getLabels.labelsType;
134
-
135
- var now; // Can pass a custom `now`, e.g. for testing purposes.
118
+ labels = _this$getLabels.labels,
119
+ labelsType = _this$getLabels.labelsType;
120
+ var now;
121
+ // Can pass a custom `now`, e.g. for testing purposes.
136
122
  //
137
123
  // Legacy way was passing `now` in `style`.
138
124
  // That way is deprecated.
139
-
140
125
  if (style.now !== undefined) {
141
126
  now = style.now;
142
- } // The new way is passing `now` option to `.format()`.
143
-
144
-
127
+ }
128
+ // The new way is passing `now` option to `.format()`.
145
129
  if (now === undefined && options.now !== undefined) {
146
130
  now = options.now;
147
131
  }
148
-
149
132
  if (now === undefined) {
150
133
  now = Date.now();
151
- } // how much time has passed (in seconds)
152
-
134
+ }
153
135
 
136
+ // how much time has passed (in seconds)
154
137
  var secondsPassed = (now - timestamp) / 1000; // in seconds
155
138
 
156
139
  var future = options.future || secondsPassed < 0;
157
- var nowLabel = getNowLabel(labels, getLocaleData(this.locale).now, getLocaleData(this.locale)["long"], future); // `custom` – A function of `{ elapsed, time, date, now, locale }`.
140
+ var nowLabel = getNowLabel(labels, getLocaleData(this.locale).now, getLocaleData(this.locale)["long"], future);
141
+
142
+ // `custom` – A function of `{ elapsed, time, date, now, locale }`.
158
143
  //
159
144
  // Looks like `custom` function is deprecated and will be removed
160
145
  // in the next major version.
@@ -166,7 +151,6 @@ var TimeAgo = /*#__PURE__*/function () {
166
151
  // in case anyone would ever need that. Prefer using
167
152
  // `steps[step].format(value, locale)` instead.
168
153
  //
169
-
170
154
  if (style.custom) {
171
155
  var custom = style.custom({
172
156
  now: now,
@@ -175,41 +159,44 @@ var TimeAgo = /*#__PURE__*/function () {
175
159
  elapsed: secondsPassed,
176
160
  locale: this.locale
177
161
  });
178
-
179
162
  if (custom !== undefined) {
180
163
  // Won't return `timeToNextUpdate` here
181
164
  // because `custom()` seems deprecated.
182
165
  return custom;
183
166
  }
184
- } // Get the list of available time interval units.
185
-
167
+ }
186
168
 
187
- var units = getTimeIntervalMeasurementUnits( // Controlling `style.steps` through `style.units` seems to be deprecated:
169
+ // Get the list of available time interval units.
170
+ var units = getTimeIntervalMeasurementUnits(
171
+ // Controlling `style.steps` through `style.units` seems to be deprecated:
188
172
  // create a new custom `style` instead.
189
- style.units, labels, nowLabel); // // If no available time unit is suitable, just output an empty string.
173
+ style.units, labels, nowLabel);
174
+
175
+ // // If no available time unit is suitable, just output an empty string.
190
176
  // if (units.length === 0) {
191
177
  // console.error(`None of the "${units.join(', ')}" time units have been found in "${labelsType}" labels for "${this.locale}" locale.`)
192
178
  // return ''
193
179
  // }
194
180
 
195
- var round = options.round || style.round; // Choose the appropriate time measurement unit
196
- // and get the corresponding rounded time amount.
197
-
198
- var _getStep = getStep( // "gradation" is a legacy name for "steps".
199
- // For historical reasons, "approximate" steps are used by default.
200
- // In the next major version, there'll be no default for `steps`.
201
- style.gradation || style.steps || defaultStyle.steps, secondsPassed, {
202
- now: now,
203
- units: units,
204
- round: round,
205
- future: future,
206
- getNextStep: true
207
- }),
208
- _getStep2 = _slicedToArray(_getStep, 3),
209
- prevStep = _getStep2[0],
210
- step = _getStep2[1],
211
- nextStep = _getStep2[2];
181
+ var round = options.round || style.round;
212
182
 
183
+ // Choose the appropriate time measurement unit
184
+ // and get the corresponding rounded time amount.
185
+ var _getStep = getStep(
186
+ // "gradation" is a legacy name for "steps".
187
+ // For historical reasons, "approximate" steps are used by default.
188
+ // In the next major version, there'll be no default for `steps`.
189
+ style.gradation || style.steps || defaultStyle.steps, secondsPassed, {
190
+ now: now,
191
+ units: units,
192
+ round: round,
193
+ future: future,
194
+ getNextStep: true
195
+ }),
196
+ _getStep2 = _slicedToArray(_getStep, 3),
197
+ prevStep = _getStep2[0],
198
+ step = _getStep2[1],
199
+ nextStep = _getStep2[2];
213
200
  var formattedDate = this.formatDateForStep(timestamp, step, secondsPassed, {
214
201
  labels: labels,
215
202
  labelsType: labelsType,
@@ -218,7 +205,6 @@ var TimeAgo = /*#__PURE__*/function () {
218
205
  future: future,
219
206
  round: round
220
207
  }) || '';
221
-
222
208
  if (options.getTimeToNextUpdate) {
223
209
  var timeToNextUpdate = getTimeToNextUpdate(timestamp, step, {
224
210
  nextStep: nextStep,
@@ -229,26 +215,22 @@ var TimeAgo = /*#__PURE__*/function () {
229
215
  });
230
216
  return [formattedDate, timeToNextUpdate];
231
217
  }
232
-
233
218
  return formattedDate;
234
219
  }
235
220
  }, {
236
221
  key: "formatDateForStep",
237
222
  value: function formatDateForStep(timestamp, step, secondsPassed, _ref2) {
238
223
  var _this = this;
239
-
240
224
  var labels = _ref2.labels,
241
- labelsType = _ref2.labelsType,
242
- nowLabel = _ref2.nowLabel,
243
- now = _ref2.now,
244
- future = _ref2.future,
245
- round = _ref2.round;
246
-
225
+ labelsType = _ref2.labelsType,
226
+ nowLabel = _ref2.nowLabel,
227
+ now = _ref2.now,
228
+ future = _ref2.future,
229
+ round = _ref2.round;
247
230
  // If no step matches, then output an empty string.
248
231
  if (!step) {
249
232
  return;
250
233
  }
251
-
252
234
  if (step.format) {
253
235
  return step.format(timestamp, this.locale, {
254
236
  formatAs: function formatAs(unit, value) {
@@ -261,23 +243,24 @@ var TimeAgo = /*#__PURE__*/function () {
261
243
  now: now,
262
244
  future: future
263
245
  });
264
- } // "unit" is now called "formatAs".
265
-
246
+ }
266
247
 
248
+ // "unit" is now called "formatAs".
267
249
  var unit = step.unit || step.formatAs;
268
-
269
250
  if (!unit) {
270
251
  throw new Error("[javascript-time-ago] Each step must define either `formatAs` or `format()`. Step: ".concat(JSON.stringify(step)));
271
- } // `Intl.RelativeTimeFormat` doesn't operate in "now" units.
272
- // Therefore, threat "now" as a special case.
273
-
252
+ }
274
253
 
254
+ // `Intl.RelativeTimeFormat` doesn't operate in "now" units.
255
+ // Therefore, threat "now" as a special case.
275
256
  if (unit === 'now') {
276
257
  return nowLabel;
277
- } // Amount in units.
258
+ }
278
259
 
260
+ // Amount in units.
261
+ var amount = Math.abs(secondsPassed) / getStepDenominator(step);
279
262
 
280
- var amount = Math.abs(secondsPassed) / getStepDenominator(step); // Apply granularity to the time amount
263
+ // Apply granularity to the time amount
281
264
  // (and fallback to the previous step
282
265
  // if the first level of granularity
283
266
  // isn't met by this amount)
@@ -288,19 +271,18 @@ var TimeAgo = /*#__PURE__*/function () {
288
271
  // Perhaps this feature will be removed because there seem to be no use cases
289
272
  // of it in the real world.
290
273
  //
291
-
292
274
  if (step.granularity) {
293
275
  // Recalculate the amount of seconds passed based on granularity
294
276
  amount = getRoundFunction(round)(amount / step.granularity) * step.granularity;
295
277
  }
278
+ var valueForFormatting = -1 * Math.sign(secondsPassed) * getRoundFunction(round)(amount);
296
279
 
297
- var valueForFormatting = -1 * Math.sign(secondsPassed) * getRoundFunction(round)(amount); // By default, this library formats a `0` in "past" mode,
280
+ // By default, this library formats a `0` in "past" mode,
298
281
  // unless `future: true` option is passed.
299
282
  // This is different to `relative-time-format`'s behavior
300
283
  // which formats a `0` in "future" mode by default, unless it's a `-0`.
301
284
  // So, convert `0` to `-0` if `future: true` option wasn't passed.
302
285
  // `=== 0` matches both `0` and `-0`.
303
-
304
286
  if (valueForFormatting === 0) {
305
287
  if (future) {
306
288
  valueForFormatting = 0;
@@ -308,14 +290,12 @@ var TimeAgo = /*#__PURE__*/function () {
308
290
  valueForFormatting = -0;
309
291
  }
310
292
  }
311
-
312
293
  switch (labelsType) {
313
294
  case 'long':
314
295
  case 'short':
315
296
  case 'narrow':
316
297
  // Format the amount using `Intl.RelativeTimeFormat`.
317
298
  return this.getFormatter(labelsType).format(valueForFormatting, unit);
318
-
319
299
  default:
320
300
  // Format the amount.
321
301
  // (mimicks `Intl.RelativeTimeFormat` behavior for other time label styles)
@@ -325,6 +305,7 @@ var TimeAgo = /*#__PURE__*/function () {
325
305
  });
326
306
  }
327
307
  }
308
+
328
309
  /**
329
310
  * Mimicks what `Intl.RelativeTimeFormat` does for additional locale styles.
330
311
  * @param {number} value
@@ -333,16 +314,16 @@ var TimeAgo = /*#__PURE__*/function () {
333
314
  * @param {boolean} [options.future] — Tells how to format value `0`: as "future" (`true`) or "past" (`false`). Is `false` by default, but should have been `true` actually.
334
315
  * @return {string}
335
316
  */
336
-
337
317
  }, {
338
318
  key: "formatValue",
339
319
  value: function formatValue(value, unit, _ref3) {
340
320
  var labels = _ref3.labels,
341
- future = _ref3.future;
321
+ future = _ref3.future;
342
322
  return this.getFormattingRule(labels, unit, value, {
343
323
  future: future
344
324
  }).replace('{0}', this.formatNumber(Math.abs(value)));
345
325
  }
326
+
346
327
  /**
347
328
  * Returns formatting rule for `value` in `units` (either in past or in future).
348
329
  * @param {object} formattingRules — Relative time labels for different units.
@@ -354,7 +335,6 @@ var TimeAgo = /*#__PURE__*/function () {
354
335
  * // Returns "{0} days ago"
355
336
  * getFormattingRule(en.long, "day", -2, 'en')
356
337
  */
357
-
358
338
  }, {
359
339
  key: "getFormattingRule",
360
340
  value: function getFormattingRule(formattingRules, unit, value, _ref4) {
@@ -362,49 +342,47 @@ var TimeAgo = /*#__PURE__*/function () {
362
342
  // Passing the language is required in order to
363
343
  // be able to correctly classify the `value` as a number.
364
344
  var locale = this.locale;
365
- formattingRules = formattingRules[unit]; // Check for a special "compacted" rules case:
345
+ formattingRules = formattingRules[unit];
346
+ // Check for a special "compacted" rules case:
366
347
  // if formatting rules are the same for "past" and "future",
367
348
  // and also for all possible `value`s, then those rules are
368
349
  // stored as a single string.
369
-
370
350
  if (typeof formattingRules === 'string') {
371
351
  return formattingRules;
372
- } // Choose either "past" or "future" based on time `value` sign.
352
+ }
353
+ // Choose either "past" or "future" based on time `value` sign.
373
354
  // If "past" is same as "future" then they're stored as "other".
374
355
  // If there's only "other" then it's being collapsed.
375
-
376
-
377
356
  var pastOrFuture = value === 0 ? future ? 'future' : 'past' : value < 0 ? 'past' : 'future';
378
- var quantifierRules = formattingRules[pastOrFuture] || formattingRules; // Bundle size optimization technique.
379
-
357
+ var quantifierRules = formattingRules[pastOrFuture] || formattingRules;
358
+ // Bundle size optimization technique.
380
359
  if (typeof quantifierRules === 'string') {
381
360
  return quantifierRules;
382
- } // Quantify `value`.
383
-
384
-
385
- var quantifier = this.getPluralRules().select(Math.abs(value)); // "other" rule is supposed to always be present.
361
+ }
362
+ // Quantify `value`.
363
+ var quantifier = this.getPluralRules().select(Math.abs(value));
364
+ // "other" rule is supposed to always be present.
386
365
  // If only "other" rule is present then "rules" is not an object and is a string.
387
-
388
366
  return quantifierRules[quantifier] || quantifierRules.other;
389
367
  }
368
+
390
369
  /**
391
370
  * Formats a number into a string.
392
371
  * Uses `Intl.NumberFormat` when available.
393
372
  * @param {number} number
394
373
  * @return {string}
395
374
  */
396
-
397
375
  }, {
398
376
  key: "formatNumber",
399
377
  value: function formatNumber(number) {
400
378
  return this.numberFormat ? this.numberFormat.format(number) : String(number);
401
379
  }
380
+
402
381
  /**
403
382
  * Returns an `Intl.RelativeTimeFormat` for a given `labelsType`.
404
383
  * @param {string} labelsType
405
384
  * @return {object} `Intl.RelativeTimeFormat` instance
406
385
  */
407
-
408
386
  }, {
409
387
  key: "getFormatter",
410
388
  value: function getFormatter(labelsType) {
@@ -414,11 +392,11 @@ var TimeAgo = /*#__PURE__*/function () {
414
392
  style: labelsType
415
393
  }));
416
394
  }
395
+
417
396
  /**
418
397
  * Returns an `Intl.PluralRules` instance.
419
398
  * @return {object} `Intl.PluralRules` instance
420
399
  */
421
-
422
400
  }, {
423
401
  key: "getPluralRules",
424
402
  value: function getPluralRules() {
@@ -426,6 +404,7 @@ var TimeAgo = /*#__PURE__*/function () {
426
404
  // a lengthy operation so the instances are cached and reused.
427
405
  return this.pluralRulesCache.get(this.locale) || this.pluralRulesCache.put(this.locale, new this.IntlPluralRules(this.locale));
428
406
  }
407
+
429
408
  /**
430
409
  * Gets localized labels for this type of labels.
431
410
  *
@@ -435,37 +414,34 @@ var TimeAgo = /*#__PURE__*/function () {
435
414
  *
436
415
  * @returns {Object} Returns an object of shape { labelsType, labels }
437
416
  */
438
-
439
417
  }, {
440
418
  key: "getLabels",
441
419
  value: function getLabels() {
442
420
  var labelsType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
443
-
444
421
  // Convert `labels` to an array.
445
422
  if (typeof labelsType === 'string') {
446
423
  labelsType = [labelsType];
447
- } // Supports legacy "tiny" and "mini-time" label styles.
448
-
424
+ }
449
425
 
426
+ // Supports legacy "tiny" and "mini-time" label styles.
450
427
  labelsType = labelsType.map(function (labelsType) {
451
428
  switch (labelsType) {
452
429
  case 'tiny':
453
430
  case 'mini-time':
454
431
  return 'mini';
455
-
456
432
  default:
457
433
  return labelsType;
458
434
  }
459
- }); // "long" labels type is the default one.
460
- // (it's always present for all languages)
435
+ });
461
436
 
462
- labelsType = labelsType.concat('long'); // Find a suitable labels type.
437
+ // "long" labels type is the default one.
438
+ // (it's always present for all languages)
439
+ labelsType = labelsType.concat('long');
463
440
 
441
+ // Find a suitable labels type.
464
442
  var localeData = getLocaleData(this.locale);
465
-
466
443
  for (var _iterator = _createForOfIteratorHelperLoose(labelsType), _step; !(_step = _iterator()).done;) {
467
444
  var _labelsType = _step.value;
468
-
469
445
  if (localeData[_labelsType]) {
470
446
  return {
471
447
  labelsType: _labelsType,
@@ -475,161 +451,146 @@ var TimeAgo = /*#__PURE__*/function () {
475
451
  }
476
452
  }
477
453
  }]);
478
-
479
454
  return TimeAgo;
480
455
  }();
481
456
  /**
482
457
  * Default locale global variable.
483
458
  */
484
-
485
-
486
459
  export { TimeAgo as default };
487
460
  var defaultLocale = 'en';
461
+
488
462
  /**
489
463
  * Gets default locale.
490
464
  * @return {string} locale
491
465
  */
492
-
493
466
  TimeAgo.getDefaultLocale = function () {
494
467
  return defaultLocale;
495
468
  };
469
+
496
470
  /**
497
471
  * Sets default locale.
498
472
  * @param {string} locale
499
473
  */
500
-
501
-
502
474
  TimeAgo.setDefaultLocale = function (locale) {
503
475
  return defaultLocale = locale;
504
476
  };
477
+
505
478
  /**
506
479
  * Adds locale data for a specific locale and marks the locale as default.
507
480
  * @param {Object} localeData
508
481
  */
509
-
510
-
511
482
  TimeAgo.addDefaultLocale = function (localeData) {
512
483
  if (defaultLocaleHasBeenSpecified) {
513
484
  return console.error('[javascript-time-ago] `TimeAgo.addDefaultLocale()` can only be called once. To add other locales, use `TimeAgo.addLocale()`.');
514
485
  }
515
-
516
486
  defaultLocaleHasBeenSpecified = true;
517
487
  TimeAgo.setDefaultLocale(localeData.locale);
518
488
  TimeAgo.addLocale(localeData);
519
489
  };
520
-
521
490
  var defaultLocaleHasBeenSpecified;
491
+
522
492
  /**
523
493
  * Adds locale data for a specific locale.
524
494
  * @param {Object} localeData
525
495
  */
526
-
527
496
  TimeAgo.addLocale = function (localeData) {
528
497
  addLocaleData(localeData);
529
498
  RelativeTimeFormatPolyfill.addLocale(localeData);
530
499
  };
500
+
531
501
  /**
532
502
  * (legacy alias)
533
503
  * Adds locale data for a specific locale.
534
504
  * @param {Object} localeData
535
505
  * @deprecated
536
506
  */
537
-
538
-
539
507
  TimeAgo.locale = TimeAgo.addLocale;
508
+
540
509
  /**
541
510
  * Adds custom labels to locale data.
542
511
  * @param {string} locale
543
512
  * @param {string} name
544
513
  * @param {object} labels
545
514
  */
546
-
547
515
  TimeAgo.addLabels = function (locale, name, labels) {
548
516
  var localeData = getLocaleData(locale);
549
-
550
517
  if (!localeData) {
551
518
  addLocaleData({
552
519
  locale: locale
553
520
  });
554
- localeData = getLocaleData(locale); // throw new Error(`[javascript-time-ago] No data for locale "${locale}"`)
521
+ localeData = getLocaleData(locale);
522
+ // throw new Error(`[javascript-time-ago] No data for locale "${locale}"`)
555
523
  }
556
-
557
524
  localeData[name] = labels;
558
- }; // Normalizes `.format()` `time` argument.
559
-
525
+ };
560
526
 
527
+ // Normalizes `.format()` `time` argument.
561
528
  function getTimestamp(input) {
562
529
  if (input.constructor === Date || isMockedDate(input)) {
563
530
  return input.getTime();
564
531
  }
565
-
566
532
  if (typeof input === 'number') {
567
533
  return input;
568
- } // For some weird reason istanbul doesn't see this `throw` covered.
534
+ }
569
535
 
536
+ // For some weird reason istanbul doesn't see this `throw` covered.
570
537
  /* istanbul ignore next */
571
-
572
-
573
538
  throw new Error("Unsupported relative time formatter input: ".concat(_typeof(input), ", ").concat(input));
574
- } // During testing via some testing libraries `Date`s aren't actually `Date`s.
575
- // https://github.com/catamphetamine/javascript-time-ago/issues/22
576
-
539
+ }
577
540
 
541
+ // During testing via some testing libraries `Date`s aren't actually `Date`s.
542
+ // https://github.com/catamphetamine/javascript-time-ago/issues/22
578
543
  function isMockedDate(object) {
579
544
  return _typeof(object) === 'object' && typeof object.getTime === 'function';
580
- } // Get available time interval measurement units.
581
-
545
+ }
582
546
 
547
+ // Get available time interval measurement units.
583
548
  function getTimeIntervalMeasurementUnits(allowedUnits, labels, nowLabel) {
584
549
  // Get all time interval measurement units that're available
585
550
  // in locale data for a given time labels style.
586
- var units = Object.keys(labels); // `now` unit is handled separately and is shipped in its own `now.json` file.
551
+ var units = Object.keys(labels);
552
+
553
+ // `now` unit is handled separately and is shipped in its own `now.json` file.
587
554
  // `now.json` isn't present for all locales, so it could be substituted with
588
555
  // ".second.current".
589
556
  // Add `now` unit if it's available in locale data.
590
-
591
557
  if (nowLabel) {
592
558
  units.push('now');
593
- } // If only a specific set of available time measurement units can be used
594
- // then only those units are allowed (if they're present in locale data).
595
-
559
+ }
596
560
 
561
+ // If only a specific set of available time measurement units can be used
562
+ // then only those units are allowed (if they're present in locale data).
597
563
  if (allowedUnits) {
598
564
  units = allowedUnits.filter(function (unit) {
599
565
  return unit === 'now' || units.indexOf(unit) >= 0;
600
566
  });
601
567
  }
602
-
603
568
  return units;
604
569
  }
605
-
606
570
  function getNowLabel(labels, nowLabels, longLabels, future) {
607
- var nowLabel = labels.now || nowLabels && nowLabels.now; // Specific "now" message form extended locale data (if present).
608
-
571
+ var nowLabel = labels.now || nowLabels && nowLabels.now;
572
+ // Specific "now" message form extended locale data (if present).
609
573
  if (nowLabel) {
610
574
  // Bundle size optimization technique.
611
575
  if (typeof nowLabel === 'string') {
612
576
  return nowLabel;
613
- } // Not handling `value === 0` as `localeData.now.current` here
577
+ }
578
+ // Not handling `value === 0` as `localeData.now.current` here
614
579
  // because it wouldn't make sense: "now" is a moment,
615
580
  // so one can't possibly differentiate between a
616
581
  // "previous" moment, a "current" moment and a "next moment".
617
582
  // It can only be differentiated between "past" and "future".
618
-
619
-
620
583
  if (future) {
621
584
  return nowLabel.future;
622
585
  } else {
623
586
  return nowLabel.past;
624
587
  }
625
- } // Use ".second.current" as "now" message.
626
-
627
-
588
+ }
589
+ // Use ".second.current" as "now" message.
628
590
  if (longLabels && longLabels.second && longLabels.second.current) {
629
591
  return longLabels.second.current;
630
592
  }
631
593
  }
632
-
633
594
  function isStyle(variable) {
634
595
  return typeof variable === 'string' || isStyleObject(variable);
635
596
  }