now.js 349 B

123456789101112131415161718
  1. /**
  2. * Get current time in miliseconds
  3. */
  4. function now(){
  5. // yes, we defer the work to another function to allow mocking it
  6. // during the tests
  7. return now.get();
  8. }
  9. now.get = (typeof Date.now === 'function')? Date.now : function(){
  10. return +(new Date());
  11. };
  12. module.exports = now;