Socket
Socket
Sign inDemoInstall

relative-microtime

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    relative-microtime

Get the number of microseconds elapsed since January 1, 1970 00:00:00 UTC without fear of clock drift


Version published
Weekly downloads
290K
increased by6.98%
Maintainers
1
Install size
4.56 kB
Created
Weekly downloads
 

Readme

Source

relative-microtime

This module returns the number of microseconds elapsed since January 1, 1970 00:00:00 UTC.

Note: The returned number of microseconds are locked relative to a specific time and is therefore not subject to clock drift. This is contrary to how Date.now() operates, whos return value (in milliseconds) is always based on the system clock.

npm build status js-standard-style

Installation

npm install relative-microtime --save

Usage

const timer = require('relative-microtime')()

const milli = Date.now()
const micro = timer()

console.log(milli) // 1537446194859
console.log(micro) // 1537446194859132

Gotcha

API

timer = microtime()

Sync the microtime clock to the UTC wall clock.

Returns a timer function synced with the UTC time when microtime() was called. Any clock drift that happens after the call to microtime() will not influence the returned timer.

timer()

Returns a Number representing the microseconds elapsed since the UNIX epoch.

License

MIT

Keywords

FAQs

Last updated on 16 Oct 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc