Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

relative-microtime

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

relative-microtime - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

16

index.js
'use strict'
const nanoStart = process.hrtime()
const microStart = Date.now() * 1000
module.exports = function sync () {
const nanoStart = process.hrtime()
const microStart = Date.now() * 1000
module.exports = function microtime () {
const diff = process.hrtime(nanoStart)
const microRemainder = diff[1] / 1000 | 0 // Use bitwise OR to remove the decimals
const microDelta = diff[0] * 1e6 + microRemainder
return microStart + microDelta
return function microtime () {
const diff = process.hrtime(nanoStart)
const microRemainder = diff[1] / 1000 | 0 // Use bitwise OR to remove the decimals
const microDelta = diff[0] * 1e6 + microRemainder
return microStart + microDelta
}
}
{
"name": "relative-microtime",
"version": "1.0.0",
"version": "2.0.0",
"description": "Get the number of microseconds elapsed since January 1, 1970 00:00:00 UTC without fear of clock drift",

@@ -37,5 +37,5 @@ "main": "index.js",

"coordinates": [
55.778268,
12.593064
55.778279,
12.593066
]
}

@@ -6,5 +6,5 @@ # relative-microtime

Note: The returned number of microseconds are locked relative to the
start time of the process and is therefore not subject to clock drift.
This is contrary to how `Date.now()` operates, whos return value (in
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.

@@ -25,6 +25,6 @@

```js
const microtime = require('relative-microtime')
const timer = require('relative-microtime')()
const milli = Date.now()
const micro = microtime()
const micro = timer()

@@ -39,4 +39,12 @@ console.log(milli) // 1537446194859

### `microtime()`
### `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

@@ -43,0 +51,0 @@ epoch.

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc