MCPcopy
hub / github.com/jestjs/jest / formatTime

Function formatTime

packages/jest-util/src/formatTime.ts:8–22  ·  view source on GitHub ↗
(
  time: number,
  prefixPower = -3,
  padLeftLength = 0,
)

Source from the content-addressed store, hash-verified

6 */
7
8export default function formatTime(
9 time: number,
10 prefixPower = -3,
11 padLeftLength = 0,
12): string {
13 const prefixes = ['n', 'μ', 'm', ''];
14 const prefixIndex = Math.max(
15 0,
16 Math.min(
17 Math.trunc(prefixPower / 3) + prefixes.length - 1,
18 prefixes.length - 1,
19 ),
20 );
21 return `${String(time).padStart(padLeftLength)} ${prefixes[prefixIndex]}s`;
22}

Callers 11

_makeTimeoutMessageFunction · 0.90
timeEndMethod · 0.90
timeLogMethod · 0.90
timeEndMethod · 0.90
timeLogMethod · 0.90
mapperFunction · 0.90
renderTimeFunction · 0.90
getResultHeaderFunction · 0.90
_logTestMethod · 0.90
logFunction · 0.85
formatTime.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected