{"_id":"@antoniovdlc/with-retry","name":"@antoniovdlc/with-retry","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@antoniovdlc/with-retry","version":"1.0.0","description":"Retry asynchronous operations","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"scripts":{"prepare":"husky","type:check":"tsc --noEmit --project tsconfig.json","format":"prettier --write --ignore-unknown {src,test}/*","format:check":"prettier --check {src,test}/*","lint":"eslint {src,test}/*","lint:fix":"eslint --fix {src,test}/*","pre-commit":"lint-staged","test":"vitest run --coverage","build":"npm run build:lib && npm run build:types","build:lib":"vite build","build:types":"tsc --declaration --emitDeclarationOnly && cp dist/index.d.ts dist/index.d.mts && cp dist/config.d.ts dist/config.d.mts","postversion":"git push && git push --tags"},"lint-staged":{"*.ts":["npm run format","npm run type:check","npm run lint:fix"]},"repository":{"type":"git","url":"git+https://github.com/AntonioVdlC/with-retry.git"},"keywords":["retry","async"],"author":{"name":"Antonio Villagra De La Cruz"},"license":"MIT","bugs":{"url":"https://github.com/AntonioVdlC/with-retry/issues"},"homepage":"https://github.com/AntonioVdlC/with-retry#readme","devDependencies":{"@eslint/js":"^9.18.0","@vitest/coverage-v8":"^2.1.8","eslint":"^9.18.0","eslint-config-prettier":"^9.1.0","husky":"^9.1.7","lint-staged":"^15.3.0","prettier":"^3.4.2","typescript":"^5.7.3","typescript-eslint":"^8.19.1","vite":"^5.4.11","vitest":"^2.1.8"},"_id":"@antoniovdlc/with-retry@1.0.0","gitHead":"f8322e5950a8aa92ccfe765b2212462604af7575","_nodeVersion":"18.20.5","_npmVersion":"10.8.2","dist":{"integrity":"sha512-7+QI1UvtJc7h4Z9FMTlOoVZnO9MpFE07XMrfJnKCJomJXt8HHC2ZZJpNIzXL2zOaIvEbNvKdNKCi1Z/LS6ylKA==","shasum":"7628c784c0e2c0d5cc64e0e40666229beaff209e","tarball":"https://registry.npmjs.org/@antoniovdlc/with-retry/-/with-retry-1.0.0.tgz","fileCount":11,"unpackedSize":11418,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBWTnnd8CJ66AEZu3LBRLW995bVXgeAxkHpfpNFnEEGNAiEA2utG0nVtcNsVEQYgpcy1O1+frMM/b2G+KJp3AmbNgXk="}]},"_npmUser":{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"},"directories":{},"maintainers":[{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/with-retry_1.0.0_1737900295596_0.022413772376129293"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-26T14:04:55.464Z","1.0.0":"2025-01-26T14:04:55.754Z","modified":"2025-01-26T14:04:56.060Z"},"maintainers":[{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"}],"description":"Retry asynchronous operations","homepage":"https://github.com/AntonioVdlC/with-retry#readme","keywords":["retry","async"],"repository":{"type":"git","url":"git+https://github.com/AntonioVdlC/with-retry.git"},"author":{"name":"Antonio Villagra De La Cruz"},"bugs":{"url":"https://github.com/AntonioVdlC/with-retry/issues"},"license":"MIT","readme":"# with-retry\n\n[![version](https://img.shields.io/npm/v/@antoniovdlc/with-retry.svg)](https://npm.im/@antoniovdlc/with-retry)\n[![issues](https://img.shields.io/github/issues-raw/antoniovdlc/@antoniovdlc/with-retry.svg)](https://github.com/AntonioVdlC/with-retry/issues)\n[![downloads](https://img.shields.io/npm/dt/@antoniovdlc/with-retry.svg)](https://npm.im/@antoniovdlc/with-retry)\n[![license](https://img.shields.io/npm/l/@antoniovdlc/with-retry.svg)](https://opensource.org/licenses/MIT)\n\nRetry asynchronous operations\n\n## Installation\n\nThis package is distributed via npm:\n\n```\nnpm install @antoniovdlc/with-retry\n```\n\n## Usage\n\nYou can use this library either as an ES module or a CommonJS package:\n\n```js\nimport withRetry from \"@antoniovdlc/with-retry\";\n```\n\n_- or -_\n\n```js\nconst withRetry = require(\"@antoniovdlc/with-retry\");\n```\n\nYou can then wrap any asynchronous function with `withRetry` and pass configuration options:\n\n```js\nasync function fn() { ... }\n\nconst result = await withRetry(fn, { ... });\n```\n\n## Configuration\n\nThe configuration options are:\n\n```ts\ntype RetryConfig = {\n  maxAttempts: number;\n  delay: number;\n  maxDelay: number;\n  backoffStrategy: RetryConfigBackoffStrategy;\n  jitter: RetryConfigJitter;\n  retryCondition: (error: Error) => boolean;\n  onRetry: (error: Error, attempt: number) => void;\n  onExhausted: (error: Error) => void;\n  timeout: number;\n};\n```\n\nDefault values are set to:\n\n```js\n{\n  maxAttempts: 3,\n  delay: 100,\n  maxDelay: 1000,\n  backoffStrategy: \"constant\",\n  jitter: true,\n  retryCondition: () => true,\n  onRetry: () => {},\n  onExhausted: () => {},\n  timeout: 0,\n}\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}