MCPcopy
hub / github.com/vitejs/vite / displayTime

Function displayTime

packages/vite/src/node/utils.ts:1764–1788  ·  view source on GitHub ↗
(time: number)

Source from the content-addressed store, hash-verified

1762}
1763
1764export function displayTime(time: number): string {
1765 // display: {X}ms
1766 if (time < 1000) {
1767 return `${time}ms`
1768 }
1769
1770 time = time / 1000
1771
1772 // display: {X}s
1773 if (time < 60) {
1774 return `${time.toFixed(2)}s`
1775 }
1776
1777 // Calculate total minutes and remaining seconds
1778 const mins = Math.floor(time / 60)
1779 const seconds = Math.round(time % 60)
1780
1781 // Handle case where seconds rounds to 60
1782 if (seconds === 60) {
1783 return `${mins + 1}m`
1784 }
1785
1786 // display: {X}m {Y}s
1787 return `${mins}m${seconds < 1 ? '' : ` ${seconds}s`}`
1788}
1789
1790/**
1791 * Encodes the URI path portion (ignores part after ? or #)

Callers 1

buildEnvironmentFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected