ms.js 430 B

123456789101112131415161718
  1. 'use strict';
  2. const format = require('./format');
  3. const ms = require('ms');
  4. /*
  5. * function ms (info)
  6. * Returns an `info` with a `ms` property. The `ms` property holds the Value
  7. * of the time difference between two calls in milliseconds.
  8. */
  9. module.exports = format(info => {
  10. const curr = +new Date();
  11. this.diff = curr - (this.prevTime || curr);
  12. this.prevTime = curr;
  13. info.ms = `+${ms(this.diff)}`;
  14. return info;
  15. });