Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
trier-promise
Advanced tools
A promise based trier
Do one thing and do it well many times.
npm install trier-promise
var tp = require('trier-promise');
tp({
action: someFunctionThatReturnsAPromise,
timeout: 10000,
interval: 1000
})
.then(function(value) {
// the value from the first success
})
.catch(function(error) {
// error.message === 'TIMEOUT'
});
If the asynchronous function takes a while, you may not want overlapping calls.
tp({
action: aFunctionWithStdAsyncSignature,
timeout: 10000,
sleep: 1000,
async: true // note: this is needed so that tp knows to call with callback and wait
})
.then(function(value) {
// the value from the first success
})
.catch(function(error) {
// error.message === 'TIMEOUT'
});
tp({
action: aFunctionThatReturnsImmediately,
limit: 10,
sleep: 1000
})
.then(function(value) {
// the value from the first success
})
.catch(function(error) {
// error.message === 'LIMIT'
});
tp({
action: someFunctionThatReturnsAPromise,
until: function() { return Math.random() < 0.1 },
sleep: 1000
})
.then(function(value) {
// the value from the first success
})
.catch(function(error) {
// error.message === 'UNTIL'
});
Sometimes you want to start polling rapidly but slow down for subsequent calls.
So instead of using a Number value as the interval (or sleep), specify a function that returns a Number.
var interval = 10;
tp({
action: aFunctionWithStdAsyncSignature,
timeout: 600000, // 10 minutes
interval: function() { return interval *= 2; },
async: true // note: this is needed so that tp knows to call with callback and wait
})
.then(function(value) {
// the value from the first success
})
.catch(function(error) {
// error.message === 'TIMEOUT'
});
FAQs
A promise based trier
We found that trier-promise demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.