File size: 1,109 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import picocolors from 'picocolors'
import { Interface } from '../index.js'
import { formatUnit } from '../units.js'
import { formatVariant } from '../utils.js'
const { bgCyan, bold, magenta, red, underline } = picocolors
export default function createInterface(): Interface {
const iface: Interface = {
start: async (scenario, props) => {
console.log(
bold(underline(`Running ${formatVariant(scenario, props)}...`))
)
},
measurement: async (scenario, props, name, value, unit, relativeTo) => {
console.log(
bgCyan(
bold(
magenta(
`${formatVariant(scenario, props)}: ${name} = ${formatUnit(
value,
unit
)}${relativeTo ? ` (from ${relativeTo})` : ''}`
)
)
)
)
},
error: async (scenario, props, error) => {
console.log(
bold(
red(
`${formatVariant(scenario, props)}: ${
(error && (error as any).stack) || error
}`
)
)
)
},
}
return iface
}
|