{"_id":"@airneyx/retry-kit","name":"@airneyx/retry-kit","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@airneyx/retry-kit","version":"0.1.0","description":"Zero-dependency async retry, exponential backoff, and timeout utilities for JavaScript & TypeScript.","keywords":["retry","backoff","exponential-backoff","timeout","async","promise","sleep","resilience"],"license":"MIT","author":{"name":"AirneyxTech"},"repository":{"type":"git","url":"git+https://github.com/AirneyxTech/retry-kit.git"},"homepage":"https://github.com/AirneyxTech/retry-kit#readme","bugs":{"url":"https://github.com/AirneyxTech/retry-kit/issues"},"main":"./src/index.js","module":"./src/index.mjs","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./src/index.mjs","require":"./src/index.js"},"./package.json":"./package.json"},"engines":{"node":">=14.8.0"},"sideEffects":false,"scripts":{"test":"node --test test/test.js"},"devDependencies":{},"gitHead":"c91575b79c2501d7437dffd03c37eb98a310986c","_id":"@airneyx/retry-kit@0.1.0","_nodeVersion":"24.13.1","_npmVersion":"11.8.0","dist":{"integrity":"sha512-EMwqn9S5WihmD5X7YuQ9uTiOIlbqHmvyndTenovnhEcaTpp+AS30XV70mww4VyZBCQPCnN+XYwwVntM0Ew4cgg==","shasum":"25dbb673f02d186d49bf9f42720ca9d08c33329c","tarball":"https://registry.npmjs.org/@airneyx/retry-kit/-/retry-kit-0.1.0.tgz","fileCount":6,"unpackedSize":10968,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHcCMWs2JRSkMIHYMWCqdyClQkt3TH8ggTpLoJWEVu3XAiAbN1uZLIMKBz+an6Wm7jKDMSgHQeHlfU7C6hsQFDSqSA=="}]},"_npmUser":{"name":"airneyx","email":"airneytech@gmail.com"},"directories":{},"maintainers":[{"name":"airneyx","email":"airneytech@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/retry-kit_0.1.0_1784248423337_0.2548298450289872"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-17T00:33:43.216Z","0.1.0":"2026-07-17T00:33:43.463Z","modified":"2026-07-17T00:33:43.691Z"},"maintainers":[{"name":"airneyx","email":"airneytech@gmail.com"}],"description":"Zero-dependency async retry, exponential backoff, and timeout utilities for JavaScript & TypeScript.","homepage":"https://github.com/AirneyxTech/retry-kit#readme","keywords":["retry","backoff","exponential-backoff","timeout","async","promise","sleep","resilience"],"repository":{"type":"git","url":"git+https://github.com/AirneyxTech/retry-kit.git"},"author":{"name":"AirneyxTech"},"bugs":{"url":"https://github.com/AirneyxTech/retry-kit/issues"},"license":"MIT","readme":"# retry-kit\n\nZero-dependency async retry, exponential backoff, and timeout utilities. Works in Node and the browser, CommonJS and ESM, with full TypeScript types included.\n\nNo dependencies. No bloat. ~150 lines of actual logic.\n\n## Install\n\n```bash\nnpm install retry-kit\n```\n\n## Quick start\n\n```js\nimport { retry, withTimeout, sleep } from 'retry-kit';\n// or: const { retry, withTimeout, sleep } = require('retry-kit');\n\n// Retry a flaky call with exponential backoff + jitter\nconst data = await retry(() => fetch('/api/data').then(r => r.json()), {\n  retries: 4,\n  minDelay: 200,\n  maxDelay: 5000\n});\n\n// Wrap any promise with a timeout\nconst result = await withTimeout(fetch('/api/slow'), 3000, 'API took too long');\n\n// Plain sleep, abortable\nawait sleep(1000);\n```\n\n## Combine retry + per-attempt timeout\n\n```js\nimport { retryWithTimeout } from 'retry-kit';\n\nconst data = await retryWithTimeout(\n  () => fetch('/api/data').then(r => r.json()),\n  { timeoutMs: 2000, retries: 3 }\n);\n```\n\n## API\n\n### `retry(fn, options?)`\nRetries `fn` (sync or async) with exponential backoff.\n\n| Option | Default | Description |\n|---|---|---|\n| `retries` | `3` | Retries after the first attempt |\n| `minDelay` | `200` | Base delay in ms |\n| `maxDelay` | `5000` | Cap on delay in ms |\n| `factor` | `2` | Exponential growth factor |\n| `jitter` | `true` | Randomize delay (full jitter) |\n| `onRetry` | – | `(error, attempt) => void`, called before each retry |\n| `retryIf` | – | `(error) => boolean` — return `false` to stop retrying immediately |\n| `signal` | – | `AbortSignal` to cancel retries/delays early |\n\n### `withTimeout(promiseOrFn, ms, message?)`\nRaces a promise (or promise-returning function) against a timeout. Rejects with `TimeoutError` if `ms` elapses first.\n\n### `sleep(ms, options?)`\nResolves after `ms`. Pass `{ signal }` to make it abortable (rejects with `AbortError`).\n\n### `retryWithTimeout(fn, options)`\nSame as `retry`, but wraps every individual attempt in `withTimeout`. Requires `options.timeoutMs`.\n\n### Errors\n`TimeoutError` and `AbortError` are exported so you can `instanceof` check them.\n\n## Why not [p-retry](https://www.npmjs.com/package/p-retry) / [async-retry](https://www.npmjs.com/package/async-retry)?\nThose are solid — this exists for people who want retry **and** timeout handling in one place, zero dependencies, and don't want to pull in a dependency tree for something this small.\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-3b31e3ce56b6e75e458c798b4859788e"}