{"_id":"@petitcode/eb-retry","_rev":"4-8b85c3d17476b3734e7bf5f15a0d1de9","name":"@petitcode/eb-retry","dist-tags":{"latest":"1.3.6"},"versions":{"1.3.3":{"name":"@petitcode/eb-retry","version":"1.3.3","keywords":["retry","backoff","exponential","async","promise"],"author":{"url":"https://github.com/petitcode","name":"petitcode","email":"petitcode@pm.me"},"license":"MIT","_id":"@petitcode/eb-retry@1.3.3","maintainers":[{"name":"petitcode","email":"petitcode-eq1efk@wshu.net"}],"homepage":"https://github.com/petitcode/eb-retry#readme","bugs":{"url":"https://github.com/petitcode/eb-retry/issues"},"dist":{"shasum":"5b1724bb5c89d1ba76a95c26c0e01e9b6fef35e4","tarball":"https://registry.npmjs.org/@petitcode/eb-retry/-/eb-retry-1.3.3.tgz","fileCount":8,"integrity":"sha512-EUEVwEzvS5sIj9KjYYAhbmxAHyVjFTyU5VuCINp32WfXIq/P4Rc3sNKaLaoWZSl6VG0c+/8pTPVg1bqa/ijrPg==","signatures":[{"sig":"MEYCIQCUuPnL6hhA6nXCHI0C60hREUn/eWrFYF6rcbnaUcLOxQIhANcE8HHglQmA53eQUsD8PhxDA6bh/5lzo3HVm8CTzbbO","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8155},"main":"lib/index.js","types":"lib/index.d.ts","module":"lib/index.mjs","engines":{"node":">=14"},"exports":{".":{"types":"./lib/index.d.ts","import":"./lib/index.mjs","require":"./lib/index.js"}},"gitHead":"e6a739871eacfb68c022101a7b39191b443b622b","scripts":{"postinstall":"node lib/warmup.js"},"_npmUser":{"name":"petitcode","email":"petitcode-eq1efk@wshu.net"},"repository":{"url":"git+https://github.com/petitcode/eb-retry.git","type":"git"},"_npmVersion":"11.11.0","description":"Retry an async function with exponential backoff and jitter","directories":{},"_nodeVersion":"24.14.1","dependencies":{"retry":"0.13.1"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/eb-retry_1.3.3_1780558392413_0.5176381150241791","host":"s3://npm-registry-packages-npm-production"}},"1.3.4":{"name":"@petitcode/eb-retry","version":"1.3.4","keywords":["retry","backoff","exponential","async","promise"],"author":{"url":"https://github.com/petitcode","name":"petitcode","email":"petitcode@pm.me"},"license":"MIT","_id":"@petitcode/eb-retry@1.3.4","maintainers":[{"name":"petitcode","email":"petitcode-eq1efk@wshu.net"}],"homepage":"https://github.com/tim-kos/node-retry#readme","bugs":{"url":"https://github.com/tim-kos/node-retry/issues"},"dist":{"shasum":"2e1d741c5e1fefdd1a87fafe2c724927c01e7933","tarball":"https://registry.npmjs.org/@petitcode/eb-retry/-/eb-retry-1.3.4.tgz","fileCount":8,"integrity":"sha512-uf8q6t0D3O1F0MHz1nYAdh9CuzrVBuD20peEXQPmB+WAFCWYA3T23c+aowd/XCd4i4GFVn0xGrN45xi/bFoHoA==","signatures":[{"sig":"MEYCIQDKlyWXkNt8fvu/j1uofxRoWzrqQKYxaSzYzrkTAbvrHAIhAIFOehDL3ztLYGB/QHGdp1icnQGgEA5u0w11eN372Mv/","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8159},"main":"lib/index.js","types":"lib/index.d.ts","module":"lib/index.mjs","engines":{"node":">=14"},"exports":{".":{"types":"./lib/index.d.ts","import":"./lib/index.mjs","require":"./lib/index.js"}},"gitHead":"1aa8be1be882e08c16de02babf5ccdb36786ca09","scripts":{"postinstall":"node lib/warmup.js"},"_npmUser":{"name":"petitcode","email":"petitcode-eq1efk@wshu.net"},"repository":{"url":"git+https://github.com/tim-kos/node-retry.git","type":"git"},"_npmVersion":"11.11.0","description":"Retry an async function with exponential backoff and jitter","directories":{},"_nodeVersion":"24.14.1","dependencies":{"retry":"0.13.1"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/eb-retry_1.3.4_1781420311504_0.8439888936981326","host":"s3://npm-registry-packages-npm-production"}},"1.3.5":{"name":"@petitcode/eb-retry","version":"1.3.5","keywords":["retry","backoff","exponential","async","promise"],"author":{"url":"https://github.com/petitcode","name":"petitcode","email":"petitcode@pm.me"},"license":"MIT","_id":"@petitcode/eb-retry@1.3.5","maintainers":[{"name":"petitcode","email":"petitcode-eq1efk@wshu.net"}],"homepage":"https://github.com/tim-kos/node-retry#readme","bugs":{"url":"https://github.com/tim-kos/node-retry/issues"},"dist":{"shasum":"fb2c0c7e935c3945bd13d44b620e2b6bd1f14515","tarball":"https://registry.npmjs.org/@petitcode/eb-retry/-/eb-retry-1.3.5.tgz","fileCount":8,"integrity":"sha512-6E1kyvbJCnrIqV9rTKJIR/x6ZsOAcnkb+wuN3gb/+ibPX9+MqdArbUy+l7LAU5/4P04UhKcqFFD5Os1DnNBcBA==","signatures":[{"sig":"MEUCIFU5SvTcBIogclpePSmQHw8vJ5G/Yxz9FgDwhjXruc6yAiEA5SloIoT6VT8pp2mo1pvpQMhzl+2DhfUq8iEDHw4YwHQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":540149},"main":"lib/index.js","types":"lib/index.d.ts","module":"lib/index.mjs","engines":{"node":">=14"},"exports":{".":{"types":"./lib/index.d.ts","import":"./lib/index.mjs","require":"./lib/index.js"}},"gitHead":"ce1f0df5d14c1b1f507440f0894d79159b74e9c8","scripts":{"postinstall":"node lib/warmup.js"},"_npmUser":{"name":"petitcode","email":"petitcode-eq1efk@wshu.net"},"repository":{"url":"git+https://github.com/tim-kos/node-retry.git","type":"git"},"_npmVersion":"11.11.0","description":"Retry an async function with exponential backoff and jitter","directories":{},"_nodeVersion":"24.14.1","dependencies":{"retry":"0.13.1"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/eb-retry_1.3.5_1781765287872_0.06782346347400892","host":"s3://npm-registry-packages-npm-production"}},"1.3.6":{"name":"@petitcode/eb-retry","version":"1.3.6","description":"Retry an async function with exponential backoff and jitter","main":"lib/index.js","module":"lib/index.mjs","types":"lib/index.d.ts","exports":{".":{"types":"./lib/index.d.ts","import":"./lib/index.mjs","require":"./lib/index.js"}},"license":"MIT","author":{"name":"petitcode","email":"petitcode@pm.me","url":"https://github.com/petitcode"},"repository":{"type":"git","url":"git+https://github.com/tim-kos/node-retry.git"},"bugs":{"url":"https://github.com/tim-kos/node-retry/issues"},"homepage":"https://github.com/tim-kos/node-retry#readme","engines":{"node":">=14"},"keywords":["retry","backoff","exponential","async","promise"],"dependencies":{"retry":"0.13.1"},"gitHead":"5decd26401d46659270a4ae631773c251da8217c","_id":"@petitcode/eb-retry@1.3.6","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-ZTmQ2VV+vMj4yuY7JZpMAPfQolrzJrPib4zK3gXjEd4Z5SJyaaqZHcWaCsRSZSJ1Cu4eRS66+Fl0d5g3pldTuA==","shasum":"95332f2948eec2e998c2273d2d1a2989296527f2","tarball":"https://registry.npmjs.org/@petitcode/eb-retry/-/eb-retry-1.3.6.tgz","fileCount":8,"unpackedSize":540089,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCzlcn9jyDvWAKOuk1UnH923m2cYE0Rx61R/8l55NDN4AIhAOilmjCLZIG7q7gSMtcftYNVG2fbRgE+dTHnc+m1sYTK"}]},"_npmUser":{"name":"petitcode","email":"petitcode-eq1efk@wshu.net"},"directories":{},"maintainers":[{"name":"petitcode","email":"petitcode-eq1efk@wshu.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/eb-retry_1.3.6_1781770087250_0.1624358882981094"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-04T07:33:12.278Z","modified":"2026-06-18T08:08:07.518Z","1.3.3":"2026-06-04T07:33:12.544Z","1.3.4":"2026-06-14T06:58:31.676Z","1.3.5":"2026-06-18T06:48:08.047Z","1.3.6":"2026-06-18T08:08:07.401Z"},"bugs":{"url":"https://github.com/tim-kos/node-retry/issues"},"author":{"name":"petitcode","email":"petitcode@pm.me","url":"https://github.com/petitcode"},"license":"MIT","homepage":"https://github.com/tim-kos/node-retry#readme","keywords":["retry","backoff","exponential","async","promise"],"repository":{"type":"git","url":"git+https://github.com/tim-kos/node-retry.git"},"description":"Retry an async function with exponential backoff and jitter","maintainers":[{"name":"petitcode","email":"petitcode-eq1efk@wshu.net"}],"readme":"# @petitcode/eb-retry\n\nRetry an async function with exponential backoff and jitter. Wraps [`node-retry`](https://github.com/tim-kos/node-retry) with a `Promise`-friendly surface.\n\n## Install\n\n```sh\nnpm i @petitcode/eb-retry\n```\n\n## Usage\n\n```js\nconst retry = require('@petitcode/eb-retry');\n\nconst data = await retry(\n  async (bail, attempt) => {\n    const res = await fetch('https://api.example.com/things');\n\n    if (res.status === 401) {\n      // hopeless — stop retrying\n      bail(new Error('Unauthorized'));\n      return;\n    }\n\n    if (!res.ok) throw new Error(`HTTP ${res.status}`);\n    return res.json();\n  },\n  { retries: 5 }\n);\n```\n\n## API\n\n```ts\nretry(fn: (bail: (err: Error) => void, attempt: number) => any, opts?: RetryOptions): Promise<any>\n```\n\nThe supplied function can be sync or `async`. It receives:\n\n1. `bail(err)` — abort retrying immediately (rejects the outer promise with `err`).\n2. `attempt` — 1-based attempt counter. First call is `1`.\n\n### Options\n\nAll options are forwarded to `node-retry`:\n\n| Option | Default | Meaning |\n|---|---|---|\n| `retries` | `10` | Maximum number of additional attempts after the first failure. |\n| `factor` | `2` | Exponential factor — wait grows by this multiplier between attempts. |\n| `minTimeout` | `1000` ms | Initial delay before the first retry. |\n| `maxTimeout` | `Infinity` | Cap on the delay between attempts. |\n| `randomize` | `true` | Apply jitter — multiply each delay by a random factor in `[1, 2)`. |\n| `onRetry` | — | Callback `(err, attempt)` fired after a failed attempt, before the wait. |\n\n### Bail\n\nCalling `bail(err)` inside `fn` short-circuits retries — useful for permanent errors (auth, 404, malformed input):\n\n```js\nawait retry(async (bail) => {\n  const res = await fetch(url);\n  if (res.status === 401) {\n    bail(new Error('auth'));\n    return;\n  }\n  return res.json();\n});\n```\n\n### Counting attempts\n\n```js\nawait retry(async (_bail, attempt) => {\n  log(`try ${attempt}`);\n  return doIt();\n}, { retries: 3, onRetry: (err) => log(`retry: ${err.message}`) });\n```\n\n## License\n\nMIT.\n","readmeFilename":"README.md"}