Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.