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

node-tictoc

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-tictoc - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

40

index.js

@@ -1,4 +0,10 @@

// Stack of timers
/**
* Stack of timers
* @type {Array}
*/
var timers = [];
/**
* Creates a new timer
*/
module.exports.tic = function () {

@@ -8,16 +14,30 @@ timers.push(process.hrtime());

/**
* Prints the elapsed seconds and milliseconds for the most recent timer
*/
module.exports.toc = function () {
if (! timers.length) return;
var time = this.toct();
var time = process.hrtime(timers.pop()),
seconds = time[0],
nanos = time[1],
ms = nanos / 1000000;
var result = '';
if (seconds) result += seconds + ' seconds ';
if (ms) result += ms + ' ms ';
if (time.seconds) result += time.seconds + ' seconds ';
if (time.ms) result += time.ms + ' ms ';
console.log(result);
};
};
/**
* If you just want the elapsed time without printing
* @return {Object} Contains the time conversions (seconds, nanos, ms) for the most recent timer
*/
module.exports.toct = function() {
if (! timers.length) return null;
var time = process.hrtime(timers.pop());
return {
seconds: time[0],
nanos: time[1],
ms: time[1] / 1000000
};
};
{
"name": "node-tictoc",
"version": "1.0.0",
"version": "1.1.0",
"description": "Simple stopwatch timer for profiling operations",

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

@@ -1,7 +0,9 @@

node-tictoc
===
### tictoc
Wrapper around `process.hrtime` that lets you have a stack of
timers with a simpler api and more useful output:
`npm install node-tictoc`
Wrapper around `process.hrtime` that lets you have a stack of timers with a simpler api and more useful output:
### Usage
```javascript

@@ -31,2 +33,14 @@ var time = require('node-tictoc');

}
```
```
If you just want the time values:
```javascript
time.toct()
```
Returns an object with the following values for the most recent timer (started with `tic`):
* `seconds`
* `nanos`
* `ms`
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