@applitools/monitoring-commons
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -1,2 +0,2 @@ | ||
export function makeTiming({ parentPerformance, nowService, }?: { | ||
export function makeTiming({ parentPerformance, nowService }?: { | ||
parentPerformance?: undefined; | ||
@@ -3,0 +3,0 @@ nowService?: (() => number) | undefined; |
@@ -1,3 +0,3 @@ | ||
"use strict"; | ||
function makeTiming({ parentPerformance = undefined, nowService = Date.now, } = {}) { | ||
'use strict'; | ||
function makeTiming({ parentPerformance = undefined, nowService = Date.now } = {}) { | ||
const performance = parentPerformance || {}; | ||
@@ -13,4 +13,3 @@ /** | ||
const start = nowService(); | ||
return f().then((v) => ((performance[name] = (performance[name] || 0) + nowService() - start), v), (v) => ((performance[name] = (performance[name] || 0) + nowService() - start), | ||
Promise.reject(v))); | ||
return f().then((v) => ((performance[name] = (performance[name] || 0) + nowService() - start), v), (v) => ((performance[name] = (performance[name] || 0) + nowService() - start), Promise.reject(v))); | ||
} | ||
@@ -17,0 +16,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
export function makeTiming({ parentPerformance, nowService, }?: { | ||
export function makeTiming({ parentPerformance, nowService }?: { | ||
parentPerformance?: undefined; | ||
@@ -3,0 +3,0 @@ nowService?: (() => number) | undefined; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function makeTiming({ parentPerformance = undefined, nowService = Date.now, } = {}) { | ||
function makeTiming({ parentPerformance = undefined, nowService = Date.now } = {}) { | ||
const performance = parentPerformance || {}; | ||
@@ -14,4 +14,3 @@ /** | ||
const start = nowService(); | ||
return f().then((v) => ((performance[name] = (performance[name] || 0) + nowService() - start), v), (v) => ((performance[name] = (performance[name] || 0) + nowService() - start), | ||
Promise.reject(v))); | ||
return f().then((v) => ((performance[name] = (performance[name] || 0) + nowService() - start), v), (v) => ((performance[name] = (performance[name] || 0) + nowService() - start), Promise.reject(v))); | ||
} | ||
@@ -18,0 +17,0 @@ /** |
{ | ||
"name": "@applitools/monitoring-commons", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "", | ||
@@ -25,4 +25,3 @@ "main": "dist/cjs/monitoring-commons.js", | ||
"test:mocha-mjs": "npm run build && mocha --require @babel/register --no-timeouts 'test/**/*.test.mjs'", | ||
"eslint": "eslint '**/*.js'", | ||
"prepublishOnly": "npm version patch" | ||
"eslint": "eslint '**/*.js'" | ||
}, | ||
@@ -57,3 +56,6 @@ "keywords": [ | ||
"typescript": "^5.1.6" | ||
}, | ||
"dependencies": { | ||
"@applitools/monitoring-commons": "^2.0.1" | ||
} | ||
} |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
'use strict' | ||
function makeTiming({ | ||
parentPerformance = undefined, | ||
nowService = Date.now, | ||
} = {}) { | ||
const performance = parentPerformance || {}; | ||
function makeTiming({parentPerformance = undefined, nowService = Date.now} = {}) { | ||
const performance = parentPerformance || {} | ||
@@ -17,13 +14,10 @@ /** | ||
function timeItAsync(name, f) { | ||
const start = nowService(); | ||
const start = nowService() | ||
return f().then( | ||
(v) => ((performance[name] = (performance[name] || 0) + nowService() - start), v), | ||
(v) => ( | ||
(performance[name] = (performance[name] || 0) + nowService() - start), v | ||
(performance[name] = (performance[name] || 0) + nowService() - start), Promise.reject(v) | ||
), | ||
(v) => ( | ||
(performance[name] = (performance[name] || 0) + nowService() - start), | ||
Promise.reject(v) | ||
), | ||
); | ||
) | ||
} | ||
@@ -37,6 +31,6 @@ | ||
function getTimeItCallback(name) { | ||
const start = nowService(); | ||
const start = nowService() | ||
return () => { | ||
performance[name] = (performance[name] || 0) + nowService() - start; | ||
}; | ||
performance[name] = (performance[name] || 0) + nowService() - start | ||
} | ||
} | ||
@@ -52,12 +46,12 @@ | ||
function timeIt(name, f) { | ||
const start = nowService(); | ||
const start = nowService() | ||
try { | ||
const ret = f(); | ||
const ret = f() | ||
performance[name] = (performance[name] || 0) + nowService() - start; | ||
performance[name] = (performance[name] || 0) + nowService() - start | ||
return ret; | ||
return ret | ||
} catch (err) { | ||
performance[name] = (performance[name] || 0) + nowService() - start; | ||
throw err; | ||
performance[name] = (performance[name] || 0) + nowService() - start | ||
throw err | ||
} | ||
@@ -71,3 +65,3 @@ } | ||
performance, | ||
}; | ||
} | ||
} | ||
@@ -77,2 +71,2 @@ | ||
makeTiming, | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
21575
1
185