Socket
Socket
Sign inDemoInstall

unitimer

Package Overview
Dependencies
0
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.5.1 to 3.6.1

.babelrc

252

dist/unitimer.js

@@ -1,80 +0,155 @@

(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 now () {
return typeof window.performance !== 'undefined' &&
typeof window.performance.now !== 'undefined'
? window.performance.now()
: Date.now()
}
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["unitimer"] = factory();
else
root["unitimer"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = now
var now = __webpack_require__(1);
},{}],2:[function(require,module,exports){
var now = require('./now')
function toFixed (v, dp) {
function toFixed(v, dp) {
if (typeof dp === 'undefined') {
return v
return v;
}
return v.toFixed(dp)
return v.toFixed(dp);
}
function createInstance (tag) {
var totalTime
var meanTime
var minTime
var maxTime
var count
var tookTime
var startTimes
function createInstance(tag) {
var totalTime = void 0;
var meanTime = void 0;
var minTime = void 0;
var maxTime = void 0;
var _count = void 0;
var tookTime = void 0;
var startTimes = void 0;
function reset () {
totalTime = 0
meanTime = 0
minTime = -1
maxTime = -1
count = 0
tookTime = 0
startTimes = {}
function reset() {
totalTime = 0;
meanTime = 0;
minTime = -1;
maxTime = -1;
_count = 0;
tookTime = 0;
startTimes = {};
}
reset()
reset();
return {
start: function (id = 'default') {
var time = now()
startTimes[id] = time
return this
start: function start() {
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
var time = now();
startTimes[id] = time;
return this;
},
stop: function (id = 'default') {
const startTime = startTimes[id]
if (!startTime) { return -1 }
tookTime = now() - startTime
minTime = minTime === -1 ? tookTime : Math.min(minTime, tookTime)
maxTime = maxTime === -1 ? tookTime : Math.max(maxTime, tookTime)
totalTime += tookTime
count += 1
meanTime = totalTime / count
startTimes[id] = undefined
return tookTime
stop: function stop() {
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
var startTime = startTimes[id];
if (!startTime) {
return -1;
}
tookTime = now() - startTime;
minTime = minTime === -1 ? tookTime : Math.min(minTime, tookTime);
maxTime = maxTime === -1 ? tookTime : Math.max(maxTime, tookTime);
totalTime += tookTime;
_count += 1;
meanTime = totalTime / _count;
startTimes[id] = undefined;
return tookTime;
},
reset,
took: function () {
return tookTime
reset: reset,
took: function took() {
return tookTime;
},
total: function () {
return totalTime
total: function total() {
return totalTime;
},
mean: function () {
return meanTime
mean: function mean() {
return meanTime;
},
count: function () {
return count
count: function count() {
return _count;
},
min: function () {
return minTime
min: function min() {
return minTime;
},
max: function () {
return maxTime
max: function max() {
return maxTime;
},
stats: function () {
stats: function stats() {
return {

@@ -84,48 +159,53 @@ mean: meanTime,

total: totalTime,
count: count,
count: _count,
min: minTime,
max: maxTime
}
};
},
info: function (dp) {
return (tag ? '[' + tag + '] ' : '') +
'mean: ' + toFixed(meanTime, dp) +
'ms, took: ' + toFixed(tookTime, dp) +
'ms, total: ' + toFixed(totalTime, dp) +
'ms, count: ' + count +
', min: ' + toFixed(minTime, dp) +
'ms, max: ' + toFixed(maxTime, dp) +
'ms'
info: function info(dp) {
return (tag ? '[' + tag + '] ' : '') + 'mean: ' + toFixed(meanTime, dp) + 'ms, took: ' + toFixed(tookTime, dp) + 'ms, total: ' + toFixed(totalTime, dp) + 'ms, count: ' + _count + ', min: ' + toFixed(minTime, dp) + 'ms, max: ' + toFixed(maxTime, dp) + 'ms';
},
log: function (dp) {
console.log(this.info(dp))
log: function log(dp) {
// eslint-disable-next-line no-console
console.log(this.info(dp));
}
}
};
}
function isArray (o) {
return Object.prototype.toString.call(o) === '[object Array]'
function isArray(o) {
return Object.prototype.toString.call(o) === '[object Array]';
}
function isString (o) {
return (typeof o === 'string') || (o instanceof String)
function isString(o) {
return typeof o === 'string' || o instanceof String;
}
function createTimer (tags) {
function createTimer(tags) {
if (isArray(tags)) {
var a = []
var a = [];
for (var i = 0; i < tags.length; i += 1) {
a.push(createInstance(tags[i]))
a.push(createInstance(tags[i]));
}
return a
return a;
}
if (isString(tags)) {
return createInstance(tags)
return createInstance(tags);
}
return createInstance()
return createInstance();
}
module.exports = createTimer
module.exports = createTimer;
},{"./now":1}]},{},[2])(2)
/***/ }),
/* 1 */
/***/ (function(module, exports) {
function now() {
return typeof window.performance !== 'undefined' && typeof window.performance.now !== 'undefined' ? window.performance.now() : Date.now();
}
module.exports = now;
/***/ })
/******/ ]);
});

@@ -1,2 +0,2 @@

function now () {
function now() {
return typeof window.performance !== 'undefined' &&

@@ -3,0 +3,0 @@ typeof window.performance.now !== 'undefined'

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

var now = require('./now')
const now = require('./now')
function toFixed (v, dp) {
function toFixed(v, dp) {
if (typeof dp === 'undefined') {

@@ -10,12 +10,12 @@ return v

function createInstance (tag) {
var totalTime
var meanTime
var minTime
var maxTime
var count
var tookTime
var startTimes
function createInstance(tag) {
let totalTime
let meanTime
let minTime
let maxTime
let count
let tookTime
let startTimes
function reset () {
function reset() {
totalTime = 0

@@ -33,11 +33,9 @@ meanTime = 0

return {
start: function (id) {
id = id || 'default'
var time = now()
start(id = 'default') {
const time = now()
startTimes[id] = time
return this
},
stop: function (id) {
id = id || 'default'
var startTime = startTimes[id]
stop(id = 'default') {
const startTime = startTimes[id]
if (!startTime) { return -1 }

@@ -54,21 +52,21 @@ tookTime = now() - startTime

reset,
took: function () {
took() {
return tookTime
},
total: function () {
total() {
return totalTime
},
mean: function () {
mean() {
return meanTime
},
count: function () {
count() {
return count
},
min: function () {
min() {
return minTime
},
max: function () {
max() {
return maxTime
},
stats: function () {
stats() {
return {

@@ -78,3 +76,3 @@ mean: meanTime,

total: totalTime,
count: count,
count,
min: minTime,

@@ -84,13 +82,13 @@ max: maxTime

},
info: function (dp) {
return (tag ? '[' + tag + '] ' : '') +
'mean: ' + toFixed(meanTime, dp) +
'ms, took: ' + toFixed(tookTime, dp) +
'ms, total: ' + toFixed(totalTime, dp) +
'ms, count: ' + count +
', min: ' + toFixed(minTime, dp) +
'ms, max: ' + toFixed(maxTime, dp) +
'ms'
info(dp) {
return `${tag ? `[${tag}] ` : ''}mean: ${toFixed(meanTime, dp)
}ms, took: ${toFixed(tookTime, dp)
}ms, total: ${toFixed(totalTime, dp)
}ms, count: ${count
}, min: ${toFixed(minTime, dp)
}ms, max: ${toFixed(maxTime, dp)
}ms`
},
log: function (dp) {
log(dp) {
// eslint-disable-next-line no-console
console.log(this.info(dp))

@@ -101,14 +99,14 @@ }

function isArray (o) {
function isArray(o) {
return Object.prototype.toString.call(o) === '[object Array]'
}
function isString (o) {
function isString(o) {
return (typeof o === 'string') || (o instanceof String)
}
function createTimer (tags) {
function createTimer(tags) {
if (isArray(tags)) {
var a = []
for (var i = 0; i < tags.length; i += 1) {
const a = []
for (let i = 0; i < tags.length; i += 1) {
a.push(createInstance(tags[i]))

@@ -115,0 +113,0 @@ }

@@ -1,6 +0,6 @@

function now () {
function now() {
const t = process.hrtime()
return t[0] * 1000 + t[1] / 1000000
return (t[0] * 1000) + (t[1] / 1000000)
}
module.exports = now
{
"name": "unitimer",
"version": "3.5.1",
"version": "3.6.1",
"description": "Universal timer (Node.js and browser)",

@@ -10,8 +10,8 @@ "main": "./lib/index.js",

"scripts": {
"build": "browserify lib/index.js -s unitimer -o dist/unitimer.js",
"build:min": "browserify lib/index.js -s unitimer | uglifyjs -c > dist/unitimer.min.js",
"watch": "watchify lib/index.js -s unitimer -o dist/unitimer.js",
"lint": "standard",
"build": "webpack",
"watch": "webpack --watch",
"lint": "eslint . --ext .js",
"fix": "eslint . --ext .js --fix",
"unit": "ava -v",
"test": "standard && ava -v"
"test": "yarn lint && ava -v"
},

@@ -51,8 +51,19 @@ "ava": {

"ava": "^0.19.1",
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.1.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-latest": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.24.1",
"browserify": "^14.3.0",
"eslint": "^3.19.0",
"eslint-config-airbnb-base": "^11.2.0",
"eslint-plugin-import": "^2.2.0",
"proxyquire": "^1.7.10",
"sinon": "^2.3.1",
"standard": "^10.0.2",
"watchify": "^3.7.0"
"watchify": "^3.7.0",
"webpack": "^3.0.0"
}
}

@@ -5,5 +5,5 @@ const test = require('ava')

function stubHrtime (times) {
function stubHrtime(times) {
let index = 0
function fn () {
function fn() {
return times[index++]

@@ -84,6 +84,6 @@ }

const hrtime = stubHrtime(times)
var a = createTimer().start()
var b = createTimer().start()
const a = createTimer().start()
const b = createTimer().start()
const msA = a.stop()
var c = createTimer().start()
const c = createTimer().start()
const msC = c.stop()

@@ -273,3 +273,3 @@ const msB = b.stop()

const hrtime = stubHrtime(times)
const [ foo, bar ] = createTimer(['foo', 'bar'])
const [foo, bar] = createTimer(['foo', 'bar'])
foo.start()

@@ -276,0 +276,0 @@ foo.stop()

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc