range.ts 592 B

1234567891011121314151617181920212223242526
  1. import { UpdateRange } from '../services/types/update'
  2. export const computeUpdateRange = (
  3. updateRange: UpdateRange,
  4. fromV: number,
  5. toV: number,
  6. updateMetaEndTimestamp: number
  7. ) => {
  8. const fromVersion = Math.min(fromV, updateRange.fromV)
  9. const toVersion = Math.max(toV, updateRange.toV)
  10. const fromVTimestamp = Math.min(
  11. updateMetaEndTimestamp,
  12. updateRange.fromVTimestamp
  13. )
  14. const toVTimestamp = Math.max(
  15. updateMetaEndTimestamp,
  16. updateRange.toVTimestamp
  17. )
  18. return {
  19. fromV: fromVersion,
  20. toV: toVersion,
  21. fromVTimestamp,
  22. toVTimestamp,
  23. }
  24. }