Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
trier-promise
Advanced tools
Readme
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
The npm package trier-promise receives a total of 1,429 weekly downloads. As such, trier-promise popularity was classified as popular.
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.