@applitools/monitoring-commons
Advanced tools
Comparing version 1.0.15 to 1.0.17
{ | ||
"name": "@applitools/monitoring-commons", | ||
"version": "1.0.15", | ||
"version": "1.0.17", | ||
"description": "", | ||
@@ -37,2 +37,3 @@ "main": "src/monitoring-commons.js", | ||
"devDependencies": { | ||
"@applitools/build-commons": "^1.1.13", | ||
"chai": "^4.2.0", | ||
@@ -42,6 +43,6 @@ "eslint": "^5.16.0", | ||
"eslint-plugin-node": "^8.0.1", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"mocha": "^4.0.1", | ||
"prettier": "^1.18.2" | ||
"prettier": "^1.19.1" | ||
} | ||
} |
'use strict' | ||
function makeTiming({parentPerformance = undefined} = {}) { | ||
function makeTiming({parentPerformance = undefined, nowService = Date.now} = {}) { | ||
const performance = parentPerformance || {} | ||
@@ -14,7 +14,9 @@ | ||
function timeItAsync(name, f) { | ||
const start = Date.now() | ||
const start = nowService() | ||
return f().then( | ||
v => ((performance[name] = (performance[name] || 0) + Date.now() - start), v), | ||
v => ((performance[name] = (performance[name] || 0) + Date.now() - start), Promise.reject(v)), | ||
v => ((performance[name] = (performance[name] || 0) + nowService() - start), v), | ||
v => ( | ||
(performance[name] = (performance[name] || 0) + nowService() - start), Promise.reject(v) | ||
), | ||
) | ||
@@ -28,14 +30,14 @@ } | ||
* @param {()=>T} f | ||
* @returns | ||
* @returns {T} | ||
*/ | ||
function timeIt(name, f) { | ||
const start = Date.now() | ||
const start = nowService() | ||
try { | ||
const ret = f() | ||
performance[name] = (performance[name] || 0) + Date.now() - start | ||
performance[name] = (performance[name] || 0) + nowService() - start | ||
return ret | ||
} catch (err) { | ||
performance[name] = (performance[name] || 0) + Date.now() - start | ||
performance[name] = (performance[name] || 0) + nowService() - start | ||
throw err | ||
@@ -42,0 +44,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13527
46
8