javascript-time-ago 2.5.11 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -1
- package/README.md +410 -272
- package/bundle/javascript-time-ago.js +1 -1
- package/bundle/javascript-time-ago.js.map +1 -1
- package/bundle/javascript-time-ago.min.js +1 -1
- package/bundle/javascript-time-ago.min.js.map +1 -1
- package/commonjs/FullDateFormatter.js +72 -0
- package/commonjs/FullDateFormatter.js.map +1 -0
- package/commonjs/FullDateFormatter.test.js +26 -0
- package/commonjs/FullDateFormatter.test.js.map +1 -0
- package/commonjs/LocaleDataStore.js +2 -5
- package/commonjs/LocaleDataStore.js.map +1 -1
- package/commonjs/PropTypes.js +12 -12
- package/commonjs/PropTypes.js.map +1 -1
- package/commonjs/TimeAgo.js +300 -253
- package/commonjs/TimeAgo.js.map +1 -1
- package/commonjs/TimeAgo.test.js +214 -135
- package/commonjs/TimeAgo.test.js.map +1 -1
- package/commonjs/cache.js +7 -25
- package/commonjs/cache.js.map +1 -1
- package/commonjs/cache.test.js +1 -3
- package/commonjs/cache.test.js.map +1 -1
- package/commonjs/isStyleObject.js +9 -9
- package/commonjs/isStyleObject.js.map +1 -1
- package/commonjs/isStyleObject.test.js +1 -3
- package/commonjs/isStyleObject.test.js.map +1 -1
- package/commonjs/locale.js +6 -19
- package/commonjs/locale.js.map +1 -1
- package/commonjs/locale.test.js +2 -11
- package/commonjs/locale.test.js.map +1 -1
- package/commonjs/round.js +2 -5
- package/commonjs/round.js.map +1 -1
- package/commonjs/steps/approximate.js +1 -4
- package/commonjs/steps/approximate.js.map +1 -1
- package/commonjs/steps/approximate.test.js +1 -6
- package/commonjs/steps/approximate.test.js.map +1 -1
- package/commonjs/steps/getStep.js +36 -53
- package/commonjs/steps/getStep.js.map +1 -1
- package/commonjs/steps/getStep.test.js +7 -7
- package/commonjs/steps/getStep.test.js.map +1 -1
- package/commonjs/steps/getStepDenominator.js +2 -5
- package/commonjs/steps/getStepDenominator.js.map +1 -1
- package/commonjs/steps/getStepDenominator.test.js +1 -3
- package/commonjs/steps/getStepDenominator.test.js.map +1 -1
- package/commonjs/steps/getStepMinTime.js +31 -39
- package/commonjs/steps/getStepMinTime.js.map +1 -1
- package/commonjs/steps/getStepMinTime.test.js +1 -3
- package/commonjs/steps/getStepMinTime.test.js.map +1 -1
- package/commonjs/steps/getTimeToNextUpdate.js +27 -41
- package/commonjs/steps/getTimeToNextUpdate.js.map +1 -1
- package/commonjs/steps/getTimeToNextUpdate.test.js +29 -25
- package/commonjs/steps/getTimeToNextUpdate.test.js.map +1 -1
- package/commonjs/steps/getTimeToNextUpdateForUnit.js +3 -12
- package/commonjs/steps/getTimeToNextUpdateForUnit.js.map +1 -1
- package/commonjs/steps/getTimeToNextUpdateForUnit.test.js +1 -7
- package/commonjs/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
- package/commonjs/steps/helpers.js +1 -2
- package/commonjs/steps/helpers.js.map +1 -1
- package/commonjs/steps/helpers.test.js +0 -1
- package/commonjs/steps/helpers.test.js.map +1 -1
- package/commonjs/steps/index.js +1 -6
- package/commonjs/steps/index.js.map +1 -1
- package/commonjs/steps/renameLegacyProperties.js +6 -14
- package/commonjs/steps/renameLegacyProperties.js.map +1 -1
- package/commonjs/steps/renameLegacyProperties.test.js +1 -3
- package/commonjs/steps/renameLegacyProperties.test.js.map +1 -1
- package/commonjs/steps/round.js +1 -2
- package/commonjs/steps/round.js.map +1 -1
- package/commonjs/steps/round.test.js +1 -7
- package/commonjs/steps/round.test.js.map +1 -1
- package/commonjs/steps/units.js +10 -21
- package/commonjs/steps/units.js.map +1 -1
- package/commonjs/style/approximate.js +2 -6
- package/commonjs/style/approximate.js.map +1 -1
- package/commonjs/style/approximateTime.js +2 -6
- package/commonjs/style/approximateTime.js.map +1 -1
- package/commonjs/style/approximateTime.test.js +116 -75
- package/commonjs/style/approximateTime.test.js.map +1 -1
- package/commonjs/style/getStyleByName.js +3 -29
- package/commonjs/style/getStyleByName.js.map +1 -1
- package/commonjs/style/mini.js +9 -6
- package/commonjs/style/mini.js.map +1 -1
- package/commonjs/style/mini.test.js +15 -25
- package/commonjs/style/mini.test.js.map +1 -1
- package/commonjs/style/miniMinute.js +8 -13
- package/commonjs/style/miniMinute.js.map +1 -1
- package/commonjs/style/miniMinute.test.js +11 -17
- package/commonjs/style/miniMinute.test.js.map +1 -1
- package/commonjs/style/miniMinuteNow.js +8 -13
- package/commonjs/style/miniMinuteNow.js.map +1 -1
- package/commonjs/style/miniMinuteNow.test.js +11 -17
- package/commonjs/style/miniMinuteNow.test.js.map +1 -1
- package/commonjs/style/miniNow.js +8 -13
- package/commonjs/style/miniNow.js.map +1 -1
- package/commonjs/style/miniNow.test.js +11 -17
- package/commonjs/style/miniNow.test.js.map +1 -1
- package/commonjs/style/renameLegacyProperties.js +7 -13
- package/commonjs/style/renameLegacyProperties.js.map +1 -1
- package/commonjs/style/renameLegacyProperties.test.js +1 -4
- package/commonjs/style/renameLegacyProperties.test.js.map +1 -1
- package/commonjs/style/round.js +2 -6
- package/commonjs/style/round.js.map +1 -1
- package/commonjs/style/round.test.js +51 -67
- package/commonjs/style/round.test.js.map +1 -1
- package/commonjs/style/roundMinute.js +8 -13
- package/commonjs/style/roundMinute.js.map +1 -1
- package/commonjs/style/roundMinute.test.js +20 -27
- package/commonjs/style/roundMinute.test.js.map +1 -1
- package/commonjs/style/twitter.js +34 -39
- package/commonjs/style/twitter.js.map +1 -1
- package/commonjs/style/twitter.test.js +54 -57
- package/commonjs/style/twitter.test.js.map +1 -1
- package/commonjs/style/twitterFirstMinute.js +10 -15
- package/commonjs/style/twitterFirstMinute.js.map +1 -1
- package/commonjs/style/twitterFirstMinute.test.js +16 -23
- package/commonjs/style/twitterFirstMinute.test.js.map +1 -1
- package/commonjs/style/twitterMinute.js +8 -13
- package/commonjs/style/twitterMinute.js.map +1 -1
- package/commonjs/style/twitterMinute.test.js +20 -25
- package/commonjs/style/twitterMinute.test.js.map +1 -1
- package/commonjs/style/twitterMinuteNow.js +8 -13
- package/commonjs/style/twitterMinuteNow.js.map +1 -1
- package/commonjs/style/twitterMinuteNow.test.js +20 -25
- package/commonjs/style/twitterMinuteNow.test.js.map +1 -1
- package/commonjs/style/twitterNow.js +8 -13
- package/commonjs/style/twitterNow.js.map +1 -1
- package/commonjs/style/twitterNow.test.js +18 -24
- package/commonjs/style/twitterNow.test.js.map +1 -1
- package/full-date-formatter/index.cjs +4 -0
- package/full-date-formatter/index.cjs.js +9 -0
- package/full-date-formatter/index.d.ts +6 -0
- package/full-date-formatter/index.js +1 -0
- package/full-date-formatter/package.json +15 -0
- package/index.cjs +1 -1
- package/index.cjs.js +2 -2
- package/index.d.ts +14 -4
- package/index.js +3 -1
- package/load-all-locales/index.cjs +32 -0
- package/load-all-locales/index.cjs.js +32 -0
- package/load-all-locales/index.js +64 -0
- package/locale/ak/package.json +16 -0
- package/locale/ak.json +267 -0
- package/locale/ak.json.d.ts +4 -0
- package/locale/ak.json.js +267 -0
- package/locale/bal-Latn/package.json +16 -0
- package/locale/bal-Latn.json +240 -0
- package/locale/bal-Latn.json.d.ts +4 -0
- package/locale/bal-Latn.json.js +240 -0
- package/locale/be-tarask/package.json +16 -0
- package/locale/be-tarask.json +259 -0
- package/locale/be-tarask.json.d.ts +4 -0
- package/locale/be-tarask.json.js +259 -0
- package/locale/blo/package.json +16 -0
- package/locale/blo.json +159 -0
- package/locale/blo.json.d.ts +4 -0
- package/locale/blo.json.js +159 -0
- package/locale/bn.json +5 -2
- package/locale/bn.json.js +5 -2
- package/locale/bs.json +8 -2
- package/locale/bs.json.js +8 -2
- package/locale/ccp.json +2 -8
- package/locale/ccp.json.js +2 -8
- package/locale/csw/package.json +16 -0
- package/locale/csw.json +180 -0
- package/locale/csw.json.d.ts +4 -0
- package/locale/csw.json.js +180 -0
- package/locale/cy.json +6 -12
- package/locale/cy.json.js +6 -12
- package/locale/doi/package.json +16 -0
- package/locale/doi.json +159 -0
- package/locale/doi.json.d.ts +4 -0
- package/locale/doi.json.js +159 -0
- package/locale/en-AU.json +12 -12
- package/locale/en-AU.json.js +12 -12
- package/locale/en-CZ/package.json +16 -0
- package/locale/en-CZ.json +219 -0
- package/locale/en-CZ.json.d.ts +4 -0
- package/locale/en-CZ.json.js +219 -0
- package/locale/en-ES/package.json +16 -0
- package/locale/en-ES.json +219 -0
- package/locale/en-ES.json.d.ts +4 -0
- package/locale/en-ES.json.js +219 -0
- package/locale/en-FR/package.json +16 -0
- package/locale/en-FR.json +219 -0
- package/locale/en-FR.json.d.ts +4 -0
- package/locale/en-FR.json.js +219 -0
- package/locale/en-GS/package.json +16 -0
- package/locale/en-GS.json +219 -0
- package/locale/en-GS.json.d.ts +4 -0
- package/locale/en-GS.json.js +219 -0
- package/locale/en-HU/package.json +16 -0
- package/locale/en-HU.json +219 -0
- package/locale/en-HU.json.d.ts +4 -0
- package/locale/en-HU.json.js +219 -0
- package/locale/en-ID/package.json +16 -0
- package/locale/en-ID.json +219 -0
- package/locale/en-ID.json.d.ts +4 -0
- package/locale/en-ID.json.js +219 -0
- package/locale/en-IT/package.json +16 -0
- package/locale/en-IT.json +219 -0
- package/locale/en-IT.json.d.ts +4 -0
- package/locale/en-IT.json.js +219 -0
- package/locale/en-NO/package.json +16 -0
- package/locale/en-NO.json +219 -0
- package/locale/en-NO.json.d.ts +4 -0
- package/locale/en-NO.json.js +219 -0
- package/locale/en-PL/package.json +16 -0
- package/locale/en-PL.json +219 -0
- package/locale/en-PL.json.d.ts +4 -0
- package/locale/en-PL.json.js +219 -0
- package/locale/en-PT/package.json +16 -0
- package/locale/en-PT.json +219 -0
- package/locale/en-PT.json.d.ts +4 -0
- package/locale/en-PT.json.js +219 -0
- package/locale/en-RO/package.json +16 -0
- package/locale/en-RO.json +219 -0
- package/locale/en-RO.json.d.ts +4 -0
- package/locale/en-RO.json.js +219 -0
- package/locale/en-SK/package.json +16 -0
- package/locale/en-SK.json +219 -0
- package/locale/en-SK.json.d.ts +4 -0
- package/locale/en-SK.json.js +219 -0
- package/locale/es-MX.json +12 -9
- package/locale/es-MX.json.js +12 -9
- package/locale/es-SV.json +2 -2
- package/locale/es-SV.json.js +2 -2
- package/locale/eu.json +24 -24
- package/locale/eu.json.js +24 -24
- package/locale/ha.json +119 -65
- package/locale/ha.json.js +119 -65
- package/locale/he.json +0 -6
- package/locale/he.json.js +0 -6
- package/locale/hi-Latn.json +2 -2
- package/locale/hi-Latn.json.js +2 -2
- package/locale/ht/package.json +16 -0
- package/locale/ht.json +207 -0
- package/locale/ht.json.d.ts +4 -0
- package/locale/ht.json.js +207 -0
- package/locale/id.json +1 -1
- package/locale/id.json.js +1 -1
- package/locale/ie/package.json +16 -0
- package/locale/ie.json +159 -0
- package/locale/ie.json.d.ts +4 -0
- package/locale/ie.json.js +159 -0
- package/locale/ig.json +17 -17
- package/locale/ig.json.js +17 -17
- package/locale/ii/package.json +16 -0
- package/locale/ii.json +165 -0
- package/locale/ii.json.d.ts +4 -0
- package/locale/ii.json.js +165 -0
- package/locale/is.json +4 -1
- package/locale/is.json.js +4 -1
- package/locale/kaa/package.json +16 -0
- package/locale/kaa.json +159 -0
- package/locale/kaa.json.d.ts +4 -0
- package/locale/kaa.json.js +159 -0
- package/locale/kok-Latn/package.json +16 -0
- package/locale/kok-Latn.json +159 -0
- package/locale/kok-Latn.json.d.ts +4 -0
- package/locale/kok-Latn.json.js +159 -0
- package/locale/kok.json +8 -8
- package/locale/kok.json.js +8 -8
- package/locale/ks.json +9 -9
- package/locale/ks.json.js +9 -9
- package/locale/ku.json +55 -46
- package/locale/ku.json.js +55 -46
- package/locale/lld/package.json +16 -0
- package/locale/lld.json +291 -0
- package/locale/lld.json.d.ts +4 -0
- package/locale/lld.json.js +291 -0
- package/locale/mi.json +22 -22
- package/locale/mi.json.js +22 -22
- package/locale/ms-Arab/package.json +16 -0
- package/locale/ms-Arab.json +159 -0
- package/locale/ms-Arab.json.d.ts +4 -0
- package/locale/ms-Arab.json.js +159 -0
- package/locale/nb.json +2 -2
- package/locale/nb.json.js +2 -2
- package/locale/ne.json +1 -1
- package/locale/ne.json.js +1 -1
- package/locale/nn.json +4 -4
- package/locale/nn.json.js +4 -4
- package/locale/no.json +2 -2
- package/locale/no.json.js +2 -2
- package/locale/nqo/package.json +16 -0
- package/locale/nqo.json +159 -0
- package/locale/nqo.json.d.ts +4 -0
- package/locale/nqo.json.js +159 -0
- package/locale/om/package.json +16 -0
- package/locale/om.json +213 -0
- package/locale/om.json.d.ts +4 -0
- package/locale/om.json.js +213 -0
- package/locale/or.json +1 -1
- package/locale/or.json.js +1 -1
- package/locale/qu.json +46 -46
- package/locale/qu.json.js +46 -46
- package/locale/rhg/package.json +16 -0
- package/locale/rhg.json +159 -0
- package/locale/rhg.json.d.ts +4 -0
- package/locale/rhg.json.js +159 -0
- package/locale/sl.json +12 -12
- package/locale/sl.json.js +12 -12
- package/locale/sr-Cyrl-BA.json +2 -2
- package/locale/sr-Cyrl-BA.json.js +2 -2
- package/locale/sr-Latn-BA.json +2 -2
- package/locale/sr-Latn-BA.json.js +2 -2
- package/locale/sv.json +1 -1
- package/locale/sv.json.js +1 -1
- package/locale/syr/package.json +16 -0
- package/locale/syr.json +303 -0
- package/locale/syr.json.d.ts +4 -0
- package/locale/syr.json.js +303 -0
- package/locale/ti.json +6 -6
- package/locale/ti.json.js +6 -6
- package/locale/tn/package.json +16 -0
- package/locale/tn.json +159 -0
- package/locale/tn.json.d.ts +4 -0
- package/locale/tn.json.js +159 -0
- package/locale/to.json +26 -26
- package/locale/to.json.js +26 -26
- package/locale/uk.json +1 -1
- package/locale/uk.json.js +1 -1
- package/locale/ur-IN.json +9 -6
- package/locale/ur-IN.json.js +9 -6
- package/locale/vec/package.json +16 -0
- package/locale/vec.json +267 -0
- package/locale/vec.json.d.ts +4 -0
- package/locale/vec.json.js +267 -0
- package/locale/xnr/package.json +16 -0
- package/locale/xnr.json +159 -0
- package/locale/xnr.json.d.ts +4 -0
- package/locale/xnr.json.js +159 -0
- package/locale/yo-BJ.json +17 -17
- package/locale/yo-BJ.json.js +17 -17
- package/locale/yo.json +17 -17
- package/locale/yo.json.js +17 -17
- package/modules/FullDateFormatter.js +67 -0
- package/modules/FullDateFormatter.js.map +1 -0
- package/modules/FullDateFormatter.test.js +22 -0
- package/modules/FullDateFormatter.test.js.map +1 -0
- package/modules/LocaleDataStore.js +2 -3
- package/modules/LocaleDataStore.js.map +1 -1
- package/modules/PropTypes.js +11 -7
- package/modules/PropTypes.js.map +1 -1
- package/modules/TimeAgo.js +299 -237
- package/modules/TimeAgo.js.map +1 -1
- package/modules/TimeAgo.test.js +217 -119
- package/modules/TimeAgo.test.js.map +1 -1
- package/modules/cache.js +6 -22
- package/modules/cache.js.map +1 -1
- package/modules/cache.test.js.map +1 -1
- package/modules/isStyleObject.js +9 -7
- package/modules/isStyleObject.js.map +1 -1
- package/modules/isStyleObject.test.js.map +1 -1
- package/modules/locale.js +6 -16
- package/modules/locale.js.map +1 -1
- package/modules/locale.test.js +0 -4
- package/modules/locale.test.js.map +1 -1
- package/modules/round.js +2 -3
- package/modules/round.js.map +1 -1
- package/modules/steps/approximate.js +6 -2
- package/modules/steps/approximate.js.map +1 -1
- package/modules/steps/approximate.test.js +0 -2
- package/modules/steps/approximate.test.js.map +1 -1
- package/modules/steps/getStep.js +36 -48
- package/modules/steps/getStep.js.map +1 -1
- package/modules/steps/getStep.test.js +6 -2
- package/modules/steps/getStep.test.js.map +1 -1
- package/modules/steps/getStepDenominator.js +2 -3
- package/modules/steps/getStepDenominator.js.map +1 -1
- package/modules/steps/getStepDenominator.test.js.map +1 -1
- package/modules/steps/getStepMinTime.js +31 -36
- package/modules/steps/getStepMinTime.js.map +1 -1
- package/modules/steps/getStepMinTime.test.js.map +1 -1
- package/modules/steps/getTimeToNextUpdate.js +28 -32
- package/modules/steps/getTimeToNextUpdate.js.map +1 -1
- package/modules/steps/getTimeToNextUpdate.test.js +27 -18
- package/modules/steps/getTimeToNextUpdate.test.js.map +1 -1
- package/modules/steps/getTimeToNextUpdateForUnit.js +4 -10
- package/modules/steps/getTimeToNextUpdateForUnit.js.map +1 -1
- package/modules/steps/getTimeToNextUpdateForUnit.test.js +0 -4
- package/modules/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
- package/modules/steps/helpers.js +1 -1
- package/modules/steps/helpers.js.map +1 -1
- package/modules/steps/helpers.test.js.map +1 -1
- package/modules/steps/index.js +2 -1
- package/modules/steps/index.js.map +1 -1
- package/modules/steps/renameLegacyProperties.js +6 -13
- package/modules/steps/renameLegacyProperties.js.map +1 -1
- package/modules/steps/renameLegacyProperties.test.js.map +1 -1
- package/modules/steps/round.js.map +1 -1
- package/modules/steps/round.test.js +0 -3
- package/modules/steps/round.test.js.map +1 -1
- package/modules/steps/units.js +5 -9
- package/modules/steps/units.js.map +1 -1
- package/modules/style/approximate.js +5 -1
- package/modules/style/approximate.js.map +1 -1
- package/modules/style/approximateTime.js +6 -2
- package/modules/style/approximateTime.js.map +1 -1
- package/modules/style/approximateTime.test.js +115 -70
- package/modules/style/approximateTime.test.js.map +1 -1
- package/modules/style/getStyleByName.js +4 -17
- package/modules/style/getStyleByName.js.map +1 -1
- package/modules/style/mini.js +8 -4
- package/modules/style/mini.js.map +1 -1
- package/modules/style/mini.test.js +14 -20
- package/modules/style/mini.test.js.map +1 -1
- package/modules/style/miniMinute.js +6 -6
- package/modules/style/miniMinute.js.map +1 -1
- package/modules/style/miniMinute.test.js +10 -12
- package/modules/style/miniMinute.test.js.map +1 -1
- package/modules/style/miniMinuteNow.js +6 -6
- package/modules/style/miniMinuteNow.js.map +1 -1
- package/modules/style/miniMinuteNow.test.js +10 -12
- package/modules/style/miniMinuteNow.test.js.map +1 -1
- package/modules/style/miniNow.js +6 -6
- package/modules/style/miniNow.js.map +1 -1
- package/modules/style/miniNow.test.js +10 -12
- package/modules/style/miniNow.test.js.map +1 -1
- package/modules/style/renameLegacyProperties.js +8 -10
- package/modules/style/renameLegacyProperties.js.map +1 -1
- package/modules/style/renameLegacyProperties.test.js +0 -1
- package/modules/style/renameLegacyProperties.test.js.map +1 -1
- package/modules/style/round.js +3 -2
- package/modules/style/round.js.map +1 -1
- package/modules/style/round.test.js +50 -62
- package/modules/style/round.test.js.map +1 -1
- package/modules/style/roundMinute.js +8 -7
- package/modules/style/roundMinute.js.map +1 -1
- package/modules/style/roundMinute.test.js +19 -22
- package/modules/style/roundMinute.test.js.map +1 -1
- package/modules/style/twitter.js +36 -33
- package/modules/style/twitter.js.map +1 -1
- package/modules/style/twitter.test.js +53 -52
- package/modules/style/twitter.test.js.map +1 -1
- package/modules/style/twitterFirstMinute.js +8 -7
- package/modules/style/twitterFirstMinute.js.map +1 -1
- package/modules/style/twitterFirstMinute.test.js +15 -18
- package/modules/style/twitterFirstMinute.test.js.map +1 -1
- package/modules/style/twitterMinute.js +6 -6
- package/modules/style/twitterMinute.js.map +1 -1
- package/modules/style/twitterMinute.test.js +19 -20
- package/modules/style/twitterMinute.test.js.map +1 -1
- package/modules/style/twitterMinuteNow.js +6 -6
- package/modules/style/twitterMinuteNow.js.map +1 -1
- package/modules/style/twitterMinuteNow.test.js +19 -20
- package/modules/style/twitterMinuteNow.test.js.map +1 -1
- package/modules/style/twitterNow.js +6 -6
- package/modules/style/twitterNow.js.map +1 -1
- package/modules/style/twitterNow.test.js +17 -19
- package/modules/style/twitterNow.test.js.map +1 -1
- package/package.json +275 -13
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getStepDenominator = _interopRequireDefault(require("./getStepDenominator.js"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
|
-
|
|
4
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
7
5
|
describe('getStepDenominator', function () {
|
|
8
6
|
it('should support the older "unit" name', function () {
|
|
9
7
|
(0, _getStepDenominator["default"])({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStepDenominator.test.js","names":["describe","it","getStepDenominator","unit","should","equal","formatAs"],"sources":["../../source/steps/getStepDenominator.test.js"],"sourcesContent":["import getStepDenominator from './getStepDenominator.js'\r\n\r\ndescribe('getStepDenominator', () => {\r\n\tit('should support the older \"unit\" name', () => {\r\n\t\tgetStepDenominator({ unit: 'minute' }).should.equal(60)\r\n\t})\r\n\r\n\tit('should return 1 as a default \"denominator\"', () => {\r\n\t\tgetStepDenominator({ formatAs: 'exotic' }).should.equal(1)\r\n\t})\r\n})"],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"getStepDenominator.test.js","names":["_getStepDenominator","_interopRequireDefault","require","e","__esModule","describe","it","getStepDenominator","unit","should","equal","formatAs"],"sources":["../../source/steps/getStepDenominator.test.js"],"sourcesContent":["import getStepDenominator from './getStepDenominator.js'\r\n\r\ndescribe('getStepDenominator', () => {\r\n\tit('should support the older \"unit\" name', () => {\r\n\t\tgetStepDenominator({ unit: 'minute' }).should.equal(60)\r\n\t})\r\n\r\n\tit('should return 1 as a default \"denominator\"', () => {\r\n\t\tgetStepDenominator({ formatAs: 'exotic' }).should.equal(1)\r\n\t})\r\n})"],"mappings":";;AAAA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAwD,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAExDE,QAAQ,CAAC,oBAAoB,EAAE,YAAM;EACpCC,EAAE,CAAC,sCAAsC,EAAE,YAAM;IAChD,IAAAC,8BAAkB,EAAC;MAAEC,IAAI,EAAE;IAAS,CAAC,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,EAAE,CAAC;EACxD,CAAC,CAAC;EAEFJ,EAAE,CAAC,4CAA4C,EAAE,YAAM;IACtD,IAAAC,8BAAkB,EAAC;MAAEI,QAAQ,EAAE;IAAS,CAAC,CAAC,CAACF,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC;EAC3D,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -4,45 +4,48 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = getStepMinTime;
|
|
7
|
-
|
|
8
7
|
var _units = require("./units.js");
|
|
9
|
-
|
|
10
8
|
var _round = require("../round.js");
|
|
11
|
-
|
|
12
|
-
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); }
|
|
13
|
-
|
|
9
|
+
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); }
|
|
14
10
|
function getStepMinTime(step, _ref) {
|
|
15
11
|
var prevStep = _ref.prevStep,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var minTime;
|
|
21
|
-
|
|
12
|
+
timestamp = _ref.timestamp,
|
|
13
|
+
now = _ref.now,
|
|
14
|
+
future = _ref.future,
|
|
15
|
+
round = _ref.round;
|
|
16
|
+
var minTime;
|
|
17
|
+
|
|
18
|
+
// (deprecated)
|
|
19
|
+
// Get `minTime` from "threshold_for_xxx" property of the `step`.
|
|
20
|
+
// "threshold_for_xxx" property of a `step` is deprecated.
|
|
22
21
|
if (prevStep) {
|
|
23
22
|
if (prevStep.id || prevStep.unit) {
|
|
24
23
|
minTime = step["threshold_for_".concat(prevStep.id || prevStep.unit)];
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
|
|
27
|
+
// (deprecated)
|
|
28
|
+
// Get `minTime` from "threshold" property of the `step`.
|
|
29
|
+
// "threshold" property of a `step` is deprecated.
|
|
28
30
|
if (minTime === undefined) {
|
|
29
|
-
// "threshold" is a legacy property.
|
|
30
31
|
if (step.threshold !== undefined) {
|
|
31
32
|
// "threshold" is a legacy name for "minTime".
|
|
32
|
-
minTime = step.threshold;
|
|
33
|
-
|
|
33
|
+
minTime = step.threshold;
|
|
34
|
+
// "threshold" function is deprecated.
|
|
34
35
|
if (typeof minTime === 'function') {
|
|
35
36
|
minTime = minTime(now, future);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
// Get `minTime` from `minTime` property of the `step`.
|
|
42
|
+
// This is the only non-deprecated source for the `minTime` property.
|
|
40
43
|
if (minTime === undefined) {
|
|
41
44
|
minTime = step.minTime;
|
|
42
|
-
}
|
|
43
|
-
// depending on the previous step's unit.
|
|
44
|
-
|
|
45
|
+
}
|
|
45
46
|
|
|
47
|
+
// (deprecated)
|
|
48
|
+
// If `minTime` is an object, calculate `minTime` from the previous step's `unit`.
|
|
46
49
|
if (_typeof(minTime) === 'object') {
|
|
47
50
|
if (prevStep && prevStep.id && minTime[prevStep.id] !== undefined) {
|
|
48
51
|
minTime = minTime[prevStep.id];
|
|
@@ -51,6 +54,7 @@ function getStepMinTime(step, _ref) {
|
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
// If `minTime` is a function, call it with certain arguments.
|
|
54
58
|
if (typeof minTime === 'function') {
|
|
55
59
|
minTime = minTime(timestamp, {
|
|
56
60
|
future: future,
|
|
@@ -60,10 +64,11 @@ function getStepMinTime(step, _ref) {
|
|
|
60
64
|
});
|
|
61
65
|
}
|
|
62
66
|
});
|
|
63
|
-
}
|
|
64
|
-
// `test()` function is deprecated.
|
|
65
|
-
|
|
67
|
+
}
|
|
66
68
|
|
|
69
|
+
// (deprecated)
|
|
70
|
+
// Get `minTime` from `step.test()` function property.
|
|
71
|
+
// `step.test` property is deprecated.
|
|
67
72
|
if (minTime === undefined) {
|
|
68
73
|
if (step.test) {
|
|
69
74
|
if (step.test(timestamp, {
|
|
@@ -79,6 +84,8 @@ function getStepMinTime(step, _ref) {
|
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
86
|
|
|
87
|
+
// If `minTime` is `undefined`, calculate it from the previous `step`.
|
|
88
|
+
// If it's the first step and there's no previous one, the `minTime` is assumed `0`.
|
|
82
89
|
if (minTime === undefined) {
|
|
83
90
|
if (prevStep) {
|
|
84
91
|
if (step.formatAs && prevStep.formatAs) {
|
|
@@ -90,33 +97,18 @@ function getStepMinTime(step, _ref) {
|
|
|
90
97
|
// The first step's `minTime` is `0` by default.
|
|
91
98
|
minTime = 0;
|
|
92
99
|
}
|
|
93
|
-
}
|
|
94
|
-
|
|
100
|
+
}
|
|
95
101
|
|
|
102
|
+
// Warn if no `minTime` is defined for this step.
|
|
96
103
|
if (minTime === undefined) {
|
|
97
104
|
console.warn('[javascript-time-ago] A step should specify `minTime`:\n' + JSON.stringify(step, null, 2));
|
|
98
105
|
}
|
|
99
|
-
|
|
100
106
|
return minTime;
|
|
101
107
|
}
|
|
102
|
-
|
|
103
108
|
function _getMinTimeForUnit(toUnit, fromUnit, _ref2) {
|
|
104
109
|
var round = _ref2.round;
|
|
105
|
-
var toUnitAmount = (0, _units.getSecondsInUnit)(toUnit);
|
|
106
|
-
|
|
107
|
-
// }
|
|
108
|
-
// if (!fromUnit) {
|
|
109
|
-
// fromUnit = getPreviousUnitFor(toUnit)
|
|
110
|
-
// }
|
|
111
|
-
|
|
112
|
-
var fromUnitAmount;
|
|
113
|
-
|
|
114
|
-
if (fromUnit === 'now') {
|
|
115
|
-
fromUnitAmount = (0, _units.getSecondsInUnit)(toUnit);
|
|
116
|
-
} else {
|
|
117
|
-
fromUnitAmount = (0, _units.getSecondsInUnit)(fromUnit);
|
|
118
|
-
}
|
|
119
|
-
|
|
110
|
+
var toUnitAmount = (0, _units.getSecondsInUnit)(toUnit);
|
|
111
|
+
var fromUnitAmount = fromUnit === 'now' ? (0, _units.getSecondsInUnit)(toUnit) : (0, _units.getSecondsInUnit)(fromUnit);
|
|
120
112
|
if (toUnitAmount !== undefined && fromUnitAmount !== undefined) {
|
|
121
113
|
return toUnitAmount - fromUnitAmount * (1 - (0, _round.getDiffRatioToNextRoundedNumber)(round));
|
|
122
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStepMinTime.js","names":["getStepMinTime","step","prevStep","timestamp","now","future","round","minTime","id","unit","undefined","threshold","getMinTimeForUnit","toUnit","fromUnit","formatAs","test","console","warn","JSON","stringify","toUnitAmount","getSecondsInUnit","fromUnitAmount","getDiffRatioToNextRoundedNumber"],"sources":["../../source/steps/getStepMinTime.js"],"sourcesContent":["import { getSecondsInUnit } from './units.js'\r\nimport { getDiffRatioToNextRoundedNumber } from '../round.js'\r\n\r\nexport default function getStepMinTime(step, {\r\n\tprevStep,\r\n\ttimestamp,\r\n\t// `now` argument is used in a deprecated `step.test()` function.\r\n\tnow,\r\n\tfuture,\r\n\tround\r\n}) {\r\n\tlet minTime\r\n\t// \"threshold_for_xxx\"
|
|
1
|
+
{"version":3,"file":"getStepMinTime.js","names":["_units","require","_round","_typeof","o","Symbol","iterator","constructor","prototype","getStepMinTime","step","_ref","prevStep","timestamp","now","future","round","minTime","id","unit","concat","undefined","threshold","getMinTimeForUnit","toUnit","fromUnit","formatAs","test","console","warn","JSON","stringify","_ref2","toUnitAmount","getSecondsInUnit","fromUnitAmount","getDiffRatioToNextRoundedNumber"],"sources":["../../source/steps/getStepMinTime.js"],"sourcesContent":["import { getSecondsInUnit } from './units.js'\r\nimport { getDiffRatioToNextRoundedNumber } from '../round.js'\r\n\r\nexport default function getStepMinTime(step, {\r\n\tprevStep,\r\n\ttimestamp,\r\n\t// `now` argument is used in a deprecated `step.test()` function.\r\n\tnow,\r\n\tfuture,\r\n\tround\r\n}) {\r\n\tlet minTime\r\n\r\n\t// (deprecated)\r\n\t// Get `minTime` from \"threshold_for_xxx\" property of the `step`.\r\n\t// \"threshold_for_xxx\" property of a `step` is deprecated.\r\n\tif (prevStep) {\r\n\t\tif (prevStep.id || prevStep.unit) {\r\n\t\t\tminTime = step[`threshold_for_${prevStep.id || prevStep.unit}`]\r\n\t\t}\r\n\t}\r\n\r\n\t// (deprecated)\r\n\t// Get `minTime` from \"threshold\" property of the `step`.\r\n\t// \"threshold\" property of a `step` is deprecated.\r\n\tif (minTime === undefined) {\r\n\t\tif (step.threshold !== undefined) {\r\n\t\t\t// \"threshold\" is a legacy name for \"minTime\".\r\n\t\t\tminTime = step.threshold\r\n\t\t\t// \"threshold\" function is deprecated.\r\n\t\t\tif (typeof minTime === 'function') {\r\n\t\t\t\tminTime = minTime(now, future)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Get `minTime` from `minTime` property of the `step`.\r\n\t// This is the only non-deprecated source for the `minTime` property.\r\n\tif (minTime === undefined) {\r\n\t\tminTime = step.minTime\r\n\t}\r\n\r\n\t// (deprecated)\r\n\t// If `minTime` is an object, calculate `minTime` from the previous step's `unit`.\r\n\tif (typeof minTime === 'object') {\r\n\t\tif (prevStep && prevStep.id && minTime[prevStep.id] !== undefined) {\r\n\t\t\tminTime = minTime[prevStep.id]\r\n\t\t} else {\r\n\t\t\tminTime = minTime.default\r\n\t\t}\r\n\t}\r\n\r\n\t// If `minTime` is a function, call it with certain arguments.\r\n\tif (typeof minTime === 'function') {\r\n\t\tminTime = minTime(timestamp, {\r\n\t\t\tfuture,\r\n\t\t\tgetMinTimeForUnit(toUnit, fromUnit) {\r\n\t\t\t\treturn getMinTimeForUnit(\r\n\t\t\t\t\ttoUnit,\r\n\t\t\t\t\tfromUnit || prevStep && prevStep.formatAs,\r\n\t\t\t\t\t{ round }\r\n\t\t\t\t)\r\n\t\t\t}\r\n\t\t})\r\n\t}\r\n\r\n\t// (deprecated)\r\n\t// Get `minTime` from `step.test()` function property.\r\n\t// `step.test` property is deprecated.\r\n\tif (minTime === undefined) {\r\n\t\tif (step.test) {\r\n\t\t\tif (step.test(timestamp, {\r\n\t\t\t\tnow,\r\n\t\t\t\tfuture\r\n\t\t\t})) {\r\n\t\t\t\t// `0` threshold always passes.\r\n\t\t\t\tminTime = 0\r\n\t\t\t} else {\r\n\t\t\t\t// `MAX_SAFE_INTEGER` threshold won't ever pass in real life.\r\n\t\t\t\tminTime = 9007199254740991 // Number.MAX_SAFE_INTEGER\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// If `minTime` is `undefined`, calculate it from the previous `step`.\r\n\t// If it's the first step and there's no previous one, the `minTime` is assumed `0`.\r\n\tif (minTime === undefined) {\r\n\t\tif (prevStep) {\r\n\t\t\tif (step.formatAs && prevStep.formatAs) {\r\n\t\t\t\tminTime = getMinTimeForUnit(step.formatAs, prevStep.formatAs, { round })\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\t// The first step's `minTime` is `0` by default.\r\n\t\t\tminTime = 0\r\n\t\t}\r\n\t}\r\n\r\n\t// Warn if no `minTime` is defined for this step.\r\n\tif (minTime === undefined) {\r\n\t\tconsole.warn('[javascript-time-ago] A step should specify `minTime`:\\n' + JSON.stringify(step, null, 2))\r\n\t}\r\n\r\n\treturn minTime\r\n}\r\n\r\nfunction getMinTimeForUnit(toUnit, fromUnit, { round }) {\r\n\tconst toUnitAmount = getSecondsInUnit(toUnit)\r\n\tconst fromUnitAmount = fromUnit === 'now' ? getSecondsInUnit(toUnit) : getSecondsInUnit(fromUnit)\r\n\tif (toUnitAmount !== undefined && fromUnitAmount !== undefined) {\r\n\t\treturn toUnitAmount - fromUnitAmount * (1 - getDiffRatioToNextRoundedNumber(round))\r\n\t}\r\n}"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAA6D,SAAAE,QAAAC,CAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,CAAA,kBAAAA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G;EAEA,OAAOO,OAAO;AACf;AAEA,SAASM,kBAAiBA,CAACC,MAAM,EAAEC,QAAQ,EAAAO,KAAA,EAAa;EAAA,IAAThB,KAAK,GAAAgB,KAAA,CAALhB,KAAK;EACnD,IAAMiB,YAAY,GAAG,IAAAC,uBAAgB,EAACV,MAAM,CAAC;EAC7C,IAAMW,cAAc,GAAGV,QAAQ,KAAK,KAAK,GAAG,IAAAS,uBAAgB,EAACV,MAAM,CAAC,GAAG,IAAAU,uBAAgB,EAACT,QAAQ,CAAC;EACjG,IAAIQ,YAAY,KAAKZ,SAAS,IAAIc,cAAc,KAAKd,SAAS,EAAE;IAC/D,OAAOY,YAAY,GAAGE,cAAc,IAAI,CAAC,GAAG,IAAAC,sCAA+B,EAACpB,KAAK,CAAC,CAAC;EACpF;AACD","ignoreList":[]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getStepMinTime = _interopRequireDefault(require("./getStepMinTime.js"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
|
-
|
|
4
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
7
5
|
describe('getStepMinTime', function () {
|
|
8
6
|
it('should support `step.test()` function (returns true)', function () {
|
|
9
7
|
(0, _getStepMinTime["default"])({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStepMinTime.test.js","names":["describe","it","getStepMinTime","test","prevStep","minTime","should","equal"],"sources":["../../source/steps/getStepMinTime.test.js"],"sourcesContent":["import getStepMinTime from './getStepMinTime.js'\r\n\r\ndescribe('getStepMinTime', () => {\r\n\tit('should support `step.test()` function (returns true)', () => {\r\n\t\tgetStepMinTime({\r\n\t\t\ttest: () => true\r\n\t\t}, {\r\n\t\t\tprevStep: { minTime: 1 }\r\n\t\t}).should.equal(0)\r\n\t})\r\n\r\n\tit('should support `step.test()` function (returns false)', () => {\r\n\t\tgetStepMinTime({\r\n\t\t\ttest: () => false\r\n\t\t}, {\r\n\t\t\tprevStep: { minTime: 1 }\r\n\t\t}).should.equal(9007199254740991)\r\n\t})\r\n})"],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"getStepMinTime.test.js","names":["_getStepMinTime","_interopRequireDefault","require","e","__esModule","describe","it","getStepMinTime","test","prevStep","minTime","should","equal"],"sources":["../../source/steps/getStepMinTime.test.js"],"sourcesContent":["import getStepMinTime from './getStepMinTime.js'\r\n\r\ndescribe('getStepMinTime', () => {\r\n\tit('should support `step.test()` function (returns true)', () => {\r\n\t\tgetStepMinTime({\r\n\t\t\ttest: () => true\r\n\t\t}, {\r\n\t\t\tprevStep: { minTime: 1 }\r\n\t\t}).should.equal(0)\r\n\t})\r\n\r\n\tit('should support `step.test()` function (returns false)', () => {\r\n\t\tgetStepMinTime({\r\n\t\t\ttest: () => false\r\n\t\t}, {\r\n\t\t\tprevStep: { minTime: 1 }\r\n\t\t}).should.equal(9007199254740991)\r\n\t})\r\n})"],"mappings":";;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAgD,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAEhDE,QAAQ,CAAC,gBAAgB,EAAE,YAAM;EAChCC,EAAE,CAAC,sDAAsD,EAAE,YAAM;IAChE,IAAAC,0BAAc,EAAC;MACdC,IAAI,EAAE,SAAAA,KAAA;QAAA,OAAM,IAAI;MAAA;IACjB,CAAC,EAAE;MACFC,QAAQ,EAAE;QAAEC,OAAO,EAAE;MAAE;IACxB,CAAC,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC;EACnB,CAAC,CAAC;EAEFN,EAAE,CAAC,uDAAuD,EAAE,YAAM;IACjE,IAAAC,0BAAc,EAAC;MACdC,IAAI,EAAE,SAAAA,KAAA;QAAA,OAAM,KAAK;MAAA;IAClB,CAAC,EAAE;MACFC,QAAQ,EAAE;QAAEC,OAAO,EAAE;MAAE;IACxB,CAAC,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,gBAAgB,CAAC;EAClC,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -7,20 +7,18 @@ exports.INFINITY = void 0;
|
|
|
7
7
|
exports["default"] = getTimeToNextUpdate;
|
|
8
8
|
exports.getStepChangesAt = getStepChangesAt;
|
|
9
9
|
exports.getTimeToStepChange = getTimeToStepChange;
|
|
10
|
-
|
|
11
10
|
var _getTimeToNextUpdateForUnit2 = _interopRequireDefault(require("./getTimeToNextUpdateForUnit.js"));
|
|
12
|
-
|
|
13
11
|
var _getStepMinTime = _interopRequireDefault(require("./getStepMinTime.js"));
|
|
14
|
-
|
|
15
12
|
var _round = require("../round.js");
|
|
16
|
-
|
|
17
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
18
|
-
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
19
14
|
// A thousand years is practically a metaphor for "infinity".
|
|
20
15
|
var YEAR = 365 * 24 * 60 * 60 * 1000;
|
|
21
|
-
|
|
16
|
+
// It can't really return `Infinity` in order to not screw any potential calculations performed with it.
|
|
17
|
+
// Hence, it emulates `Infinity` with a really large number that is "practically infinite".
|
|
18
|
+
var INFINITY = exports.INFINITY = 1000 * YEAR;
|
|
19
|
+
|
|
22
20
|
/**
|
|
23
|
-
*
|
|
21
|
+
* Returns the time (in milliseconds) after which the formatted date label should be refreshed.
|
|
24
22
|
* @param {number} date — The date passed to `.format()`, converted to a timestamp.
|
|
25
23
|
* @param {object} step
|
|
26
24
|
* @param {object} [options.previousStep]
|
|
@@ -28,25 +26,23 @@ var INFINITY = 1000 * YEAR;
|
|
|
28
26
|
* @param {number} options.now
|
|
29
27
|
* @param {boolean} options.future
|
|
30
28
|
* @param {string} [options.round] - (undocumented) Rounding mechanism.
|
|
31
|
-
* @return {number} [timeToNextUpdate]
|
|
29
|
+
* @return {number} [timeToNextUpdate] Returns the time to next update. Returns `undefined` when it can't determine time to next update. That could only happen when the "style" doesn't meet the minimum requirements for `getTimeToNextUpdate: true` feature (see README).
|
|
32
30
|
*/
|
|
33
|
-
|
|
34
|
-
exports.INFINITY = INFINITY;
|
|
35
|
-
|
|
36
31
|
function getTimeToNextUpdate(date, step, _ref) {
|
|
37
32
|
var prevStep = _ref.prevStep,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
nextStep = _ref.nextStep,
|
|
34
|
+
now = _ref.now,
|
|
35
|
+
future = _ref.future,
|
|
36
|
+
round = _ref.round;
|
|
42
37
|
var timestamp = date.getTime ? date.getTime() : date;
|
|
43
|
-
|
|
44
38
|
var getTimeToNextUpdateForUnit = function getTimeToNextUpdateForUnit(unit) {
|
|
45
39
|
return (0, _getTimeToNextUpdateForUnit2["default"])(unit, timestamp, {
|
|
46
40
|
now: now,
|
|
47
41
|
round: round
|
|
48
42
|
});
|
|
49
|
-
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// For future dates, steps move from the last one to the first one,
|
|
50
46
|
// while for past dates, steps move from the first one to the last one,
|
|
51
47
|
// due to the fact that time flows in one direction,
|
|
52
48
|
// and future dates' interval naturally becomes smaller
|
|
@@ -60,24 +56,22 @@ function getTimeToNextUpdate(date, step, _ref) {
|
|
|
60
56
|
// from the current step to the next step,
|
|
61
57
|
// therefore check the `minTime` of the next step.
|
|
62
58
|
//
|
|
63
|
-
|
|
64
|
-
|
|
65
59
|
var timeToStepChange = getTimeToStepChange(future ? step : nextStep, timestamp, {
|
|
66
60
|
future: future,
|
|
67
61
|
now: now,
|
|
68
62
|
round: round,
|
|
69
|
-
prevStep: future ? prevStep : step
|
|
70
|
-
|
|
63
|
+
prevStep: future ? prevStep : step
|
|
64
|
+
// isFirstStep: future && isFirstStep
|
|
71
65
|
});
|
|
72
66
|
|
|
67
|
+
// If the "style" doesn't meet the minimum requirements for `getTimeToNextUpdate: true` feature (see README)
|
|
68
|
+
// then `timeToStepChange` will be `undefined`. In that case, just return `undefined`.
|
|
73
69
|
if (timeToStepChange === undefined) {
|
|
74
70
|
// Can't reliably determine "time to next update"
|
|
75
71
|
// if not all of the steps provide `minTime`.
|
|
76
72
|
return;
|
|
77
73
|
}
|
|
78
|
-
|
|
79
74
|
var timeToNextUpdate;
|
|
80
|
-
|
|
81
75
|
if (step) {
|
|
82
76
|
if (step.getTimeToNextUpdate) {
|
|
83
77
|
timeToNextUpdate = step.getTimeToNextUpdate(timestamp, {
|
|
@@ -88,11 +82,9 @@ function getTimeToNextUpdate(date, step, _ref) {
|
|
|
88
82
|
round: round
|
|
89
83
|
});
|
|
90
84
|
}
|
|
91
|
-
|
|
92
85
|
if (timeToNextUpdate === undefined) {
|
|
93
86
|
// "unit" is now called "formatAs".
|
|
94
87
|
var unit = step.unit || step.formatAs;
|
|
95
|
-
|
|
96
88
|
if (unit) {
|
|
97
89
|
// For some units, like "now", there's no defined amount of seconds in them.
|
|
98
90
|
// In such cases, `getTimeToNextUpdateForUnit()` returns `undefined`,
|
|
@@ -102,19 +94,19 @@ function getTimeToNextUpdate(date, step, _ref) {
|
|
|
102
94
|
}
|
|
103
95
|
}
|
|
104
96
|
}
|
|
105
|
-
|
|
106
97
|
if (timeToNextUpdate === undefined) {
|
|
107
98
|
return timeToStepChange;
|
|
108
99
|
}
|
|
109
|
-
|
|
110
100
|
return Math.min(timeToNextUpdate, timeToStepChange);
|
|
111
101
|
}
|
|
112
102
|
|
|
103
|
+
// Returns the timestamp at which it'll move to the next step.
|
|
104
|
+
// Returns `undefined` when it can't determine when it'll move to the next stemp. That could only happen when the "style" doesn't meet the minimum requirements for `getTimeToNextUpdate: true` feature (see README).
|
|
113
105
|
function getStepChangesAt(currentOrNextStep, timestamp, _ref2) {
|
|
114
106
|
var now = _ref2.now,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
107
|
+
future = _ref2.future,
|
|
108
|
+
round = _ref2.round,
|
|
109
|
+
prevStep = _ref2.prevStep;
|
|
118
110
|
// The first step's `minTime` is `0` by default.
|
|
119
111
|
// It doesn't "change" steps at zero point
|
|
120
112
|
// but it does change the wording when switching
|
|
@@ -127,11 +119,9 @@ function getStepChangesAt(currentOrNextStep, timestamp, _ref2) {
|
|
|
127
119
|
round: round,
|
|
128
120
|
prevStep: prevStep
|
|
129
121
|
});
|
|
130
|
-
|
|
131
122
|
if (minTime === undefined) {
|
|
132
123
|
return;
|
|
133
124
|
}
|
|
134
|
-
|
|
135
125
|
if (future) {
|
|
136
126
|
// The step changes to the previous step
|
|
137
127
|
// as soon as `timestamp - now` becomes
|
|
@@ -145,21 +135,19 @@ function getStepChangesAt(currentOrNextStep, timestamp, _ref2) {
|
|
|
145
135
|
// equal to `minTime` of the next step:
|
|
146
136
|
// `now - timestamp === minTime`
|
|
147
137
|
// => `now === timestamp + minTime`.
|
|
138
|
+
|
|
148
139
|
// This is a special case when double-update could be skipped.
|
|
149
140
|
if (minTime === 0 && timestamp === now) {
|
|
150
141
|
return INFINITY;
|
|
151
142
|
}
|
|
152
|
-
|
|
153
143
|
return timestamp + minTime * 1000;
|
|
154
144
|
}
|
|
155
145
|
}
|
|
156
|
-
|
|
157
146
|
function getTimeToStepChange(step, timestamp, _ref3) {
|
|
158
147
|
var now = _ref3.now,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
148
|
+
future = _ref3.future,
|
|
149
|
+
round = _ref3.round,
|
|
150
|
+
prevStep = _ref3.prevStep;
|
|
163
151
|
if (step) {
|
|
164
152
|
var stepChangesAt = getStepChangesAt(step, timestamp, {
|
|
165
153
|
now: now,
|
|
@@ -167,11 +155,9 @@ function getTimeToStepChange(step, timestamp, _ref3) {
|
|
|
167
155
|
round: round,
|
|
168
156
|
prevStep: prevStep
|
|
169
157
|
});
|
|
170
|
-
|
|
171
158
|
if (stepChangesAt === undefined) {
|
|
172
159
|
return;
|
|
173
160
|
}
|
|
174
|
-
|
|
175
161
|
return stepChangesAt - now;
|
|
176
162
|
} else {
|
|
177
163
|
if (future) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTimeToNextUpdate.js","names":["YEAR","INFINITY","getTimeToNextUpdate","date","step","prevStep","nextStep","now","future","round","timestamp","getTime","getTimeToNextUpdateForUnit","unit","_getTimeToNextUpdateForUnit","timeToStepChange","getTimeToStepChange","undefined","timeToNextUpdate","getRoundFunction","formatAs","Math","min","getStepChangesAt","currentOrNextStep","minTime","getStepMinTime","stepChangesAt"],"sources":["../../source/steps/getTimeToNextUpdate.js"],"sourcesContent":["import _getTimeToNextUpdateForUnit from './getTimeToNextUpdateForUnit.js'\r\nimport getStepMinTime from './getStepMinTime.js'\r\nimport { getRoundFunction } from '../round.js'\r\n\r\n// A thousand years is practically a metaphor for \"infinity\".\r\nconst YEAR = 365 * 24 * 60 * 60 * 1000\r\nexport const INFINITY = 1000 * YEAR\r\n\r\n/**\r\n *
|
|
1
|
+
{"version":3,"file":"getTimeToNextUpdate.js","names":["_getTimeToNextUpdateForUnit2","_interopRequireDefault","require","_getStepMinTime","_round","e","__esModule","YEAR","INFINITY","exports","getTimeToNextUpdate","date","step","_ref","prevStep","nextStep","now","future","round","timestamp","getTime","getTimeToNextUpdateForUnit","unit","_getTimeToNextUpdateForUnit","timeToStepChange","getTimeToStepChange","undefined","timeToNextUpdate","getRoundFunction","formatAs","Math","min","getStepChangesAt","currentOrNextStep","_ref2","minTime","getStepMinTime","_ref3","stepChangesAt"],"sources":["../../source/steps/getTimeToNextUpdate.js"],"sourcesContent":["import _getTimeToNextUpdateForUnit from './getTimeToNextUpdateForUnit.js'\r\nimport getStepMinTime from './getStepMinTime.js'\r\nimport { getRoundFunction } from '../round.js'\r\n\r\n// A thousand years is practically a metaphor for \"infinity\".\r\nconst YEAR = 365 * 24 * 60 * 60 * 1000\r\n// It can't really return `Infinity` in order to not screw any potential calculations performed with it.\r\n// Hence, it emulates `Infinity` with a really large number that is \"practically infinite\".\r\nexport const INFINITY = 1000 * YEAR\r\n\r\n/**\r\n * Returns the time (in milliseconds) after which the formatted date label should be refreshed.\r\n * @param {number} date — The date passed to `.format()`, converted to a timestamp.\r\n * @param {object} step\r\n * @param {object} [options.previousStep]\r\n * @param {object} [options.nextStep]\r\n * @param {number} options.now\r\n * @param {boolean} options.future\r\n * @param {string} [options.round] - (undocumented) Rounding mechanism.\r\n * @return {number} [timeToNextUpdate] Returns the time to next update. Returns `undefined` when it can't determine time to next update. That could only happen when the \"style\" doesn't meet the minimum requirements for `getTimeToNextUpdate: true` feature (see README).\r\n */\r\nexport default function getTimeToNextUpdate(date, step, { prevStep, nextStep, now, future, round }) {\r\n\tconst timestamp = date.getTime ? date.getTime() : date\r\n\r\n\tconst getTimeToNextUpdateForUnit = (unit) => _getTimeToNextUpdateForUnit(unit, timestamp, { now, round })\r\n\r\n\t// For future dates, steps move from the last one to the first one,\r\n\t// while for past dates, steps move from the first one to the last one,\r\n\t// due to the fact that time flows in one direction,\r\n\t// and future dates' interval naturally becomes smaller\r\n\t// while past dates' interval naturally grows larger.\r\n\t//\r\n\t// For future dates, it's the transition\r\n\t// from the current step to the previous step,\r\n\t// therefore check the `minTime` of the current step.\r\n\t//\r\n\t// For past dates, it's the transition\r\n\t// from the current step to the next step,\r\n\t// therefore check the `minTime` of the next step.\r\n\t//\r\n\tconst timeToStepChange = getTimeToStepChange(future ? step : nextStep, timestamp, {\r\n\t\tfuture,\r\n\t\tnow,\r\n\t\tround,\r\n\t\tprevStep: future ? prevStep : step,\r\n\t\t// isFirstStep: future && isFirstStep\r\n\t})\r\n\r\n\t// If the \"style\" doesn't meet the minimum requirements for `getTimeToNextUpdate: true` feature (see README)\r\n\t// then `timeToStepChange` will be `undefined`. In that case, just return `undefined`.\r\n\tif (timeToStepChange === undefined) {\r\n\t\t// Can't reliably determine \"time to next update\"\r\n\t\t// if not all of the steps provide `minTime`.\r\n\t\treturn\r\n\t}\r\n\r\n\tlet timeToNextUpdate\r\n\r\n\tif (step) {\r\n\t\tif (step.getTimeToNextUpdate) {\r\n\t\t\ttimeToNextUpdate = step.getTimeToNextUpdate(timestamp, {\r\n\t\t\t\tgetTimeToNextUpdateForUnit,\r\n\t\t\t\tgetRoundFunction,\r\n\t\t\t\tnow,\r\n\t\t\t\tfuture,\r\n\t\t\t\tround\r\n\t\t\t})\r\n\t\t}\r\n\r\n\t\tif (timeToNextUpdate === undefined) {\r\n\t\t\t// \"unit\" is now called \"formatAs\".\r\n\t\t\tconst unit = step.unit || step.formatAs\r\n\t\t\tif (unit) {\r\n\t\t\t\t// For some units, like \"now\", there's no defined amount of seconds in them.\r\n\t\t\t\t// In such cases, `getTimeToNextUpdateForUnit()` returns `undefined`,\r\n\t\t\t\t// and the next step's `minTime` could be used to calculate the update interval:\r\n\t\t\t\t// it will just assume that the label never changes for this step.\r\n\t\t\t\ttimeToNextUpdate = getTimeToNextUpdateForUnit(unit)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (timeToNextUpdate === undefined) {\r\n\t\treturn timeToStepChange\r\n\t}\r\n\r\n\treturn Math.min(timeToNextUpdate, timeToStepChange)\r\n}\r\n\r\n// Returns the timestamp at which it'll move to the next step.\r\n// Returns `undefined` when it can't determine when it'll move to the next stemp. That could only happen when the \"style\" doesn't meet the minimum requirements for `getTimeToNextUpdate: true` feature (see README).\r\nexport function getStepChangesAt(currentOrNextStep, timestamp, { now, future, round, prevStep }) {\r\n\t// The first step's `minTime` is `0` by default.\r\n\t// It doesn't \"change\" steps at zero point\r\n\t// but it does change the wording when switching\r\n\t// from \"future\" to \"past\": \"in ...\" -> \"... ago\".\r\n\t// Therefore, the label should be updated at zero-point too.\r\n\tconst minTime = getStepMinTime(currentOrNextStep, { timestamp, now, future, round, prevStep })\r\n\tif (minTime === undefined) {\r\n\t\treturn\r\n\t}\r\n\tif (future) {\r\n\t\t// The step changes to the previous step\r\n\t\t// as soon as `timestamp - now` becomes\r\n\t\t// less than the `minTime` of the current step:\r\n\t\t// `timestamp - now === minTime - 1`\r\n\t\t// => `now === timestamp - minTime + 1`.\r\n\t\treturn timestamp - minTime * 1000 + 1\r\n\t} else {\r\n\t\t// The step changes to the next step\r\n\t\t// as soon as `now - timestamp` becomes\r\n\t\t// equal to `minTime` of the next step:\r\n\t\t// `now - timestamp === minTime`\r\n\t\t// => `now === timestamp + minTime`.\r\n\r\n\t\t// This is a special case when double-update could be skipped.\r\n\t\tif (minTime === 0 && timestamp === now) {\r\n\t\t\treturn INFINITY\r\n\t\t}\r\n\r\n\t\treturn timestamp + minTime * 1000\r\n\t}\r\n}\r\n\r\nexport function getTimeToStepChange(step, timestamp, {\r\n\tnow,\r\n\tfuture,\r\n\tround,\r\n\tprevStep\r\n}) {\r\n\tif (step) {\r\n\t\tconst stepChangesAt = getStepChangesAt(step, timestamp, {\r\n\t\t\tnow,\r\n\t\t\tfuture,\r\n\t\t\tround,\r\n\t\t\tprevStep\r\n\t\t})\r\n\t\tif (stepChangesAt === undefined) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\treturn stepChangesAt - now\r\n\t} else {\r\n\t\tif (future) {\r\n\t\t\t// No step.\r\n\t\t\t// Update right after zero point, when it changes from \"future\" to \"past\".\r\n\t\t\treturn timestamp - now + 1\r\n\t\t} else {\r\n\t\t\t// The last step doesn't ever change when `date` is in the past.\r\n\t\t\treturn INFINITY\r\n\t\t}\r\n\t}\r\n}"],"mappings":";;;;;;;;;AAAA,IAAAA,4BAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAA8C,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAE9C;AACA,IAAME,IAAI,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,I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AAIA,OAAO,KAAK,CAAC,IAAIhB,SAAS,KAAKH,GAAG,EAAE;MACvC,OAAOR,QAAQ;IAChB;IAEA,OAAOW,SAAS,GAAGgB,OAAO,GAAG,IAAI;EAClC;AACD;AAEO,SAASV,mBAAmBA,CAACb,IAAI,EAAEO,SAAS,EAAAkB,KAAA,EAKhD;EAAA,IAJFrB,GAAG,GAAAqB,KAAA,CAAHrB,GAAG;IACHC,MAAM,GAAAoB,KAAA,CAANpB,MAAM;IACNC,KAAK,GAAAmB,KAAA,CAALnB,KAAK;IACLJ,QAAQ,GAAAuB,KAAA,CAARvB,QAAQ;EAER,IAAIF,IAAI,EAAE;IACT,IAAM0B,aAAa,GAAGN,gBAAgB,CAACpB,IAAI,EAAEO,SAAS,EAAE;MACvDH,GAAG,EAAHA,GAAG;MACHC,MAAM,EAANA,MAAM;MACNC,KAAK,EAALA,KAAK;MACLJ,QAAQ,EAARA;IACD,CAAC,CAAC;IACF,IAAIwB,aAAa,KAAKZ,SAAS,EAAE;MAChC;IACD;IACA,OAAOY,aAAa,GAAGtB,GAAG;EAC3B,CAAC,MAAM;IACN,IAAIC,MAAM,EAAE;MACX;MACA;MACA,OAAOE,SAAS,GAAGH,GAAG,GAAG,CAAC;IAC3B,CAAC,MAAM;MACN;MACA,OAAOR,QAAQ;IAChB;EACD;AACD","ignoreList":[]}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
3
|
+
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); }
|
|
5
4
|
var _getTimeToNextUpdate = _interopRequireWildcard(require("./getTimeToNextUpdate.js"));
|
|
6
|
-
|
|
7
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
8
|
-
|
|
9
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
-
|
|
5
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) { "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); } return f; })(e, t); }
|
|
11
6
|
describe('getTimeToNextUpdate', function () {
|
|
12
7
|
it('should return infinity when there are no more steps, and it does not format as a unit (past)', function () {
|
|
13
8
|
expect((0, _getTimeToNextUpdate["default"])(-4 * 60 * 1000, {
|
|
@@ -175,11 +170,12 @@ describe('getStepChangesAt', function () {
|
|
|
175
170
|
now: 0,
|
|
176
171
|
future: false,
|
|
177
172
|
prevStep: undefined
|
|
178
|
-
}).should.equal(_getTimeToNextUpdate.INFINITY);
|
|
173
|
+
}).should.equal(_getTimeToNextUpdate.INFINITY);
|
|
174
|
+
|
|
175
|
+
// Past.
|
|
179
176
|
// Is at zero point.
|
|
180
177
|
// The next step is seconds.
|
|
181
178
|
// Updates at the next step.
|
|
182
|
-
|
|
183
179
|
(0, _getTimeToNextUpdate.getStepChangesAt)({
|
|
184
180
|
unit: 'second',
|
|
185
181
|
minTime: 1
|
|
@@ -187,32 +183,35 @@ describe('getStepChangesAt', function () {
|
|
|
187
183
|
now: 0,
|
|
188
184
|
future: false,
|
|
189
185
|
prevStep: {}
|
|
190
|
-
}).should.equal(1 * 1000);
|
|
186
|
+
}).should.equal(1 * 1000);
|
|
187
|
+
|
|
188
|
+
// Future.
|
|
191
189
|
// Inside the first step.
|
|
192
190
|
// Updates after zero point.
|
|
193
|
-
|
|
194
191
|
(0, _getTimeToNextUpdate.getStepChangesAt)({
|
|
195
192
|
unit: 'now'
|
|
196
193
|
}, 0.9 * 1000, {
|
|
197
194
|
now: 0,
|
|
198
195
|
future: true,
|
|
199
196
|
prevStep: undefined
|
|
200
|
-
}).should.equal(0.9 * 1000 + 1);
|
|
197
|
+
}).should.equal(0.9 * 1000 + 1);
|
|
198
|
+
|
|
199
|
+
// Future.
|
|
201
200
|
// The first step doesn't start at 0.
|
|
202
201
|
// Outside of the first step.
|
|
203
202
|
// Updates right after zero point.
|
|
204
|
-
|
|
205
203
|
(0, _getTimeToNextUpdate.getTimeToStepChange)(undefined, 0.9 * 1000, {
|
|
206
204
|
now: 0,
|
|
207
205
|
future: true,
|
|
208
206
|
prevStep: undefined
|
|
209
|
-
}).should.equal(0.9 * 1000 + 1);
|
|
207
|
+
}).should.equal(0.9 * 1000 + 1);
|
|
208
|
+
|
|
209
|
+
// Past.
|
|
210
210
|
// The current step is `undefined`.
|
|
211
211
|
// The next step is the first step.
|
|
212
212
|
// The first step doesn't start at 0.
|
|
213
213
|
// Outside of the first step.
|
|
214
214
|
// Updates at entering the first step.
|
|
215
|
-
|
|
216
215
|
(0, _getTimeToNextUpdate.getStepChangesAt)({
|
|
217
216
|
minTime: 1,
|
|
218
217
|
unit: 'second'
|
|
@@ -220,10 +219,11 @@ describe('getStepChangesAt', function () {
|
|
|
220
219
|
now: 0,
|
|
221
220
|
future: false,
|
|
222
221
|
prevStep: {}
|
|
223
|
-
}).should.equal(0.1 * 1000);
|
|
222
|
+
}).should.equal(0.1 * 1000);
|
|
223
|
+
|
|
224
|
+
// Future.
|
|
224
225
|
// The first step doesn't start at 0.
|
|
225
226
|
// Will output empty string after it exits the current step.
|
|
226
|
-
|
|
227
227
|
(0, _getTimeToNextUpdate.getStepChangesAt)({
|
|
228
228
|
minTime: 1,
|
|
229
229
|
unit: 'second'
|
|
@@ -231,39 +231,43 @@ describe('getStepChangesAt', function () {
|
|
|
231
231
|
now: 0,
|
|
232
232
|
future: true,
|
|
233
233
|
prevStep: undefined
|
|
234
|
-
}).should.equal(0.1 * 1000 + 1);
|
|
234
|
+
}).should.equal(0.1 * 1000 + 1);
|
|
235
|
+
|
|
236
|
+
// Past.
|
|
235
237
|
// Next step is seconds.
|
|
236
238
|
// The "next" step doesn't have `minTime`,
|
|
237
239
|
// so "time to next update" couldn't be determined.
|
|
238
|
-
|
|
239
240
|
expect((0, _getTimeToNextUpdate.getStepChangesAt)({
|
|
240
241
|
unit: 'unknown-time-unit'
|
|
241
242
|
}, 0, {
|
|
242
243
|
now: 0,
|
|
243
244
|
future: false,
|
|
244
245
|
prevStep: {}
|
|
245
|
-
})).to.be.undefined;
|
|
246
|
+
})).to.be.undefined;
|
|
247
|
+
|
|
248
|
+
// Past.
|
|
246
249
|
// No next step.
|
|
247
250
|
// The last step never changes.
|
|
248
|
-
|
|
249
251
|
(0, _getTimeToNextUpdate.getTimeToStepChange)(undefined, 0, {
|
|
250
252
|
now: 0,
|
|
251
253
|
future: false,
|
|
252
254
|
isFirstStep: undefined
|
|
253
|
-
}).should.equal(_getTimeToNextUpdate.INFINITY);
|
|
255
|
+
}).should.equal(_getTimeToNextUpdate.INFINITY);
|
|
256
|
+
|
|
257
|
+
// Future.
|
|
254
258
|
// Current step is seconds.
|
|
255
259
|
// Updates after zero point.
|
|
256
|
-
|
|
257
260
|
(0, _getTimeToNextUpdate.getStepChangesAt)({
|
|
258
261
|
unit: 'second'
|
|
259
262
|
}, 0, {
|
|
260
263
|
now: 0,
|
|
261
264
|
future: true,
|
|
262
265
|
prevStep: undefined
|
|
263
|
-
}).should.equal(1);
|
|
266
|
+
}).should.equal(1);
|
|
267
|
+
|
|
268
|
+
// Past.
|
|
264
269
|
// Next step is minutes.
|
|
265
270
|
// Already at zero point, so no need to update at zero point.
|
|
266
|
-
|
|
267
271
|
(0, _getTimeToNextUpdate.getStepChangesAt)({
|
|
268
272
|
minTime: 60,
|
|
269
273
|
formatAs: 'minute'
|