MCPcopy Create free account
hub / github.com/DavidWells/analytics / formatSize

Function formatSize

scripts/getSize.js:9–15  ·  view source on GitHub ↗
(size, filename, type, raw)

Source from the content-addressed store, hash-verified

7const chalk = safeChalk()
8
9function formatSize(size, filename, type, raw) {
10 const pretty = raw ? `${size}B` : prettyBytes(size)
11 const color = size < 5000 ? 'green' : size > 40000 ? 'red' : 'yellow'
12 const MAGIC_INDENTATION = type === 'br' ? 13 : 10
13 const prefix = ' '.repeat(MAGIC_INDENTATION - pretty.length)
14 return `${prefix}${chalk[color](pretty)}: ${chalk.white(path.basename(filename))}.${type}`
15}
16
17function pretty(size, raw) {
18 return raw ? `${size}kb` : prettyBytes(size)

Callers 1

getSizeInfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected