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.
@4a/retry
Advanced tools
Readme
失败自动重试,可用于 http 请求重试,或其他需要重试的逻辑
npm i @4a/retry
// ES6
import { Retry } from '@4a/retry'
// Nodejs
const { Retry } = require('@4a/retry')
let i = 0
Retry.delay(300) // 可选调用 重试间隔300ms,默认300ms,单位ms
.max(10) // 可选调用 重试次数10,默认3次防止死循环
.when((result) => result !== 10) // 必须调用 重试条件,符合条件则重试,否则视为成功正常返回
.repeat(() => {
// 支持async函数,支持promise,返回Promise
i++
return i
})
.then((result) => {
console.log('result:', result)
})
.catch((err) => {
// 报错视为失败
// 最后一次重试如果依然报错,则抛出该错误
console.error('error:', err)
})
Simple
let i = 0
Retry.when((result) => result !== 10)
.repeat(() => {
i++
return i
})
.then((result) => {
console.log('result:', result)
})
.catch((err) => {
console.error('error:', err)
})
Axios Request
Retry.when((result) => result.data.code !== 0)
.repeat(() => axios(options))
.then((result) => {
console.log('result:', result)
})
.catch((err) => {
console.error('error:', err)
})
npm test
FAQs
失败自动重试,可用于 http 请求重试,或其他需要重试的逻辑
The npm package @4a/retry receives a total of 5 weekly downloads. As such, @4a/retry popularity was classified as not popular.
We found that @4a/retry demonstrated a healthy version release cadence and project activity because the last version was released less than 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.