All files / packages/logger/src/format/plugins ms.ts

0% Statements 0/10
0% Branches 0/1
0% Functions 0/1
0% Lines 0/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19                                     
import ms from 'ms'
import format from '../format'
 
/*
 * function ms (info)
 * Returns an `info` with a `ms` property. The `ms` property holds the value
 * of the time difference between two calls in milliseconds.
 */
let prevTime: number
 
export default format((info) => {
  const curr = +new Date()
  const diff = curr - (prevTime || curr)
  prevTime = curr
  info.ms = `+${ms(diff)}`
 
  return info
})