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

unitimer

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unitimer - npm Package Compare versions

Comparing version 3.3.0 to 3.4.0

27

dist/unitimer.js

@@ -22,10 +22,22 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.unitimer = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

function createInstance (tag) {
var totalTime = 0
var meanTime = 0
var minTime = -1
var maxTime = -1
var count = 0
var tookTime = -1
var startTimes = {}
var totalTime
var meanTime
var minTime
var maxTime
var count
var tookTime
var startTimes
function reset () {
totalTime = 0
meanTime = 0
minTime = -1
maxTime = -1
count = 0
tookTime = 0
startTimes = {}
}
reset()
return {

@@ -49,2 +61,3 @@ start: function (id = 'default') {

},
reset,
took: function () {

@@ -51,0 +64,0 @@ return tookTime

@@ -11,10 +11,22 @@ var now = require('./now')

function createInstance (tag) {
var totalTime = 0
var meanTime = 0
var minTime = -1
var maxTime = -1
var count = 0
var tookTime = -1
var startTimes = {}
var totalTime
var meanTime
var minTime
var maxTime
var count
var tookTime
var startTimes
function reset () {
totalTime = 0
meanTime = 0
minTime = -1
maxTime = -1
count = 0
tookTime = 0
startTimes = {}
}
reset()
return {

@@ -38,2 +50,3 @@ start: function (id = 'default') {

},
reset,
took: function () {

@@ -40,0 +53,0 @@ return tookTime

{
"name": "unitimer",
"version": "3.3.0",
"version": "3.4.0",
"description": "Universal timer (Node.js and browser)",

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

@@ -41,2 +41,6 @@ # unitimer

### `timer.took()`
Returns the most recent start / stop interval in milliseconds.
### `timer.mean()`

@@ -48,3 +52,3 @@

Returns the total time taken for a given (addition of `start` / `stop` durations)
Returns the total time taken (an addition of `start` / `stop` intervals)

@@ -70,1 +74,5 @@ ### `timer.count()`

`console.log` of `timer.info()` (see above)
### `timer.stats()`
Returns a stats object.

@@ -95,2 +95,25 @@ const test = require('ava')

test('reset()', (t) => {
const times = [
[1, 0],
[2, 0]
]
const hrtime = stubHrtime(times)
const a = createTimer().start()
a.stop()
a.reset()
t.deepEqual(
a.stats(),
{
took: 0,
total: 0,
mean: 0,
count: 0,
min: -1,
max: -1
}
)
hrtime.restore()
})
test('total() is total time', (t) => {

@@ -97,0 +120,0 @@ const times = [

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