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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTimeToNextUpdate.test.js","names":["describe","it","expect","getTimeToNextUpdate","minTime","format","now","future","isFirstStep","to","equal","INFINITY","Date","nextStep","formatAs","be","undefined","should","test","getStepChangesAt","unit","prevStep","getTimeToStepChange"],"sources":["../../source/steps/getTimeToNextUpdate.test.js"],"sourcesContent":["import getTimeToNextUpdate, { INFINITY, getStepChangesAt, getTimeToStepChange } from './getTimeToNextUpdate.js'\r\n\r\ndescribe('getTimeToNextUpdate', () => {\r\n\tit('should return infinity when there are no more steps, and it does not format as a unit (past)', () => {\r\n\t\texpect(getTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tminTime: 59.5,\r\n\t\t\tformat: () => ''\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true\r\n\t\t})).to.equal(INFINITY)\r\n\t})\r\n\r\n\tit('should support date argument', () => {\r\n\t\texpect(getTimeToNextUpdate(new Date(4 * 60 * 1000), {\r\n\t\t\tminTime: 60\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {}\r\n\t\t})).to.equal(3 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should return this step\\'s \"minTime\" timestamp (future)', () => {\r\n\t\texpect(getTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tminTime: 60,\r\n\t\t\tformat: () => ''\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformat: () => ''\r\n\t\t\t}\r\n\t\t})).to.equal(3 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should return undefined when there is a next step and time to next update can not be reliably determined (formatAs) (past)', () => {\r\n\t\texpect(getTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tminTime: 60,\r\n\t\t\tformatAs: 'minute'\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'unknown-time-unit'\r\n\t\t\t}\r\n\t\t})).to.be.undefined\r\n\t})\r\n\r\n\tit('should get time to next update (no next step) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.5 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (no next step) (future)', () => {\r\n\t\tgetTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.5 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should get time to next update (has prev/next step without `minTime`) (future)', () => {\r\n\t\tgetTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'hour',\r\n\t\t\t\ttest: () => false\r\n\t\t\t}\r\n\t\t}).should.equal(0.5 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should get time to next update (has `getTimeToNextUpdate`) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5,\r\n\t\t\tgetTimeToNextUpdate: () => 0.25 * 60 * 1000\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.25 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (has `getTimeToNextUpdate`) (future)', () => {\r\n\t\tgetTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5,\r\n\t\t\tgetTimeToNextUpdate: () => 0.25 * 60 * 1000\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.25 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (has both unit and prev/next steps with `minTime`) (returns time to \"minTime\" of next step) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-59 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'hour',\r\n\t\t\t\tminTime: 59.5 * 60\r\n\t\t\t}\r\n\t\t}).should.equal(0.5 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (has no unit but has prev/next step with `minTime`) (returns time to \"minTime\" of next step) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-59 * 60 * 1000, {\r\n\t\t\tformat: () => {},\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'hour',\r\n\t\t\t\tminTime: 59.5 * 60\r\n\t\t\t}\r\n\t\t}).should.equal(0.5 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (will be outside of the first step) (future)', () => {\r\n\t\tgetTimeToNextUpdate(60 * 60 * 1000, {\r\n\t\t\tformatAs: 'hour',\r\n\t\t\tminTime: 60 * 60\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(1)\r\n\t})\r\n})\r\n\r\ndescribe('getStepChangesAt', () => {\r\n\tit('should work for \"round\" steps', () => {\r\n\t\t// Future.\r\n\t\t// Is at zero point.\r\n\t\t// No next step.\r\n\t\t// No tickable unit.\r\n\t\t// Doesn't update.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'now'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(INFINITY)\r\n\r\n\t\t// Past.\r\n\t\t// Is at zero point.\r\n\t\t// The next step is seconds.\r\n\t\t// Updates at the next step.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'second',\r\n\t\t\tminTime: 1\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t}).should.equal(1 * 1000)\r\n\r\n\t\t// Future.\r\n\t\t// Inside the first step.\r\n\t\t// Updates after zero point.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'now'\r\n\t\t}, 0.9 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(0.9 * 1000 + 1)\r\n\r\n\t\t// Future.\r\n\t\t// The first step doesn't start at 0.\r\n\t\t// Outside of the first step.\r\n\t\t// Updates right after zero point.\r\n\t\tgetTimeToStepChange(undefined, 0.9 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(0.9 * 1000 + 1)\r\n\r\n\t\t// Past.\r\n\t\t// The current step is `undefined`.\r\n\t\t// The next step is the first step.\r\n\t\t// The first step doesn't start at 0.\r\n\t\t// Outside of the first step.\r\n\t\t// Updates at entering the first step.\r\n\t\tgetStepChangesAt({\r\n\t\t\tminTime: 1,\r\n\t\t\tunit: 'second'\r\n\t\t}, -0.9 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t}).should.equal(0.1 * 1000)\r\n\r\n\t\t// Future.\r\n\t\t// The first step doesn't start at 0.\r\n\t\t// Will output empty string after it exits the current step.\r\n\t\tgetStepChangesAt({\r\n\t\t\tminTime: 1,\r\n\t\t\tunit: 'second'\r\n\t\t}, 1.1 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(0.1 * 1000 + 1)\r\n\r\n\t\t// Past.\r\n\t\t// Next step is seconds.\r\n\t\t// The \"next\" step doesn't have `minTime`,\r\n\t\t// so \"time to next update\" couldn't be determined.\r\n\t\texpect(getStepChangesAt({\r\n\t\t\tunit: 'unknown-time-unit'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t})).to.be.undefined\r\n\r\n\t\t// Past.\r\n\t\t// No next step.\r\n\t\t// The last step never changes.\r\n\t\tgetTimeToStepChange(undefined, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: undefined\r\n\t\t}).should.equal(INFINITY)\r\n\r\n\t\t// Future.\r\n\t\t// Current step is seconds.\r\n\t\t// Updates after zero point.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'second'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(1)\r\n\r\n\t\t// Past.\r\n\t\t// Next step is minutes.\r\n\t\t// Already at zero point, so no need to update at zero point.\r\n\t\tgetStepChangesAt({\r\n\t\t\tminTime: 60,\r\n\t\t\tformatAs: 'minute'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t}).should.equal(60 * 1000)\r\n\t})\r\n})"],"mappings":";;;;AAAA;;;;;;AAEAA,QAAQ,CAAC,qBAAD,EAAwB,YAAM;EACrCC,EAAE,CAAC,8FAAD,EAAiG,YAAM;IACxGC,MAAM,CAAC,IAAAC,+BAAA,EAAoB,CAAC,CAAD,GAAK,EAAL,GAAU,IAA9B,EAAoC;MAC1CC,OAAO,EAAE,IADiC;MAE1CC,MAAM,EAAE;QAAA,OAAM,EAAN;MAAA;IAFkC,CAApC,EAGJ;MACFC,GAAG,EAAE,CADH;MAEFC,MAA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E;IADiB,CAAjB,EAEJ,CAFI,EAED;MACLd,GAAG,EAAE,CADA;MAELC,MAAM,EAAE,KAFH;MAGLc,QAAQ,EAAE;IAHL,CAFC,CAAD,CAAN,CAMIZ,EANJ,CAMOM,EANP,CAMUC,SANV,CA/EyC,CAuFzC;IACA;IACA;;IACA,IAAAM,wCAAA,EAAoBN,SAApB,EAA+B,CAA/B,EAAkC;MACjCV,GAAG,EAAE,CAD4B;MAEjCC,MAAM,EAAE,KAFyB;MAGjCC,WAAW,EAAEQ;IAHoB,CAAlC,EAIGC,MAJH,CAIUP,KAJV,CAIgBC,6BAJhB,EA1FyC,CAgGzC;IACA;IACA;;IACA,IAAAQ,qCAAA,EAAiB;MAChBC,IAAI,EAAE;IADU,CAAjB,EAEG,CAFH,EAEM;MACLd,GAAG,EAAE,CADA;MAELC,MAAM,EAAE,IAFH;MAGLc,QAAQ,EAAEL;IAHL,CAFN,EAMGC,MANH,CAMUP,KANV,CAMgB,CANhB,EAnGyC,CA2GzC;IACA;IACA;;IACA,IAAAS,qCAAA,EAAiB;MAChBf,OAAO,EAAE,EADO;MAEhBU,QAAQ,EAAE;IAFM,CAAjB,EAGG,CAHH,EAGM;MACLR,GAAG,EAAE,CADA;MAELC,MAAM,EAAE,KAFH;MAGLc,QAAQ,EAAE;IAHL,CAHN,EAOGJ,MAPH,CAOUP,KAPV,CAOgB,KAAK,IAPrB;EAQA,CAtHC,CAAF;AAuHA,CAxHO,CAAR"}
|
|
1
|
+
{"version":3,"file":"getTimeToNextUpdate.test.js","names":["_getTimeToNextUpdate","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","describe","it","expect","getTimeToNextUpdate","minTime","format","now","future","isFirstStep","to","equal","INFINITY","Date","nextStep","formatAs","be","undefined","should","test","getStepChangesAt","unit","prevStep","getTimeToStepChange"],"sources":["../../source/steps/getTimeToNextUpdate.test.js"],"sourcesContent":["import getTimeToNextUpdate, { INFINITY, getStepChangesAt, getTimeToStepChange } from './getTimeToNextUpdate.js'\r\n\r\ndescribe('getTimeToNextUpdate', () => {\r\n\tit('should return infinity when there are no more steps, and it does not format as a unit (past)', () => {\r\n\t\texpect(getTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tminTime: 59.5,\r\n\t\t\tformat: () => ''\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true\r\n\t\t})).to.equal(INFINITY)\r\n\t})\r\n\r\n\tit('should support date argument', () => {\r\n\t\texpect(getTimeToNextUpdate(new Date(4 * 60 * 1000), {\r\n\t\t\tminTime: 60\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {}\r\n\t\t})).to.equal(3 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should return this step\\'s \"minTime\" timestamp (future)', () => {\r\n\t\texpect(getTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tminTime: 60,\r\n\t\t\tformat: () => ''\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformat: () => ''\r\n\t\t\t}\r\n\t\t})).to.equal(3 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should return undefined when there is a next step and time to next update can not be reliably determined (formatAs) (past)', () => {\r\n\t\texpect(getTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tminTime: 60,\r\n\t\t\tformatAs: 'minute'\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'unknown-time-unit'\r\n\t\t\t}\r\n\t\t})).to.be.undefined\r\n\t})\r\n\r\n\tit('should get time to next update (no next step) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.5 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (no next step) (future)', () => {\r\n\t\tgetTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.5 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should get time to next update (has prev/next step without `minTime`) (future)', () => {\r\n\t\tgetTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'hour',\r\n\t\t\t\ttest: () => false\r\n\t\t\t}\r\n\t\t}).should.equal(0.5 * 60 * 1000 + 1)\r\n\t})\r\n\r\n\tit('should get time to next update (has `getTimeToNextUpdate`) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5,\r\n\t\t\tgetTimeToNextUpdate: () => 0.25 * 60 * 1000\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.25 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (has `getTimeToNextUpdate`) (future)', () => {\r\n\t\tgetTimeToNextUpdate(4 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5,\r\n\t\t\tgetTimeToNextUpdate: () => 0.25 * 60 * 1000\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(0.25 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (has both unit and prev/next steps with `minTime`) (returns time to \"minTime\" of next step) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-59 * 60 * 1000, {\r\n\t\t\tformatAs: 'minute',\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'hour',\r\n\t\t\t\tminTime: 59.5 * 60\r\n\t\t\t}\r\n\t\t}).should.equal(0.5 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (has no unit but has prev/next step with `minTime`) (returns time to \"minTime\" of next step) (past)', () => {\r\n\t\tgetTimeToNextUpdate(-59 * 60 * 1000, {\r\n\t\t\tformat: () => {},\r\n\t\t\tminTime: 59.5\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: true,\r\n\t\t\tnextStep: {\r\n\t\t\t\tformatAs: 'hour',\r\n\t\t\t\tminTime: 59.5 * 60\r\n\t\t\t}\r\n\t\t}).should.equal(0.5 * 60 * 1000)\r\n\t})\r\n\r\n\tit('should get time to next update (will be outside of the first step) (future)', () => {\r\n\t\tgetTimeToNextUpdate(60 * 60 * 1000, {\r\n\t\t\tformatAs: 'hour',\r\n\t\t\tminTime: 60 * 60\r\n\t\t}, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tisFirstStep: true\r\n\t\t}).should.equal(1)\r\n\t})\r\n})\r\n\r\ndescribe('getStepChangesAt', () => {\r\n\tit('should work for \"round\" steps', () => {\r\n\t\t// Future.\r\n\t\t// Is at zero point.\r\n\t\t// No next step.\r\n\t\t// No tickable unit.\r\n\t\t// Doesn't update.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'now'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(INFINITY)\r\n\r\n\t\t// Past.\r\n\t\t// Is at zero point.\r\n\t\t// The next step is seconds.\r\n\t\t// Updates at the next step.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'second',\r\n\t\t\tminTime: 1\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t}).should.equal(1 * 1000)\r\n\r\n\t\t// Future.\r\n\t\t// Inside the first step.\r\n\t\t// Updates after zero point.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'now'\r\n\t\t}, 0.9 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(0.9 * 1000 + 1)\r\n\r\n\t\t// Future.\r\n\t\t// The first step doesn't start at 0.\r\n\t\t// Outside of the first step.\r\n\t\t// Updates right after zero point.\r\n\t\tgetTimeToStepChange(undefined, 0.9 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(0.9 * 1000 + 1)\r\n\r\n\t\t// Past.\r\n\t\t// The current step is `undefined`.\r\n\t\t// The next step is the first step.\r\n\t\t// The first step doesn't start at 0.\r\n\t\t// Outside of the first step.\r\n\t\t// Updates at entering the first step.\r\n\t\tgetStepChangesAt({\r\n\t\t\tminTime: 1,\r\n\t\t\tunit: 'second'\r\n\t\t}, -0.9 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t}).should.equal(0.1 * 1000)\r\n\r\n\t\t// Future.\r\n\t\t// The first step doesn't start at 0.\r\n\t\t// Will output empty string after it exits the current step.\r\n\t\tgetStepChangesAt({\r\n\t\t\tminTime: 1,\r\n\t\t\tunit: 'second'\r\n\t\t}, 1.1 * 1000, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(0.1 * 1000 + 1)\r\n\r\n\t\t// Past.\r\n\t\t// Next step is seconds.\r\n\t\t// The \"next\" step doesn't have `minTime`,\r\n\t\t// so \"time to next update\" couldn't be determined.\r\n\t\texpect(getStepChangesAt({\r\n\t\t\tunit: 'unknown-time-unit'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t})).to.be.undefined\r\n\r\n\t\t// Past.\r\n\t\t// No next step.\r\n\t\t// The last step never changes.\r\n\t\tgetTimeToStepChange(undefined, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tisFirstStep: undefined\r\n\t\t}).should.equal(INFINITY)\r\n\r\n\t\t// Future.\r\n\t\t// Current step is seconds.\r\n\t\t// Updates after zero point.\r\n\t\tgetStepChangesAt({\r\n\t\t\tunit: 'second'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: true,\r\n\t\t\tprevStep: undefined\r\n\t\t}).should.equal(1)\r\n\r\n\t\t// Past.\r\n\t\t// Next step is minutes.\r\n\t\t// Already at zero point, so no need to update at zero point.\r\n\t\tgetStepChangesAt({\r\n\t\t\tminTime: 60,\r\n\t\t\tformatAs: 'minute'\r\n\t\t}, 0, {\r\n\t\t\tnow: 0,\r\n\t\t\tfuture: false,\r\n\t\t\tprevStep: {}\r\n\t\t}).should.equal(60 * 1000)\r\n\t})\r\n})"],"mappings":";;;AAAA,IAAAA,oBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA+G,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ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,GAAG,CAAC,CAAC;;IAE/B;IACA;IACA;IACA;IACAR,MAAM,CAAC,IAAAiB,qCAAgB,EAAC;MACvBC,IAAI,EAAE;IACP,CAAC,EAAE,CAAC,EAAE;MACLd,GAAG,EAAE,CAAC;MACNC,MAAM,EAAE,KAAK;MACbc,QAAQ,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC,CAACZ,EAAE,CAACM,EAAE,CAACC,SAAS;;IAEnB;IACA;IACA;IACA,IAAAM,wCAAmB,EAACN,SAAS,EAAE,CAAC,EAAE;MACjCV,GAAG,EAAE,CAAC;MACNC,MAAM,EAAE,KAAK;MACbC,WAAW,EAAEQ;IACd,CAAC,CAAC,CAACC,MAAM,CAACP,KAAK,CAACC,6BAAQ,CAAC;;IAEzB;IACA;IACA;IACA,IAAAQ,qCAAgB,EAAC;MAChBC,IAAI,EAAE;IACP,CAAC,EAAE,CAAC,EAAE;MACLd,GAAG,EAAE,CAAC;MACNC,MAAM,EAAE,IAAI;MACZc,QAAQ,EAAEL;IACX,CAAC,CAAC,CAACC,MAAM,CAACP,KAAK,CAAC,CAAC,CAAC;;IAElB;IACA;IACA;IACA,IAAAS,qCAAgB,EAAC;MAChBf,OAAO,EAAE,EAAE;MACXU,QAAQ,EAAE;IACX,CAAC,EAAE,CAAC,EAAE;MACLR,GAAG,EAAE,CAAC;MACNC,MAAM,EAAE,KAAK;MACbc,QAAQ,EAAE,CAAC;IACZ,CAAC,CAAC,CAACJ,MAAM,CAACP,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC;EAC3B,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = getTimeToNextUpdateForUnit;
|
|
7
|
-
|
|
8
7
|
var _units = require("./units.js");
|
|
9
|
-
|
|
10
8
|
var _round = require("../round.js");
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Gets the time to next update for a step with a time unit defined.
|
|
14
11
|
* @param {string} unit
|
|
@@ -19,20 +16,17 @@ var _round = require("../round.js");
|
|
|
19
16
|
*/
|
|
20
17
|
function getTimeToNextUpdateForUnit(unit, timestamp, _ref) {
|
|
21
18
|
var now = _ref.now,
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
round = _ref.round;
|
|
24
20
|
// For some units, like "now", there's no defined amount of seconds in them.
|
|
25
21
|
if (!(0, _units.getSecondsInUnit)(unit)) {
|
|
26
22
|
// If there's no amount of seconds defined for this unit
|
|
27
23
|
// then the update interval can't be determined reliably.
|
|
28
24
|
return;
|
|
29
25
|
}
|
|
30
|
-
|
|
31
26
|
var unitDenominator = (0, _units.getSecondsInUnit)(unit) * 1000;
|
|
32
27
|
var future = timestamp > now;
|
|
33
28
|
var preciseAmount = Math.abs(timestamp - now);
|
|
34
29
|
var roundedAmount = (0, _round.getRoundFunction)(round)(preciseAmount / unitDenominator) * unitDenominator;
|
|
35
|
-
|
|
36
30
|
if (future) {
|
|
37
31
|
if (roundedAmount > 0) {
|
|
38
32
|
// Amount decreases with time.
|
|
@@ -42,16 +36,13 @@ function getTimeToNextUpdateForUnit(unit, timestamp, _ref) {
|
|
|
42
36
|
// when "future" changes to "past".
|
|
43
37
|
return preciseAmount - roundedAmount + 1;
|
|
44
38
|
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
}
|
|
40
|
+
// Amount increases with time.
|
|
48
41
|
return -(preciseAmount - roundedAmount) + getDiffToNextRoundedNumber(round, unitDenominator);
|
|
49
42
|
}
|
|
50
|
-
|
|
51
43
|
function getDiffToNextRoundedNumber(round, unitDenominator) {
|
|
52
44
|
return (0, _round.getDiffRatioToNextRoundedNumber)(round) * unitDenominator;
|
|
53
45
|
}
|
|
54
|
-
|
|
55
46
|
function getDiffToPreviousRoundedNumber(round, unitDenominator) {
|
|
56
47
|
return (1 - (0, _round.getDiffRatioToNextRoundedNumber)(round)) * unitDenominator + 1;
|
|
57
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTimeToNextUpdateForUnit.js","names":["getTimeToNextUpdateForUnit","unit","timestamp","now","round","getSecondsInUnit","unitDenominator","future","preciseAmount","Math","abs","roundedAmount","getRoundFunction","getDiffToPreviousRoundedNumber","getDiffToNextRoundedNumber","getDiffRatioToNextRoundedNumber"],"sources":["../../source/steps/getTimeToNextUpdateForUnit.js"],"sourcesContent":["import { getSecondsInUnit } from './units.js'\r\nimport { getRoundFunction, getDiffRatioToNextRoundedNumber } from '../round.js'\r\n\r\n/**\r\n * Gets the time to next update for a step with a time unit defined.\r\n * @param {string} unit\r\n * @param {number} date — The date passed to `.format()`, converted to a timestamp.\r\n * @param {number} options.now\r\n * @param {string} [options.round] — (undocumented) Rounding mechanism.\r\n * @return {number} [timeToNextUpdate]\r\n */\r\nexport default function getTimeToNextUpdateForUnit(unit, timestamp, { now, round }) {\r\n\t// For some units, like \"now\", there's no defined amount of seconds in them.\r\n\tif (!getSecondsInUnit(unit)) {\r\n\t\t// If there's no amount of seconds defined for this unit\r\n\t\t// then the update interval can't be determined reliably.\r\n\t\treturn\r\n\t}\r\n\tconst unitDenominator = getSecondsInUnit(unit) * 1000\r\n\tconst future = timestamp > now\r\n\tconst preciseAmount = Math.abs(timestamp - now)\r\n\tconst roundedAmount = getRoundFunction(round)(preciseAmount / unitDenominator) * unitDenominator\r\n\tif (future) {\r\n\t\tif (roundedAmount > 0) {\r\n\t\t\t// Amount decreases with time.\r\n\t\t\treturn (preciseAmount - roundedAmount) +\r\n\t\t\t\tgetDiffToPreviousRoundedNumber(round, unitDenominator)\r\n\t\t} else {\r\n\t\t\t// Refresh right after the zero point,\r\n\t\t\t// when \"future\" changes to \"past\".\r\n\t\t\treturn (preciseAmount - roundedAmount) + 1\r\n\t\t}\r\n\t}\r\n \t// Amount increases with time.\r\n\treturn -(preciseAmount - roundedAmount) + getDiffToNextRoundedNumber(round, unitDenominator)\r\n}\r\n\r\nfunction getDiffToNextRoundedNumber(round, unitDenominator) {\r\n\treturn getDiffRatioToNextRoundedNumber(round) * unitDenominator\r\n}\r\n\r\nfunction getDiffToPreviousRoundedNumber(round, unitDenominator) {\r\n\treturn (1 - getDiffRatioToNextRoundedNumber(round)) * unitDenominator + 1\r\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getTimeToNextUpdateForUnit.js","names":["_units","require","_round","getTimeToNextUpdateForUnit","unit","timestamp","_ref","now","round","getSecondsInUnit","unitDenominator","future","preciseAmount","Math","abs","roundedAmount","getRoundFunction","getDiffToPreviousRoundedNumber","getDiffToNextRoundedNumber","getDiffRatioToNextRoundedNumber"],"sources":["../../source/steps/getTimeToNextUpdateForUnit.js"],"sourcesContent":["import { getSecondsInUnit } from './units.js'\r\nimport { getRoundFunction, getDiffRatioToNextRoundedNumber } from '../round.js'\r\n\r\n/**\r\n * Gets the time to next update for a step with a time unit defined.\r\n * @param {string} unit\r\n * @param {number} date — The date passed to `.format()`, converted to a timestamp.\r\n * @param {number} options.now\r\n * @param {string} [options.round] — (undocumented) Rounding mechanism.\r\n * @return {number} [timeToNextUpdate]\r\n */\r\nexport default function getTimeToNextUpdateForUnit(unit, timestamp, { now, round }) {\r\n\t// For some units, like \"now\", there's no defined amount of seconds in them.\r\n\tif (!getSecondsInUnit(unit)) {\r\n\t\t// If there's no amount of seconds defined for this unit\r\n\t\t// then the update interval can't be determined reliably.\r\n\t\treturn\r\n\t}\r\n\tconst unitDenominator = getSecondsInUnit(unit) * 1000\r\n\tconst future = timestamp > now\r\n\tconst preciseAmount = Math.abs(timestamp - now)\r\n\tconst roundedAmount = getRoundFunction(round)(preciseAmount / unitDenominator) * unitDenominator\r\n\tif (future) {\r\n\t\tif (roundedAmount > 0) {\r\n\t\t\t// Amount decreases with time.\r\n\t\t\treturn (preciseAmount - roundedAmount) +\r\n\t\t\t\tgetDiffToPreviousRoundedNumber(round, unitDenominator)\r\n\t\t} else {\r\n\t\t\t// Refresh right after the zero point,\r\n\t\t\t// when \"future\" changes to \"past\".\r\n\t\t\treturn (preciseAmount - roundedAmount) + 1\r\n\t\t}\r\n\t}\r\n \t// Amount increases with time.\r\n\treturn -(preciseAmount - roundedAmount) + getDiffToNextRoundedNumber(round, unitDenominator)\r\n}\r\n\r\nfunction getDiffToNextRoundedNumber(round, unitDenominator) {\r\n\treturn getDiffRatioToNextRoundedNumber(round) * unitDenominator\r\n}\r\n\r\nfunction getDiffToPreviousRoundedNumber(round, unitDenominator) {\r\n\treturn (1 - getDiffRatioToNextRoundedNumber(round)) * unitDenominator + 1\r\n}"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,0BAA0BA,CAACC,IAAI,EAAEC,SAAS,EAAAC,IAAA,EAAkB;EAAA,IAAdC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IAAEC,KAAK,GAAAF,IAAA,CAALE,KAAK;EAC/E;EACA,IAAI,CAAC,IAAAC,uBAAgB,EAACL,IAAI,CAAC,EAAE;IAC5B;IACA;IACA;EACD;EACA,IAAMM,eAAe,GAAG,IAAAD,uBAAgB,EAACL,IAAI,CAAC,GAAG,IAAI;EACrD,IAAMO,MAAM,GAAGN,SAAS,GAAGE,GAAG;EAC9B,IAAMK,aAAa,GAAGC,IAAI,CAACC,GAAG,CAACT,SAAS,GAAGE,GAAG,CAAC;EAC/C,IAAMQ,aAAa,GAAG,IAAAC,uBAAgB,EAACR,KAAK,CAAC,CAACI,aAAa,GAAGF,eAAe,CAAC,GAAGA,eAAe;EAChG,IAAIC,MAAM,EAAE;IACX,IAAII,aAAa,GAAG,CAAC,EAAE;MACtB;MACA,OAAQH,aAAa,GAAGG,aAAa,GACpCE,8BAA8B,CAACT,KAAK,EAAEE,eAAe,CAAC;IACxD,CAAC,MAAM;MACN;MACA;MACA,OAAQE,aAAa,GAAGG,aAAa,GAAI,CAAC;IAC3C;EACD;EACC;EACD,OAAO,EAAEH,aAAa,GAAGG,aAAa,CAAC,GAAGG,0BAA0B,CAACV,KAAK,EAAEE,eAAe,CAAC;AAC7F;AAEA,SAASQ,0BAA0BA,CAACV,KAAK,EAAEE,eAAe,EAAE;EAC3D,OAAO,IAAAS,sCAA+B,EAACX,KAAK,CAAC,GAAGE,eAAe;AAChE;AAEA,SAASO,8BAA8BA,CAACT,KAAK,EAAEE,eAAe,EAAE;EAC/D,OAAO,CAAC,CAAC,GAAG,IAAAS,sCAA+B,EAACX,KAAK,CAAC,IAAIE,eAAe,GAAG,CAAC;AAC1E","ignoreList":[]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getTimeToNextUpdateForUnit = _interopRequireDefault(require("./getTimeToNextUpdateForUnit.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('getTimeToNextUpdateForUnit', function () {
|
|
8
6
|
it('should return undefined for unknown units', function () {
|
|
9
7
|
expect((0, _getTimeToNextUpdateForUnit["default"])('now', 0, {})).to.be.undefined;
|
|
@@ -22,7 +20,6 @@ describe('getTimeToNextUpdateForUnit', function () {
|
|
|
22
20
|
now: 0
|
|
23
21
|
}).should.equal(expected * 1000 + (addOneMs ? 1 : 0));
|
|
24
22
|
};
|
|
25
|
-
|
|
26
23
|
test(9, 0.5);
|
|
27
24
|
test(9.1, 0.6);
|
|
28
25
|
test(9.4, 0.9);
|
|
@@ -44,7 +41,6 @@ describe('getTimeToNextUpdateForUnit', function () {
|
|
|
44
41
|
now: 0
|
|
45
42
|
}).should.equal(expected * 1000);
|
|
46
43
|
};
|
|
47
|
-
|
|
48
44
|
test(10, 0.5);
|
|
49
45
|
test(9.9, 0.6);
|
|
50
46
|
test(9.5, 1);
|
|
@@ -66,7 +62,6 @@ describe('getTimeToNextUpdateForUnit', function () {
|
|
|
66
62
|
round: 'floor'
|
|
67
63
|
}).should.equal(expected * 1000 + (addOneMs ? 1 : 0));
|
|
68
64
|
};
|
|
69
|
-
|
|
70
65
|
test(9, 0);
|
|
71
66
|
test(9.1, 0.1);
|
|
72
67
|
test(9.4, 0.4);
|
|
@@ -88,7 +83,6 @@ describe('getTimeToNextUpdateForUnit', function () {
|
|
|
88
83
|
round: 'floor'
|
|
89
84
|
}).should.equal(expected * 1000);
|
|
90
85
|
};
|
|
91
|
-
|
|
92
86
|
test(10, 1);
|
|
93
87
|
test(9.9, 0.1);
|
|
94
88
|
test(9.5, 0.5);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTimeToNextUpdateForUnit.test.js","names":["describe","it","expect","getTimeToNextUpdateForUnit","to","be","undefined","Date","now","should","equal","test","seconds","expected","addOneMs","round"],"sources":["../../source/steps/getTimeToNextUpdateForUnit.test.js"],"sourcesContent":["import getTimeToNextUpdateForUnit from './getTimeToNextUpdateForUnit.js'\r\n\r\ndescribe('getTimeToNextUpdateForUnit', () => {\r\n\tit('should return undefined for unknown units', () => {\r\n\t\texpect(getTimeToNextUpdateForUnit('now', 0, {})).to.be.undefined\r\n\t})\r\n\r\n\tit('should support Date argument', () => {\r\n\t\tgetTimeToNextUpdateForUnit('second', new Date(0), {\r\n\t\t\t// future: false,\r\n\t\t\tnow: 0\r\n\t\t}).should.equal(500)\r\n\t})\r\n\r\n\tit('should get time to next update for unit (future)', () => {\r\n\t\tconst test = (seconds, expected, addOneMs = true) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', seconds * 1000, {\r\n\t\t\t\t// future: true,\r\n\t\t\t\tnow: 0\r\n\t\t\t}).should.equal(expected * 1000 + (addOneMs ? 1 : 0))\r\n\t\t}\r\n\r\n\t\ttest(9, 0.5)\r\n\t\ttest(9.1, 0.6)\r\n\t\ttest(9.4, 0.9)\r\n\t\ttest(9.5, 0)\r\n\t\ttest(9.9, 0.4)\r\n\t\ttest(10, 0.5)\r\n\r\n\t\ttest(1.1, 0.6)\r\n\t\ttest(1, 0.5)\r\n\t\ttest(0.9, 0.4)\r\n\t\ttest(0.5, 0)\r\n\t\ttest(0.4, 0.4)\r\n\t\ttest(0, 0.5, false)\r\n\t})\r\n\r\n\tit('should get time to next update for unit (past)', () => {\r\n\t\tconst test = (seconds, expected, addOneMs = true) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', -1 * seconds * 1000, {\r\n\t\t\t\t// future: false,\r\n\t\t\t\tnow: 0\r\n\t\t\t}).should.equal(expected * 1000)\r\n\t\t}\r\n\r\n\t\ttest(10, 0.5)\r\n\t\ttest(9.9, 0.6)\r\n\t\ttest(9.5, 1)\r\n\t\ttest(9.4, 0.1)\r\n\t\ttest(9.1, 0.4)\r\n\t\ttest(9, 0.5)\r\n\r\n\t\ttest(0, 0.5, false)\r\n\t\ttest(0.5, 1, false)\r\n\t\ttest(0.9, 0.6, false)\r\n\t\ttest(1, 0.5, false)\r\n\t\ttest(1.1, 0.4, false)\r\n\t})\r\n\r\n\tit('should support \"floor\" rounding (future)', () => {\r\n\t\tconst test = (seconds, expected, addOneMs = true) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', seconds * 1000, {\r\n\t\t\t\t// future: true,\r\n\t\t\t\tnow: 0,\r\n\t\t\t\tround: 'floor'\r\n\t\t\t}).should.equal(expected * 1000 + (addOneMs ? 1 : 0))\r\n\t\t}\r\n\r\n\t\ttest(9, 0)\r\n\t\ttest(9.1, 0.1)\r\n\t\ttest(9.4, 0.4)\r\n\t\ttest(9.5, 0.5)\r\n\t\ttest(9.9, 0.9)\r\n\t\ttest(10, 0)\r\n\r\n\t\ttest(1.1, 0.1)\r\n\t\ttest(1, 0)\r\n\t\ttest(0.9, 0.9)\r\n\t\ttest(0.5, 0.5)\r\n\t\ttest(0.1, 0.1)\r\n\t\ttest(0, 1, false)\r\n\t})\r\n\r\n\tit('should support \"floor\" rounding (past)', () => {\r\n\t\tconst test = (seconds, expected) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', -1 * seconds * 1000, {\r\n\t\t\t\t// future: false,\r\n\t\t\t\tnow: 0,\r\n\t\t\t\tround: 'floor'\r\n\t\t\t}).should.equal(expected * 1000)\r\n\t\t}\r\n\r\n\t\ttest(10, 1)\r\n\t\ttest(9.9, 0.1)\r\n\t\ttest(9.5, 0.5)\r\n\t\ttest(9.4, 0.6)\r\n\t\ttest(9.1, 0.9)\r\n\t\ttest(9, 1)\r\n\r\n\t\ttest(0, 1)\r\n\t\ttest(0.5, 0.5)\r\n\t\ttest(0.9, 0.1)\r\n\t\ttest(1, 1)\r\n\t\ttest(1.1, 0.9)\r\n\t})\r\n})"],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"getTimeToNextUpdateForUnit.test.js","names":["_getTimeToNextUpdateForUnit","_interopRequireDefault","require","e","__esModule","describe","it","expect","getTimeToNextUpdateForUnit","to","be","undefined","Date","now","should","equal","test","seconds","expected","addOneMs","arguments","length","round"],"sources":["../../source/steps/getTimeToNextUpdateForUnit.test.js"],"sourcesContent":["import getTimeToNextUpdateForUnit from './getTimeToNextUpdateForUnit.js'\r\n\r\ndescribe('getTimeToNextUpdateForUnit', () => {\r\n\tit('should return undefined for unknown units', () => {\r\n\t\texpect(getTimeToNextUpdateForUnit('now', 0, {})).to.be.undefined\r\n\t})\r\n\r\n\tit('should support Date argument', () => {\r\n\t\tgetTimeToNextUpdateForUnit('second', new Date(0), {\r\n\t\t\t// future: false,\r\n\t\t\tnow: 0\r\n\t\t}).should.equal(500)\r\n\t})\r\n\r\n\tit('should get time to next update for unit (future)', () => {\r\n\t\tconst test = (seconds, expected, addOneMs = true) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', seconds * 1000, {\r\n\t\t\t\t// future: true,\r\n\t\t\t\tnow: 0\r\n\t\t\t}).should.equal(expected * 1000 + (addOneMs ? 1 : 0))\r\n\t\t}\r\n\r\n\t\ttest(9, 0.5)\r\n\t\ttest(9.1, 0.6)\r\n\t\ttest(9.4, 0.9)\r\n\t\ttest(9.5, 0)\r\n\t\ttest(9.9, 0.4)\r\n\t\ttest(10, 0.5)\r\n\r\n\t\ttest(1.1, 0.6)\r\n\t\ttest(1, 0.5)\r\n\t\ttest(0.9, 0.4)\r\n\t\ttest(0.5, 0)\r\n\t\ttest(0.4, 0.4)\r\n\t\ttest(0, 0.5, false)\r\n\t})\r\n\r\n\tit('should get time to next update for unit (past)', () => {\r\n\t\tconst test = (seconds, expected, addOneMs = true) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', -1 * seconds * 1000, {\r\n\t\t\t\t// future: false,\r\n\t\t\t\tnow: 0\r\n\t\t\t}).should.equal(expected * 1000)\r\n\t\t}\r\n\r\n\t\ttest(10, 0.5)\r\n\t\ttest(9.9, 0.6)\r\n\t\ttest(9.5, 1)\r\n\t\ttest(9.4, 0.1)\r\n\t\ttest(9.1, 0.4)\r\n\t\ttest(9, 0.5)\r\n\r\n\t\ttest(0, 0.5, false)\r\n\t\ttest(0.5, 1, false)\r\n\t\ttest(0.9, 0.6, false)\r\n\t\ttest(1, 0.5, false)\r\n\t\ttest(1.1, 0.4, false)\r\n\t})\r\n\r\n\tit('should support \"floor\" rounding (future)', () => {\r\n\t\tconst test = (seconds, expected, addOneMs = true) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', seconds * 1000, {\r\n\t\t\t\t// future: true,\r\n\t\t\t\tnow: 0,\r\n\t\t\t\tround: 'floor'\r\n\t\t\t}).should.equal(expected * 1000 + (addOneMs ? 1 : 0))\r\n\t\t}\r\n\r\n\t\ttest(9, 0)\r\n\t\ttest(9.1, 0.1)\r\n\t\ttest(9.4, 0.4)\r\n\t\ttest(9.5, 0.5)\r\n\t\ttest(9.9, 0.9)\r\n\t\ttest(10, 0)\r\n\r\n\t\ttest(1.1, 0.1)\r\n\t\ttest(1, 0)\r\n\t\ttest(0.9, 0.9)\r\n\t\ttest(0.5, 0.5)\r\n\t\ttest(0.1, 0.1)\r\n\t\ttest(0, 1, false)\r\n\t})\r\n\r\n\tit('should support \"floor\" rounding (past)', () => {\r\n\t\tconst test = (seconds, expected) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', -1 * seconds * 1000, {\r\n\t\t\t\t// future: false,\r\n\t\t\t\tnow: 0,\r\n\t\t\t\tround: 'floor'\r\n\t\t\t}).should.equal(expected * 1000)\r\n\t\t}\r\n\r\n\t\ttest(10, 1)\r\n\t\ttest(9.9, 0.1)\r\n\t\ttest(9.5, 0.5)\r\n\t\ttest(9.4, 0.6)\r\n\t\ttest(9.1, 0.9)\r\n\t\ttest(9, 1)\r\n\r\n\t\ttest(0, 1)\r\n\t\ttest(0.5, 0.5)\r\n\t\ttest(0.9, 0.1)\r\n\t\ttest(1, 1)\r\n\t\ttest(1.1, 0.9)\r\n\t})\r\n})"],"mappings":";;AAAA,IAAAA,2BAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAwE,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAExEE,QAAQ,CAAC,4BAA4B,EAAE,YAAM;EAC5CC,EAAE,CAAC,2CAA2C,EAAE,YAAM;IACrDC,MAAM,CAAC,IAAAC,sCAA0B,EAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAACC,EAAE,CAACC,EAAE,CAACC,SAAS;EACjE,CAAC,CAAC;EAEFL,EAAE,CAAC,8BAA8B,EAAE,YAAM;IACxC,IAAAE,sCAA0B,EAAC,QAAQ,EAAE,IAAII,IAAI,CAAC,CAAC,CAAC,EAAE;MACjD;MACAC,GAAG,EAAE;IACN,CAAC,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,GAAG,CAAC;EACrB,CAAC,CAAC;EAEFT,EAAE,CAAC,kDAAkD,EAAE,YAAM;IAC5D,IAAMU,IAAI,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C","ignoreList":[]}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getDate = getDate;
|
|
7
|
-
|
|
8
7
|
// Looks like this one's deprecated.
|
|
9
8
|
// /**
|
|
10
9
|
// * Returns a step corresponding to the unit.
|
|
@@ -19,8 +18,8 @@ exports.getDate = getDate;
|
|
|
19
18
|
// }
|
|
20
19
|
// }
|
|
21
20
|
// }
|
|
22
|
-
// Looks like this one won't be used in the next major version.
|
|
23
21
|
|
|
22
|
+
// Looks like this one won't be used in the next major version.
|
|
24
23
|
/**
|
|
25
24
|
* Converts value to a `Date`
|
|
26
25
|
* @param {(number|Date)} value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["getDate","value","Date"],"sources":["../../source/steps/helpers.js"],"sourcesContent":["// Looks like this one's deprecated.\r\n// /**\r\n// * Returns a step corresponding to the unit.\r\n// * @param {Object[]} steps\r\n// * @param {string} unit\r\n// * @return {?Object}\r\n// */\r\n// export function getStepForUnit(steps, unit) {\r\n// \tfor (const step of steps) {\r\n// \t\tif (step.unit === unit) {\r\n// \t\t\treturn step\r\n// \t\t}\r\n// \t}\r\n// }\r\n\r\n// Looks like this one won't be used in the next major version.\r\n/**\r\n * Converts value to a `Date`\r\n * @param {(number|Date)} value\r\n * @return {Date}\r\n */\r\nexport function getDate(value) {\r\n\treturn value instanceof Date ? value : new Date(value)\r\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["getDate","value","Date"],"sources":["../../source/steps/helpers.js"],"sourcesContent":["// Looks like this one's deprecated.\r\n// /**\r\n// * Returns a step corresponding to the unit.\r\n// * @param {Object[]} steps\r\n// * @param {string} unit\r\n// * @return {?Object}\r\n// */\r\n// export function getStepForUnit(steps, unit) {\r\n// \tfor (const step of steps) {\r\n// \t\tif (step.unit === unit) {\r\n// \t\t\treturn step\r\n// \t\t}\r\n// \t}\r\n// }\r\n\r\n// Looks like this one won't be used in the next major version.\r\n/**\r\n * Converts value to a `Date`\r\n * @param {(number|Date)} value\r\n * @return {Date}\r\n */\r\nexport function getDate(value) {\r\n\treturn value instanceof Date ? value : new Date(value)\r\n}"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,OAAOA,CAACC,KAAK,EAAE;EAC9B,OAAOA,KAAK,YAAYC,IAAI,GAAGD,KAAK,GAAG,IAAIC,IAAI,CAACD,KAAK,CAAC;AACvD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.test.js","names":["describe","it","today","Date","getDate","getTime","should","equal"],"sources":["../../source/steps/helpers.test.js"],"sourcesContent":["import { getDate } from './helpers.js'\r\n\r\ndescribe('steps/helpers', () => {\r\n\tit('should convert value to Date', () => {\r\n\t\tconst today = new Date()\r\n\t\tgetDate(today.getTime()).getTime().should.equal(today.getTime())\r\n\t\tgetDate(today).getTime().should.equal(today.getTime())\r\n\t})\r\n})"],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"helpers.test.js","names":["_helpers","require","describe","it","today","Date","getDate","getTime","should","equal"],"sources":["../../source/steps/helpers.test.js"],"sourcesContent":["import { getDate } from './helpers.js'\r\n\r\ndescribe('steps/helpers', () => {\r\n\tit('should convert value to Date', () => {\r\n\t\tconst today = new Date()\r\n\t\tgetDate(today.getTime()).getTime().should.equal(today.getTime())\r\n\t\tgetDate(today).getTime().should.equal(today.getTime())\r\n\t})\r\n})"],"mappings":";;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,eAAe,EAAE,YAAM;EAC/BC,EAAE,CAAC,8BAA8B,EAAE,YAAM;IACxC,IAAMC,KAAK,GAAG,IAAIC,IAAI,CAAC,CAAC;IACxB,IAAAC,gBAAO,EAACF,KAAK,CAACG,OAAO,CAAC,CAAC,CAAC,CAACA,OAAO,CAAC,CAAC,CAACC,MAAM,CAACC,KAAK,CAACL,KAAK,CAACG,OAAO,CAAC,CAAC,CAAC;IAChE,IAAAD,gBAAO,EAACF,KAAK,CAAC,CAACG,OAAO,CAAC,CAAC,CAACC,MAAM,CAACC,KAAK,CAACL,KAAK,CAACG,OAAO,CAAC,CAAC,CAAC;EACvD,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
package/commonjs/steps/index.js
CHANGED
|
@@ -69,14 +69,9 @@ Object.defineProperty(exports, "year", {
|
|
|
69
69
|
return _units.year;
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
|
-
|
|
73
72
|
var _approximate = _interopRequireDefault(require("./approximate.js"));
|
|
74
|
-
|
|
75
73
|
var _round = _interopRequireDefault(require("./round.js"));
|
|
76
|
-
|
|
77
74
|
var _units = require("./units.js");
|
|
78
|
-
|
|
79
75
|
var _helpers = require("./helpers.js");
|
|
80
|
-
|
|
81
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
76
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
82
77
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../source/steps/index.js"],"sourcesContent":["// \"convenient\" is a legacy name of \"approximate\" steps.\r\nexport { default as approximate, default as convenient } from './approximate.js'\r\n\r\n// \"canonical\" is a legacy name of \"round\" steps.\r\nexport { default as round, default as canonical } from './round.js'\r\n\r\nexport {\r\n\tminute,\r\n\thour,\r\n\tday,\r\n\tweek,\r\n\tmonth,\r\n\tyear\r\n} from './units.js'\r\n\r\nexport {\r\n\tgetDate\r\n} from './helpers.js'"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_approximate","_interopRequireDefault","require","_round","_units","_helpers","e","__esModule"],"sources":["../../source/steps/index.js"],"sourcesContent":["// \"convenient\" is a legacy name of \"approximate\" steps.\r\nexport { default as approximate, default as convenient } from './approximate.js'\r\n\r\n// \"canonical\" is a legacy name of \"round\" steps.\r\nexport { default as round, default as canonical } from './round.js'\r\n\r\nexport {\r\n\tminute,\r\n\thour,\r\n\tday,\r\n\tweek,\r\n\tmonth,\r\n\tyear\r\n} from './units.js'\r\n\r\nexport {\r\n\tgetDate\r\n} from './helpers.js'"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AASA,IAAAG,QAAA,GAAAH,OAAA;AAEqB,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA","ignoreList":[]}
|
|
@@ -4,25 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = _default;
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
|
|
7
|
+
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); }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
|
+
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); }
|
|
16
13
|
// This function is only used for backwards compatibility
|
|
17
14
|
// with legacy code that uses the older versions of this library.
|
|
18
15
|
function _default(step_) {
|
|
19
16
|
var step = _objectSpread({}, step_);
|
|
20
|
-
|
|
21
17
|
if (step.minTime !== undefined) {
|
|
22
18
|
if (_typeof(step.minTime) === 'object') {
|
|
23
19
|
for (var _i = 0, _Object$keys = Object.keys(step.minTime); _i < _Object$keys.length; _i++) {
|
|
24
20
|
var key = _Object$keys[_i];
|
|
25
|
-
|
|
26
21
|
if (key === 'default') {
|
|
27
22
|
step.threshold = step.minTime["default"];
|
|
28
23
|
} else {
|
|
@@ -32,15 +27,12 @@ function _default(step_) {
|
|
|
32
27
|
} else {
|
|
33
28
|
step.threshold = step.minTime;
|
|
34
29
|
}
|
|
35
|
-
|
|
36
30
|
delete step.minTime;
|
|
37
31
|
}
|
|
38
|
-
|
|
39
32
|
if (step.formatAs) {
|
|
40
33
|
step.unit = step.formatAs;
|
|
41
34
|
delete step.formatAs;
|
|
42
35
|
}
|
|
43
|
-
|
|
44
36
|
return step;
|
|
45
37
|
}
|
|
46
38
|
//# sourceMappingURL=renameLegacyProperties.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renameLegacyProperties.js","names":["step_","step","minTime","undefined","Object","keys","key","threshold","formatAs","unit"],"sources":["../../source/steps/renameLegacyProperties.js"],"sourcesContent":["// This function is only used for backwards compatibility\r\n// with legacy code that uses the older versions of this library.\r\nexport default function(step_) {\r\n\tconst step = { ...step_ }\r\n\tif (step.minTime !== undefined) {\r\n\t\tif (typeof step.minTime === 'object') {\r\n\t\t\tfor (const key of Object.keys(step.minTime)) {\r\n\t\t\t\tif (key === 'default') {\r\n\t\t\t\t\tstep.threshold = step.minTime.default\r\n\t\t\t\t} else {\r\n\t\t\t\t\tstep[`threshold_for_${key}`] = step.minTime[key]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tstep.threshold = step.minTime\r\n\t\t}\r\n\t\tdelete step.minTime\r\n\t}\r\n\tif (step.formatAs) {\r\n\t\tstep.unit = step.formatAs\r\n\t\tdelete step.formatAs\r\n\t}\r\n\treturn step\r\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"renameLegacyProperties.js","names":["_default","step_","step","_objectSpread","minTime","undefined","_typeof","_i","_Object$keys","Object","keys","length","key","threshold","concat","formatAs","unit"],"sources":["../../source/steps/renameLegacyProperties.js"],"sourcesContent":["// This function is only used for backwards compatibility\r\n// with legacy code that uses the older versions of this library.\r\nexport default function(step_) {\r\n\tconst step = { ...step_ }\r\n\tif (step.minTime !== undefined) {\r\n\t\tif (typeof step.minTime === 'object') {\r\n\t\t\tfor (const key of Object.keys(step.minTime)) {\r\n\t\t\t\tif (key === 'default') {\r\n\t\t\t\t\tstep.threshold = step.minTime.default\r\n\t\t\t\t} else {\r\n\t\t\t\t\tstep[`threshold_for_${key}`] = step.minTime[key]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tstep.threshold = step.minTime\r\n\t\t}\r\n\t\tdelete step.minTime\r\n\t}\r\n\tif (step.formatAs) {\r\n\t\tstep.unit = step.formatAs\r\n\t\tdelete step.formatAs\r\n\t}\r\n\treturn step\r\n}"],"mappings":";;;;;;;;;;;;AAAA;AACA;AACe,SAAAA,SAASC,KAAK,EAAE;EAC9B,IAAMC,IAAI,GAAAC,aAAA,KAAQF,KAAK,CAAE;EACzB,IAAIC,IAAI,CAACE,OAAO,KAAKC,SAAS,EAAE;IAC/B,IAAIC,OAAA,CAAOJ,IAAI,CAACE,OAAO,MAAK,QAAQ,EAAE;MACrC,SAAAG,EAAA,MAAAC,YAAA,GAAkBC,MAAM,CAACC,IAAI,CAACR,IAAI,CAACE,OAAO,CAAC,EAAAG,EAAA,GAAAC,YAAA,CAAAG,MAAA,EAAAJ,EAAA,IAAE;QAAxC,IAAMK,GAAG,GAAAJ,YAAA,CAAAD,EAAA;QACb,IAAIK,GAAG,KAAK,SAAS,EAAE;UACtBV,IAAI,CAACW,SAAS,GAAGX,IAAI,CAACE,OAAO,WAAQ;QACtC,CAAC,MAAM;UACNF,IAAI,kBAAAY,MAAA,CAAkBF,GAAG,EAAG,GAAGV,IAAI,CAACE,OAAO,CAACQ,GAAG,CAAC;QACjD;MACD;IACD,CAAC,MAAM;MACNV,IAAI,CAACW,SAAS,GAAGX,IAAI,CAACE,OAAO;IAC9B;IACA,OAAOF,IAAI,CAACE,OAAO;EACpB;EACA,IAAIF,IAAI,CAACa,QAAQ,EAAE;IAClBb,IAAI,CAACc,IAAI,GAAGd,IAAI,CAACa,QAAQ;IACzB,OAAOb,IAAI,CAACa,QAAQ;EACrB;EACA,OAAOb,IAAI;AACZ","ignoreList":[]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _renameLegacyProperties = _interopRequireDefault(require("./renameLegacyProperties.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('steps/renameLegacyProperties', function () {
|
|
8
6
|
it('should rename legacy properties', function () {
|
|
9
7
|
(0, _renameLegacyProperties["default"])({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renameLegacyProperties.test.js","names":["describe","it","renameLegacyProperties","formatAs","minTime","should","deep","equal","unit","threshold","week","threshold_for_week"],"sources":["../../source/steps/renameLegacyProperties.test.js"],"sourcesContent":["import renameLegacyProperties from './renameLegacyProperties.js'\r\n\r\ndescribe('steps/renameLegacyProperties', () => {\r\n\tit('should rename legacy properties', () => {\r\n\t\trenameLegacyProperties({\r\n\t\t\tformatAs: 'now',\r\n\t\t\tminTime: 1\r\n\t\t}).should.deep.equal({\r\n\t\t\tunit: 'now',\r\n\t\t\tthreshold: 1\r\n\t\t})\r\n\t})\r\n\r\n\tit('should rename legacy properties (minTime: undefined)', () => {\r\n\t\trenameLegacyProperties({\r\n\t\t\tformatAs: 'now'\r\n\t\t}).should.deep.equal({\r\n\t\t\tunit: 'now'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should rename legacy properties (`minTime` is an object)', () => {\r\n\t\trenameLegacyProperties({\r\n\t\t\tformatAs: 'now',\r\n\t\t\tminTime: {\r\n\t\t\t\tweek: 2,\r\n\t\t\t\tdefault: 1\r\n\t\t\t}\r\n\t\t}).should.deep.equal({\r\n\t\t\tunit: 'now',\r\n\t\t\tthreshold: 1,\r\n\t\t\tthreshold_for_week: 2\r\n\t\t})\r\n\t})\r\n})"],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"renameLegacyProperties.test.js","names":["_renameLegacyProperties","_interopRequireDefault","require","e","__esModule","describe","it","renameLegacyProperties","formatAs","minTime","should","deep","equal","unit","threshold","week","threshold_for_week"],"sources":["../../source/steps/renameLegacyProperties.test.js"],"sourcesContent":["import renameLegacyProperties from './renameLegacyProperties.js'\r\n\r\ndescribe('steps/renameLegacyProperties', () => {\r\n\tit('should rename legacy properties', () => {\r\n\t\trenameLegacyProperties({\r\n\t\t\tformatAs: 'now',\r\n\t\t\tminTime: 1\r\n\t\t}).should.deep.equal({\r\n\t\t\tunit: 'now',\r\n\t\t\tthreshold: 1\r\n\t\t})\r\n\t})\r\n\r\n\tit('should rename legacy properties (minTime: undefined)', () => {\r\n\t\trenameLegacyProperties({\r\n\t\t\tformatAs: 'now'\r\n\t\t}).should.deep.equal({\r\n\t\t\tunit: 'now'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should rename legacy properties (`minTime` is an object)', () => {\r\n\t\trenameLegacyProperties({\r\n\t\t\tformatAs: 'now',\r\n\t\t\tminTime: {\r\n\t\t\t\tweek: 2,\r\n\t\t\t\tdefault: 1\r\n\t\t\t}\r\n\t\t}).should.deep.equal({\r\n\t\t\tunit: 'now',\r\n\t\t\tthreshold: 1,\r\n\t\t\tthreshold_for_week: 2\r\n\t\t})\r\n\t})\r\n})"],"mappings":";;AAAA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAgE,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAEhEE,QAAQ,CAAC,8BAA8B,EAAE,YAAM;EAC9CC,EAAE,CAAC,iCAAiC,EAAE,YAAM;IAC3C,IAAAC,kCAAsB,EAAC;MACtBC,QAAQ,EAAE,KAAK;MACfC,OAAO,EAAE;IACV,CAAC,CAAC,CAACC,MAAM,CAACC,IAAI,CAACC,KAAK,CAAC;MACpBC,IAAI,EAAE,KAAK;MACXC,SAAS,EAAE;IACZ,CAAC,CAAC;EACH,CAAC,CAAC;EAEFR,EAAE,CAAC,sDAAsD,EAAE,YAAM;IAChE,IAAAC,kCAAsB,EAAC;MACtBC,QAAQ,EAAE;IACX,CAAC,CAAC,CAACE,MAAM,CAACC,IAAI,CAACC,KAAK,CAAC;MACpBC,IAAI,EAAE;IACP,CAAC,CAAC;EACH,CAAC,CAAC;EAEFP,EAAE,CAAC,0DAA0D,EAAE,YAAM;IACpE,IAAAC,kCAAsB,EAAC;MACtBC,QAAQ,EAAE,KAAK;MACfC,OAAO,EAAE;QACRM,IAAI,EAAE,CAAC;QACP,WAAS;MACV;IACD,CAAC,CAAC,CAACL,MAAM,CAACC,IAAI,CAACC,KAAK,CAAC;MACpBC,IAAI,EAAE,KAAK;MACXC,SAAS,EAAE,CAAC;MACZE,kBAAkB,EAAE;IACrB,CAAC,CAAC;EACH,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
package/commonjs/steps/round.js
CHANGED
|
@@ -32,7 +32,7 @@ exports["default"] = void 0;
|
|
|
32
32
|
// 1 year ago
|
|
33
33
|
// 2 years ago
|
|
34
34
|
// …
|
|
35
|
-
var _default = [{
|
|
35
|
+
var _default = exports["default"] = [{
|
|
36
36
|
formatAs: 'now'
|
|
37
37
|
}, {
|
|
38
38
|
formatAs: 'second'
|
|
@@ -49,5 +49,4 @@ var _default = [{
|
|
|
49
49
|
}, {
|
|
50
50
|
formatAs: 'year'
|
|
51
51
|
}];
|
|
52
|
-
exports["default"] = _default;
|
|
53
52
|
//# sourceMappingURL=round.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round.js","names":["formatAs"],"sources":["../../source/steps/round.js"],"sourcesContent":["// just now\r\n// 1 second ago\r\n// 2 seconds ago\r\n// …\r\n// 59 seconds ago\r\n// 1 minute ago\r\n// 2 minutes ago\r\n// …\r\n// 59 minutes ago\r\n// 1 hour ago\r\n// 2 hours ago\r\n// …\r\n// 24 hours ago\r\n// 1 day ago\r\n// 2 days ago\r\n// …\r\n// 6 days ago\r\n// 1 week ago\r\n// 2 weeks ago\r\n// …\r\n// 3 weeks ago\r\n// 1 month ago\r\n// 2 months ago\r\n// …\r\n// 11 months ago\r\n// 1 year ago\r\n// 2 years ago\r\n// …\r\nexport default [\r\n\t{\r\n\t\tformatAs: 'now'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'second'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'minute'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'hour'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'day'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'week'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'month'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'year'\r\n\t}\r\n]"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"round.js","names":["_default","exports","formatAs"],"sources":["../../source/steps/round.js"],"sourcesContent":["// just now\r\n// 1 second ago\r\n// 2 seconds ago\r\n// …\r\n// 59 seconds ago\r\n// 1 minute ago\r\n// 2 minutes ago\r\n// …\r\n// 59 minutes ago\r\n// 1 hour ago\r\n// 2 hours ago\r\n// …\r\n// 24 hours ago\r\n// 1 day ago\r\n// 2 days ago\r\n// …\r\n// 6 days ago\r\n// 1 week ago\r\n// 2 weeks ago\r\n// …\r\n// 3 weeks ago\r\n// 1 month ago\r\n// 2 months ago\r\n// …\r\n// 11 months ago\r\n// 1 year ago\r\n// 2 years ago\r\n// …\r\nexport default [\r\n\t{\r\n\t\tformatAs: 'now'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'second'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'minute'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'hour'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'day'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'week'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'month'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'year'\r\n\t}\r\n]"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,IAAAA,QAAA,GAAAC,OAAA,cACe,CACd;EACCC,QAAQ,EAAE;AACX,CAAC,EACD;EACCA,QAAQ,EAAE;AACX,CAAC,EACD;EACCA,QAAQ,EAAE;AACX,CAAC,EACD;EACCA,QAAQ,EAAE;AACX,CAAC,EACD;EACCA,QAAQ,EAAE;AACX,CAAC,EACD;EACCA,QAAQ,EAAE;AACX,CAAC,EACD;EACCA,QAAQ,EAAE;AACX,CAAC,EACD;EACCA,QAAQ,EAAE;AACX,CAAC,CACD","ignoreList":[]}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getStep = _interopRequireDefault(require("./getStep.js"));
|
|
4
|
-
|
|
5
4
|
var _round = _interopRequireDefault(require("./round.js"));
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
8
|
-
|
|
5
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
6
|
describe('steps/round', function () {
|
|
10
7
|
it('should get step correctly (round: "floor")', function () {
|
|
11
8
|
var getStepFor = function getStepFor(secondsPassed) {
|
|
@@ -14,7 +11,6 @@ describe('steps/round', function () {
|
|
|
14
11
|
units: ['now', 'second', 'minute', 'hour', 'day', 'week', 'month', 'year']
|
|
15
12
|
});
|
|
16
13
|
};
|
|
17
|
-
|
|
18
14
|
expect(getStepFor(0).formatAs).to.equal('now');
|
|
19
15
|
expect(getStepFor(0.9).formatAs).to.equal('now');
|
|
20
16
|
expect(getStepFor(1).formatAs).to.equal('second');
|
|
@@ -32,7 +28,6 @@ describe('steps/round', function () {
|
|
|
32
28
|
units: ['now', 'second', 'minute', 'hour', 'day', 'week', 'month', 'year']
|
|
33
29
|
});
|
|
34
30
|
};
|
|
35
|
-
|
|
36
31
|
expect(getStepFor(0).formatAs).to.equal('now');
|
|
37
32
|
expect(getStepFor(0.49).formatAs).to.equal('now');
|
|
38
33
|
expect(getStepFor(0.5).formatAs).to.equal('second');
|
|
@@ -51,7 +46,6 @@ describe('steps/round', function () {
|
|
|
51
46
|
units: ['now', 'second', 'minute', 'hour', 'day', 'month', 'year']
|
|
52
47
|
});
|
|
53
48
|
};
|
|
54
|
-
|
|
55
49
|
expect(getStepFor(7 * 24 * 60 * 60).formatAs).to.equal('day');
|
|
56
50
|
});
|
|
57
51
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round.test.js","names":["describe","it","getStepFor","secondsPassed","getStep","steps","round","units","expect","formatAs","to","equal"],"sources":["../../source/steps/round.test.js"],"sourcesContent":["import getStep from './getStep.js'\r\nimport steps from './round.js'\r\n\r\ndescribe('steps/round', () => {\r\n\tit('should get step correctly (round: \"floor\")', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tround: 'floor',\r\n\t\t\tunits: [\r\n\t\t\t\t'now',\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'week',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(0).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(0.9).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(1).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(59.9).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(60).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(60 * 60 - 1).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(60 * 60).formatAs).to.equal('hour')\r\n\t\texpect(getStepFor(24 * 60 * 60).formatAs).to.equal('day')\r\n\t\texpect(getStepFor(7 * 24 * 60 * 60).formatAs).to.equal('week')\r\n\t})\r\n\r\n\tit('should get step correctly (round: \"round\")', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tround: 'round',\r\n\t\t\tunits: [\r\n\t\t\t\t'now',\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'week',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(0).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(0.49).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(0.5).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(1).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(59.4).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(60).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(59.4 * 60).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(60 * 60).formatAs).to.equal('hour')\r\n\t\texpect(getStepFor(23.49 * 60 * 60).formatAs).to.equal('hour')\r\n\t\texpect(getStepFor(23.5 * 60 * 60).formatAs).to.equal('day')\r\n\t\texpect(getStepFor(7 * 24 * 60 * 60).formatAs).to.equal('week')\r\n\t})\r\n\r\n\tit('should use \"day\"s when \"week\"s are not allowed', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tunits: [\r\n\t\t\t\t'now',\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(7 * 24 * 60 * 60).formatAs).to.equal('day')\r\n\t})\r\n})"],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"round.test.js","names":["_getStep","_interopRequireDefault","require","_round","e","__esModule","describe","it","getStepFor","secondsPassed","getStep","steps","round","units","expect","formatAs","to","equal"],"sources":["../../source/steps/round.test.js"],"sourcesContent":["import getStep from './getStep.js'\r\nimport steps from './round.js'\r\n\r\ndescribe('steps/round', () => {\r\n\tit('should get step correctly (round: \"floor\")', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tround: 'floor',\r\n\t\t\tunits: [\r\n\t\t\t\t'now',\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'week',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(0).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(0.9).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(1).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(59.9).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(60).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(60 * 60 - 1).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(60 * 60).formatAs).to.equal('hour')\r\n\t\texpect(getStepFor(24 * 60 * 60).formatAs).to.equal('day')\r\n\t\texpect(getStepFor(7 * 24 * 60 * 60).formatAs).to.equal('week')\r\n\t})\r\n\r\n\tit('should get step correctly (round: \"round\")', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tround: 'round',\r\n\t\t\tunits: [\r\n\t\t\t\t'now',\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'week',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(0).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(0.49).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(0.5).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(1).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(59.4).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(60).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(59.4 * 60).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(60 * 60).formatAs).to.equal('hour')\r\n\t\texpect(getStepFor(23.49 * 60 * 60).formatAs).to.equal('hour')\r\n\t\texpect(getStepFor(23.5 * 60 * 60).formatAs).to.equal('day')\r\n\t\texpect(getStepFor(7 * 24 * 60 * 60).formatAs).to.equal('week')\r\n\t})\r\n\r\n\tit('should use \"day\"s when \"week\"s are not allowed', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tunits: [\r\n\t\t\t\t'now',\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(7 * 24 * 60 * 60).formatAs).to.equal('day')\r\n\t})\r\n})"],"mappings":";;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8B,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAE9BE,QAAQ,CAAC,aAAa,EAAE,YAAM;EAC7BC,EAAE,CAAC,4CAA4C,EAAE,YAAM;IACtD,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAIC,aAAa;MAAA,OAAK,IAAAC,mBAAO,EAACC,iBAAK,EAAEF,aAAa,EAAE;QACnEG,KAAK,EAAE,OAAO;QACdC,KAAK,EAAE,CACN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAA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E,GAAG,EAAE,CAAC,CAACO,QAAQ,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,KAAK,CAAC;IAC3DH,MAAM,CAACN,UAAU,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAACO,QAAQ,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,MAAM,CAAC;EAC/D,CAAC,CAAC;EAEFV,EAAE,CAAC,gDAAgD,EAAE,YAAM;IAC1D,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAIC,aAAa;MAAA,OAAK,IAAAC,mBAAO,EAACC,iBAAK,EAAEF,aAAa,EAAE;QACnEI,KAAK,EAAE,CACN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,KAAK,EACL,OAAO,EACP,MAAM;MAER,CAAC,CAAC;IAAA;IAEFC,MAAM,CAACN,UAAU,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAACO,QAAQ,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,KAAK,CAAC;EAC9D,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
package/commonjs/steps/units.js
CHANGED
|
@@ -6,51 +6,40 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.day = void 0;
|
|
7
7
|
exports.getSecondsInUnit = getSecondsInUnit;
|
|
8
8
|
exports.year = exports.week = exports.month = exports.minute = exports.hour = void 0;
|
|
9
|
-
var minute = 60; // in seconds
|
|
9
|
+
var minute = exports.minute = 60; // in seconds
|
|
10
10
|
|
|
11
|
-
exports.
|
|
12
|
-
var hour = 60 * minute; // in seconds
|
|
11
|
+
var hour = exports.hour = 60 * minute; // in seconds
|
|
13
12
|
|
|
14
|
-
exports.
|
|
15
|
-
|
|
13
|
+
var day = exports.day = 24 * hour; // in seconds
|
|
14
|
+
|
|
15
|
+
var week = exports.week = 7 * day; // in seconds
|
|
16
16
|
|
|
17
|
-
exports.day = day;
|
|
18
|
-
var week = 7 * day; // in seconds
|
|
19
17
|
// https://www.quora.com/What-is-the-average-number-of-days-in-a-month
|
|
18
|
+
var month = exports.month = 30.44 * day; // in seconds
|
|
20
19
|
|
|
21
|
-
exports.week = week;
|
|
22
|
-
var month = 30.44 * day; // in seconds
|
|
23
20
|
// "400 years have 146097 days (taking into account leap year rules)"
|
|
24
|
-
|
|
25
|
-
exports.month = month;
|
|
26
|
-
var year = 146097 / 400 * day; // in seconds
|
|
27
|
-
|
|
28
|
-
exports.year = year;
|
|
21
|
+
var year = exports.year = 146097 / 400 * day; // in seconds
|
|
29
22
|
|
|
30
23
|
function getSecondsInUnit(unit) {
|
|
31
24
|
switch (unit) {
|
|
32
25
|
case 'second':
|
|
33
26
|
return 1;
|
|
34
|
-
|
|
35
27
|
case 'minute':
|
|
36
28
|
return minute;
|
|
37
|
-
|
|
38
29
|
case 'hour':
|
|
39
30
|
return hour;
|
|
40
|
-
|
|
41
31
|
case 'day':
|
|
42
32
|
return day;
|
|
43
|
-
|
|
44
33
|
case 'week':
|
|
45
34
|
return week;
|
|
46
|
-
|
|
47
35
|
case 'month':
|
|
48
36
|
return month;
|
|
49
|
-
|
|
50
37
|
case 'year':
|
|
51
38
|
return year;
|
|
52
39
|
}
|
|
53
|
-
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// export function getPreviousUnitFor(unit) {
|
|
54
43
|
// switch (unit) {
|
|
55
44
|
// case 'second':
|
|
56
45
|
// return 'now'
|