Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@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 0 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.