
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@songkick/promise-stopwatch
Advanced tools
Mesure a Promise resolution duration using Performance API with fallback to `new Data()`
Mesure a Promise resolution duration using Performance API with fallback to new Data()
.
var stopwatch = require('promise-stopwatch');
function resolveInOneSec() {
return new Promise(function(resolve, reject){
setTimeout(function(){
resolve('yay');
}, 1000);
});
}
var settings = {}; // there is none available for now
stopwatch(settings)(resolveInOneSec)().then(function(response){
var result = response.result; // === 'yay'
var duration = response.duration; // ~== 1000
var settings = response.settings; // === {}
console.log('Resolution took ' + duration + 'ms');
return result; // return the result so you can handle it normally
});
function rejectInOneSec() {
return new Promise(function(resolve, reject){
setTimeout(function(){
reject('nay');
}, 1000);
});
}
stopwatch(settings)(rejectInOneSec)().catch(function(response){
var error = response.error; // === 'nay'
var duration = response.duration; // ~== 1000
var settings = response.settings; // === {}
console.log('Rejection took ' + duration + 'ms');
throw error; // possibly re-throw the error so you can handle it normally
});
None, for now, but it might come, so we keep this signature similar to other promise helper and be able to some without change the API.
promise-stopwatch
composes really well with the following promise helper:
FAQs
Mesure a Promise resolution duration using Performance API with fallback to `new Data()`
The npm package @songkick/promise-stopwatch receives a total of 1 weekly downloads. As such, @songkick/promise-stopwatch popularity was classified as not popular.
We found that @songkick/promise-stopwatch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.