Socket
Socket
Sign inDemoInstall

jsprim

Package Overview
Dependencies
3
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.1 to 0.7.0

test/hrtimediff.js

30

lib/jsprim.js

@@ -28,2 +28,3 @@ /*

exports.randElt = randElt;
exports.hrtimediff = hrtimediff;

@@ -327,1 +328,30 @@ exports.startsWith = startsWith;

}
/*
* Compute the time elapsed between hrtime readings A and B, where A is later
* than B. hrtime readings come from Node's process.hrtime(). There is no
* defined way to represent negative deltas, so it's illegal to diff B from A
* where the time denoted by B is later than the time denoted by A. If this
* becomes valuable, we can define a representation and extend the
* implementation to support it.
*/
function hrtimediff(a, b)
{
mod_assert.ok(a[0] >= 0 && a[1] >= 0 && b[0] >= 0 && b[1] >= 0,
'negative numbers not allowed in hrtimes');
mod_assert.ok(a[1] < 1e9 && b[1] < 1e9,
'nanoseconds column overflow');
mod_assert.ok(a[0] > b[0] || (a[0] == b[0] && a[1] >= b[1]),
'negative differences not allowed');
var rv = [ a[0] - b[0], 0 ];
if (a[1] >= b[1]) {
rv[1] = a[1] - b[1];
} else {
rv[0]--;
rv[1] = 1e9 - (b[1] - a[1]);
}
return (rv);
}

2

package.json
{
"name": "jsprim",
"version": "0.6.1",
"version": "0.7.0",
"description": "utilities for primitive JavaScript types",

@@ -5,0 +5,0 @@ "main": "./lib/jsprim.js",

@@ -146,2 +146,9 @@ # jsprim: utilities for primitive JavaScript types

### hrtimediff(timeA, timeB)
Given two hrtime readings (as from Node's `process.hrtime()`), where timeA is
later than timeB, compute the difference and return that as an hrtime. It is
illegal to invoke this for a pair of times where timeB is newer than timeA.
### validateJsonObject(schema, object)

@@ -148,0 +155,0 @@

Sorry, the diff of this file is not supported yet

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