javascript-time-ago 2.5.11 → 2.5.12

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