javascript-time-ago 2.5.10 → 2.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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 +135 -190
- package/commonjs/TimeAgo.js.map +1 -1
- package/commonjs/TimeAgo.test.js +124 -130
- 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 +17 -32
- 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 +19 -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 -38
- package/commonjs/style/twitter.js.map +1 -1
- package/commonjs/style/twitter.test.js +49 -55
- 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/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/pl.json +59 -0
- package/locale/pl.json.js +59 -0
- 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/locale-more-styles/pl/long-time.json +30 -0
- package/locale-more-styles/pl/mini.json +9 -0
- package/locale-more-styles/pl/now.json +7 -0
- package/locale-more-styles/pl/short-time.json +12 -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 +135 -174
- package/modules/TimeAgo.js.map +1 -1
- package/modules/TimeAgo.test.js +126 -115
- 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 +17 -29
- package/modules/steps/getStepMinTime.js.map +1 -1
- package/modules/steps/getStepMinTime.test.js.map +1 -1
- package/modules/steps/getTimeToNextUpdate.js +19 -31
- 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 +35 -32
- package/modules/style/twitter.js.map +1 -1
- package/modules/style/twitter.test.js +48 -50
- 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 +261 -4
|
@@ -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,OAA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";
|
|
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\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IAAMU,IAAI,GAAG,SAAPA,IAAIA,CAAIC,OAAO,EAAEC,QAAQ,EAAK;MACnC,IAAAV,sCAA0B,EAAC,QAAQ,EAAE,CAAC,CAAC,GAAGS,OAAO,GAAG,IAAI,EAAE;QACzD;QACAJ,GAAG,EAAE,CAAC;QACNS,KAAK,EAAE;MACR,CAAC,CAAC,CAACR,MAAM,CAACC,KAAK,CAACG,QAAQ,GAAG,IAAI,CAAC;IACjC,CAAC;IAEDF,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IACXA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;IACdA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;IACdA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;IACdA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;IACdA,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IAEVA,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IACVA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;IACdA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;IACdA,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IACVA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;EACf,CAAC,CAAC;AACH,CAAC,CAAC","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,MAAM,EACN,OAAO,EACP,MAAM;MAER,CAAC,CAAC;IAAA;IAEFC,MAAM,CAACN,UAAU,CAAC,CAAC,CAAC,CAACO,QAAQ,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,KAAK,CAAC;IAC9CH,MAAM,CAACN,UAAU,CAAC,GAAG,CAAC,CAACO,QAAQ,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,KAAK,CAAC;IAChDH,MAAM,CAACN,UAAU,CAAC,CAAC,CAAC,CAACO,QAAQ,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,QAAQ,CAAC;IACjDH,MAAM,CAACN,UAAU,CAAC,IAAI,CAAC,CAACO,QAAQ,CAAC,CAACC,EAAE,CAACC,KAAK,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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'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"units.js","names":["minute","hour","day","week","month","year","getSecondsInUnit","unit"],"sources":["../../source/steps/units.js"],"sourcesContent":["export const minute = 60 // in seconds\r\n\r\nexport const hour = 60 * minute // in seconds\r\n\r\nexport const day = 24 * hour // in seconds\r\n\r\nexport const week = 7 * day // in seconds\r\n\r\n// https://www.quora.com/What-is-the-average-number-of-days-in-a-month\r\nexport const month = 30.44 * day // in seconds\r\n\r\n// \"400 years have 146097 days (taking into account leap year rules)\"\r\nexport const year = (146097 / 400) * day // in seconds\r\n\r\nexport function getSecondsInUnit(unit) {\r\n\tswitch (unit) {\r\n\t\tcase 'second':\r\n\t\t\treturn 1\r\n\t\tcase 'minute':\r\n\t\t\treturn minute\r\n\t\tcase 'hour':\r\n\t\t\treturn hour\r\n\t\tcase 'day':\r\n\t\t\treturn day\r\n\t\tcase 'week':\r\n\t\t\treturn week\r\n\t\tcase 'month':\r\n\t\t\treturn month\r\n\t\tcase 'year':\r\n\t\t\treturn year\r\n\t}\r\n}\r\n\r\n// export function getPreviousUnitFor(unit) {\r\n// \tswitch (unit) {\r\n// \t\tcase 'second':\r\n// \t\t\treturn 'now'\r\n// \t\tcase 'minute':\r\n// \t\t\treturn 'second'\r\n// \t\tcase 'hour':\r\n// \t\t\treturn 'minute'\r\n// \t\tcase 'day':\r\n// \t\t\treturn 'hour'\r\n// \t\tcase 'week':\r\n// \t\t\treturn 'day'\r\n// \t\tcase 'month':\r\n// \t\t\treturn 'week'\r\n// \t\tcase 'year':\r\n// \t\t\treturn 'month'\r\n// \t}\r\n// }"],"mappings":";;;;;;;;AAAO,IAAMA,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"units.js","names":["minute","exports","hour","day","week","month","year","getSecondsInUnit","unit"],"sources":["../../source/steps/units.js"],"sourcesContent":["export const minute = 60 // in seconds\r\n\r\nexport const hour = 60 * minute // in seconds\r\n\r\nexport const day = 24 * hour // in seconds\r\n\r\nexport const week = 7 * day // in seconds\r\n\r\n// https://www.quora.com/What-is-the-average-number-of-days-in-a-month\r\nexport const month = 30.44 * day // in seconds\r\n\r\n// \"400 years have 146097 days (taking into account leap year rules)\"\r\nexport const year = (146097 / 400) * day // in seconds\r\n\r\nexport function getSecondsInUnit(unit) {\r\n\tswitch (unit) {\r\n\t\tcase 'second':\r\n\t\t\treturn 1\r\n\t\tcase 'minute':\r\n\t\t\treturn minute\r\n\t\tcase 'hour':\r\n\t\t\treturn hour\r\n\t\tcase 'day':\r\n\t\t\treturn day\r\n\t\tcase 'week':\r\n\t\t\treturn week\r\n\t\tcase 'month':\r\n\t\t\treturn month\r\n\t\tcase 'year':\r\n\t\t\treturn year\r\n\t}\r\n}\r\n\r\n// export function getPreviousUnitFor(unit) {\r\n// \tswitch (unit) {\r\n// \t\tcase 'second':\r\n// \t\t\treturn 'now'\r\n// \t\tcase 'minute':\r\n// \t\t\treturn 'second'\r\n// \t\tcase 'hour':\r\n// \t\t\treturn 'minute'\r\n// \t\tcase 'day':\r\n// \t\t\treturn 'hour'\r\n// \t\tcase 'week':\r\n// \t\t\treturn 'day'\r\n// \t\tcase 'month':\r\n// \t\t\treturn 'week'\r\n// \t\tcase 'year':\r\n// \t\t\treturn 'month'\r\n// \t}\r\n// }"],"mappings":";;;;;;;;AAAO,IAAMA,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG,EAAE,EAAC;;AAElB,IAAME,IAAI,GAAAD,OAAA,CAAAC,IAAA,GAAG,EAAE,GAAGF,MAAM,EAAC;;AAEzB,IAAMG,GAAG,GAAAF,OAAA,CAAAE,GAAA,GAAG,EAAE,GAAGD,IAAI,EAAC;;AAEtB,IAAME,IAAI,GAAAH,OAAA,CAAAG,IAAA,GAAG,CAAC,GAAGD,GAAG,EAAC;;AAE5B;AACO,IAAME,KAAK,GAAAJ,OAAA,CAAAI,KAAA,GAAG,KAAK,GAAGF,GAAG,EAAC;;AAEjC;AACO,IAAMG,IAAI,GAAAL,OAAA,CAAAK,IAAA,GAAI,MAAM,GAAG,GAAG,GAAIH,GAAG,EAAC;;AAElC,SAASI,gBAAgBA,CAACC,IAAI,EAAE;EACtC,QAAQA,IAAI;IACX,KAAK,QAAQ;MACZ,OAAO,CAAC;IACT,KAAK,QAAQ;MACZ,OAAOR,MAAM;IACd,KAAK,MAAM;MACV,OAAOE,IAAI;IACZ,KAAK,KAAK;MACT,OAAOC,GAAG;IACX,KAAK,MAAM;MACV,OAAOC,IAAI;IACZ,KAAK,OAAO;MACX,OAAOC,KAAK;IACb,KAAK,MAAM;MACV,OAAOC,IAAI;EACb;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _approximate = _interopRequireDefault(require("../steps/approximate.js"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
9
|
// "gradation" is a legacy name for "steps".
|
|
13
10
|
// It's here just for legacy compatibility.
|
|
14
11
|
// Use "steps" name instead.
|
|
@@ -18,10 +15,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
18
15
|
// "units" is a legacy property.
|
|
19
16
|
// It's here just for legacy compatibility.
|
|
20
17
|
// Developers shouldn't need to use it in their custom styles.
|
|
21
|
-
var _default = {
|
|
18
|
+
var _default = exports["default"] = {
|
|
22
19
|
gradation: _approximate["default"],
|
|
23
20
|
flavour: 'long',
|
|
24
21
|
units: ['now', 'minute', 'hour', 'day', 'week', 'month', 'year']
|
|
25
22
|
};
|
|
26
|
-
exports["default"] = _default;
|
|
27
23
|
//# sourceMappingURL=approximate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approximate.js","names":["gradation","approximate","flavour","units"],"sources":["../../source/style/approximate.js"],"sourcesContent":["import approximate from '../steps/approximate.js'\r\n\r\n// \"gradation\" is a legacy name for \"steps\".\r\n// It's here just for legacy compatibility.\r\n// Use \"steps\" name instead.\r\n\r\n// \"flavour\" is a legacy name for \"labels\".\r\n// It's here just for legacy compatibility.\r\n// Use \"labels\" name instead.\r\n\r\n// \"units\" is a legacy property.\r\n// It's here just for legacy compatibility.\r\n// Developers shouldn't need to use it in their custom styles.\r\n\r\nexport default {\r\n\tgradation: approximate,\r\n\tflavour: 'long',\r\n\tunits: [\r\n\t\t'now',\r\n\t\t'minute',\r\n\t\t'hour',\r\n\t\t'day',\r\n\t\t'week',\r\n\t\t'month',\r\n\t\t'year'\r\n\t]\r\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"approximate.js","names":["_approximate","_interopRequireDefault","require","e","__esModule","_default","exports","gradation","approximate","flavour","units"],"sources":["../../source/style/approximate.js"],"sourcesContent":["import approximate from '../steps/approximate.js'\r\n\r\n// \"gradation\" is a legacy name for \"steps\".\r\n// It's here just for legacy compatibility.\r\n// Use \"steps\" name instead.\r\n\r\n// \"flavour\" is a legacy name for \"labels\".\r\n// It's here just for legacy compatibility.\r\n// Use \"labels\" name instead.\r\n\r\n// \"units\" is a legacy property.\r\n// It's here just for legacy compatibility.\r\n// Developers shouldn't need to use it in their custom styles.\r\n\r\nexport default {\r\n\tgradation: approximate,\r\n\tflavour: 'long',\r\n\tunits: [\r\n\t\t'now',\r\n\t\t'minute',\r\n\t\t'hour',\r\n\t\t'day',\r\n\t\t'week',\r\n\t\t'month',\r\n\t\t'year'\r\n\t]\r\n}"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAiD,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAEjD;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAAA,IAAAE,QAAA,GAAAC,OAAA,cAEe;EACdC,SAAS,EAAEC,uBAAW;EACtBC,OAAO,EAAE,MAAM;EACfC,KAAK,EAAE,CACN,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM;AAER,CAAC","ignoreList":[]}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _approximate = _interopRequireDefault(require("../steps/approximate.js"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
9
|
// "gradation" is a legacy name for "steps".
|
|
13
10
|
// It's here just for legacy compatibility.
|
|
14
11
|
// Use "steps" name instead.
|
|
@@ -41,10 +38,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
41
38
|
// a year
|
|
42
39
|
// 2 years
|
|
43
40
|
//
|
|
44
|
-
var _default = {
|
|
41
|
+
var _default = exports["default"] = {
|
|
45
42
|
gradation: _approximate["default"],
|
|
46
43
|
flavour: 'long-time',
|
|
47
44
|
units: ['now', 'minute', 'hour', 'day', 'week', 'month', 'year']
|
|
48
45
|
};
|
|
49
|
-
exports["default"] = _default;
|
|
50
46
|
//# sourceMappingURL=approximateTime.js.map
|