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

hirestime

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hirestime - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

7

index.js

@@ -11,3 +11,8 @@ var S = 'seconds';

return recalc(elapsed[0] * 1e3 + elapsed[1] / 1e6, unit);
var time;
if(unit === S) time = elapsed[0] + elapsed[1] / 1e9;
else if(unit === NS) time = elapsed[0] * 1e9 + elapsed[1];
else if(unit === MS || !unit || !time) time = elapsed[0] * 1e3 + elapsed[1] / 1e6;
return parseInt(time * 100, 10) / 100;
}

@@ -14,0 +19,0 @@ }

4

package.json
{
"name": "hirestime",
"version": "0.2.2",
"version": "0.2.3",
"description": "thin wrapper around process.hrtime",

@@ -26,4 +26,4 @@ "main": "index.js",

"chai": "~1.8.1",
"hrtimemock": "0.0.1"
"hrtimemock": "0.0.2"
}
}

@@ -9,35 +9,35 @@ var expect = require('chai').expect;

it('should return an approximate number of elapsed time in milliseconds (no unit given)', function() {
hrtimeMock(100);
hrtimeMock(1100);
var getElapsed = hirestime();
expect(getElapsed()).to.equal(100);
expect(getElapsed()).to.equal(1100);
});
it('should return an approximate number of elapsed time in seconds (seconds unit)', function() {
hrtimeMock(100);
hrtimeMock(1100);
var getElapsed = hirestime();
expect(getElapsed(hirestime.S)).to.equal(0.1);
expect(getElapsed(hirestime.S)).to.equal(1.1);
});
it('should return an approximate number of elapsed time in seconds (milliseconds unit)', function() {
hrtimeMock(100);
it('should return an approximate number of elapsed time in milliseconds (milliseconds unit)', function() {
hrtimeMock(1100);
var getElapsed = hirestime();
expect(getElapsed(hirestime.MS)).to.equal(100);
expect(getElapsed(hirestime.MS)).to.equal(1100);
});
it('should return an approximate number of elapsed time in seconds (nanoseconds unit)', function() {
hrtimeMock(100);
it('should return an approximate number of elapsed time in nanoseconds (nanoseconds unit)', function() {
hrtimeMock(1100);
var getElapsed = hirestime();
expect(getElapsed(hirestime.NS)).to.equal(100000);
expect(getElapsed(hirestime.NS)).to.equal(1100000000);
});
it('should return an approximate number of elapsed time in seconds (unknown unit)', function() {
hrtimeMock(100);
it('should return an approximate number of elapsed time in milliseconds (unknown unit)', function() {
hrtimeMock(1100);
var getElapsed = hirestime();
expect(getElapsed('foo')).to.equal(100);
expect(getElapsed('foo')).to.equal(1100);
});
});
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