{"_id":"@bybrave/promise-retry2","_rev":"2-7cd760f11eaff374ea5e23d3e6164e10","name":"@bybrave/promise-retry2","dist-tags":{"latest":"3.0.1"},"versions":{"3.0.0":{"name":"@bybrave/promise-retry2","version":"3.0.0","keywords":["promise","retry","retries","backoff","exponential","repeat","esm","typescript"],"author":{"url":"https://github.com/bybraveHQ","name":"bybrave"},"license":"MIT","_id":"@bybrave/promise-retry2@3.0.0","maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"contributors":[{"url":"author of the original promise-retry","name":"IndigoUnited","email":"hello@indigounited.com"}],"homepage":"https://github.com/bybraveHQ/promise-retry2#readme","bugs":{"url":"https://github.com/bybraveHQ/promise-retry2/issues"},"dist":{"shasum":"259f3c0187200820a0d9ffd93e02f970202857d7","tarball":"https://registry.npmjs.org/@bybrave/promise-retry2/-/promise-retry2-3.0.0.tgz","fileCount":9,"integrity":"sha512-tUlFvcxOns10FosNOtVi32cOqh1Z2Q0hG6BDzodeqTOLO1ST4EeJYqKXcGQCHhC18nz5octEFWHUyFW9C1V1xA==","signatures":[{"sig":"MEQCIDXoqlPyhmmegy2YPNFfNZucA1w/ztE3FGV+RnaOYwI4AiBdkm5uv17mumvAyGg9idku/qr/rXChBIC9ZTbnvuHyXQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":26566},"main":"./dist/index.cjs","type":"module","types":"./index.d.ts","module":"./index.js","engines":{"node":">=18"},"exports":{".":{"types":"./index.d.ts","import":"./index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"funding":"https://ko-fi.com/bybrave","gitHead":"463318cead194b7509062abf632600972e84eb2f","scripts":{"test":"node --test test/*.test.js test/*.test.cjs","build":"node build/build.js","test-types":"tsc --strict --noEmit --moduleResolution bundler --target es2020 --lib es2020 --types node test/types.ts","prepublishOnly":"npm run build && npm test && npm run test-types"},"_npmUser":{"name":"bybrave","email":"opmybrave@gmail.com"},"repository":{"url":"git+https://github.com/bybraveHQ/promise-retry2.git","type":"git"},"_npmVersion":"10.8.2","description":"Maintained promise-retry fork: zero runtime dependencies, ESM + CommonJS, built-in TypeScript types, and the retry operation exposed for reset/stop. Drop-in for promise-retry.","directories":{},"sideEffects":false,"_nodeVersion":"20.19.6","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.24.0","typescript":"^5.6.0","@types/node":"^22.0.0"},"_npmOperationalInternal":{"tmp":"tmp/promise-retry2_3.0.0_1783273945881_0.6465765531973342","host":"s3://npm-registry-packages-npm-production"}},"3.0.1":{"name":"@bybrave/promise-retry2","version":"3.0.1","description":"Maintained promise-retry fork: zero runtime dependencies, ESM + CommonJS, built-in TypeScript types, and the retry operation exposed for reset/stop. Drop-in for promise-retry.","type":"module","main":"./dist/index.cjs","module":"./index.js","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"sideEffects":false,"scripts":{"build":"node build/build.js","test":"node --test test/*.test.js test/*.test.cjs","test-types":"tsc --strict --noEmit --moduleResolution bundler --target es2020 --lib es2020 --types node test/types.ts","prepublishOnly":"npm run build && npm test && npm run test-types"},"keywords":["promise","retry","retries","backoff","exponential","repeat","esm","typescript"],"author":{"name":"bybrave","url":"https://github.com/bybraveHQ"},"contributors":[{"name":"IndigoUnited","email":"hello@indigounited.com","url":"author of the original promise-retry"}],"license":"MIT","funding":"https://ko-fi.com/bybrave","repository":{"type":"git","url":"git+https://github.com/bybraveHQ/promise-retry2.git"},"bugs":{"url":"https://github.com/bybraveHQ/promise-retry2/issues"},"homepage":"https://github.com/bybraveHQ/promise-retry2#readme","engines":{"node":">=18"},"devDependencies":{"esbuild":"^0.24.0","typescript":"^5.6.0","@types/node":"^22.0.0"},"_id":"@bybrave/promise-retry2@3.0.1","gitHead":"8d2b70b9a4319664c7f0571ba0791ff3359b7549","_nodeVersion":"20.19.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-HPkFy3843YN67PQN1s07q+Hf2x0K8R3uWhSwWmbI3QehrAAALDdNJ57elVgL3AMuigy5TqOIvlebXk0DOL1aEg==","shasum":"400259b8bf91bc99e610da7512b91aab3309821f","tarball":"https://registry.npmjs.org/@bybrave/promise-retry2/-/promise-retry2-3.0.1.tgz","fileCount":9,"unpackedSize":26728,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDUowd1bRKr2Fy1yEwJWfC84HTtT2P/BoyDG6k4n6+X0QIhANHUj3UBq8AHC0Q7Qt8RoYEVKk41+mYriShT2SvZIGbi"}]},"_npmUser":{"name":"bybrave","email":"opmybrave@gmail.com"},"directories":{},"maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/promise-retry2_3.0.1_1783297260740_0.7655404083944475"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-05T17:52:25.680Z","modified":"2026-07-06T00:21:01.057Z","3.0.0":"2026-07-05T17:52:26.012Z","3.0.1":"2026-07-06T00:21:00.940Z"},"bugs":{"url":"https://github.com/bybraveHQ/promise-retry2/issues"},"author":{"name":"bybrave","url":"https://github.com/bybraveHQ"},"license":"MIT","homepage":"https://github.com/bybraveHQ/promise-retry2#readme","keywords":["promise","retry","retries","backoff","exponential","repeat","esm","typescript"],"repository":{"type":"git","url":"git+https://github.com/bybraveHQ/promise-retry2.git"},"description":"Maintained promise-retry fork: zero runtime dependencies, ESM + CommonJS, built-in TypeScript types, and the retry operation exposed for reset/stop. Drop-in for promise-retry.","contributors":[{"name":"IndigoUnited","email":"hello@indigounited.com","url":"author of the original promise-retry"}],"maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"readme":"# @bybrave/promise-retry2\n\nMaintained, drop-in fork of [`promise-retry`](https://github.com/IndigoUnited/node-promise-retry) — retries a function that returns a promise, with exponential backoff.\n\nThe original has had no release since 2020 (`2.0.1`) while still pulling ~188M downloads/month, with types living in a separate `@types/promise-retry` (~1.1M/month) and two runtime dependencies. This fork **bundles the TypeScript types**, drops to **zero runtime dependencies**, ships **ESM + CommonJS**, and **exposes the retry operation** so you can reset the backoff or stop pending retries. The API is unchanged.\n\n```sh\nnpm install @bybrave/promise-retry2\n```\n\n```js\nconst promiseRetry = require('@bybrave/promise-retry2'); // CommonJS\nimport promiseRetry from '@bybrave/promise-retry2';       // ESM\n```\n\n## Usage\n\n```js\npromiseRetry((retry, number) => {\n  return doSomething().catch(retry);\n}, {retries: 5});\n```\n\n`fn` is called with `(retry, attemptNumber, operation)`. Call `retry(err)` to trigger another attempt; it always throws, so returning/throwing it ends the current try. When the retries run out, the promise rejects with the last error. Options are the same as the underlying [`retry`](https://github.com/tim-kos/node-retry) module (`retries`, `factor`, `minTimeout`, `maxTimeout`, `randomize`, `forever`). The alternate `(options, fn)` argument order also works.\n\n## What's fixed\n\n| Issue | Problem | Fix |\n|---|---|---|\n| — | Types shipped separately as `@types/promise-retry`. | **Types are bundled** — no extra install. |\n| — | Two runtime dependencies (`retry`, `err-code`). | **Zero runtime dependencies** — both vendored in. |\n| — | CommonJS only, no `import`. | **Dual ESM + CommonJS** build. |\n| [#25](https://github.com/IndigoUnited/node-promise-retry/issues/25), [#32](https://github.com/IndigoUnited/node-promise-retry/issues/32) | No way to reset the backoff when a dependency recovers early, or to inspect/stop the operation. | The retry **`operation` is exposed as the third argument** — call `operation.reset()`, `operation.stop()`, or `operation.getTimeout()`. |\n| [#37](https://github.com/IndigoUnited/node-promise-retry/issues/37) | No CHANGELOG / release notes. | Releases are documented. |\n\n### Exposing the operation\n\n```js\npromiseRetry((retry, number, operation) => {\n  return call().catch((err) => {\n    // When the network is back, forget the accumulated backoff delay:\n    if (isBackOnline()) operation.reset();\n    retry(err);\n  });\n}, {retries: 10});\n```\n\n`operation.getTimeout()` returns the ms until the next scheduled attempt — handy for logging \"retrying in 16s\".\n\n## Notes on behavior (unchanged, by design)\n\n- **Memory with huge `retries`** ([#20](https://github.com/IndigoUnited/node-promise-retry/issues/20)): the underlying `retry` module precomputes a timeouts array of length `retries`, so memory grows O(retries). For effectively-infinite retries use `forever: true` (or a modest `retries` with a large `maxTimeout`) instead of a giant number.\n- **`retries: 0`** ([#8](https://github.com/IndigoUnited/node-promise-retry/issues/8)) means \"no retries\", not \"retry forever\" — use `forever: true` for that.\n- After calling `retry(err)`, don't throw again in the same tick without returning it — `return retry(err)` ([#14](https://github.com/IndigoUnited/node-promise-retry/issues/14)).\n\n## Migration from `promise-retry`\n\nReplace the dependency and the import, and remove `@types/promise-retry` from your devDependencies — the types are built in. Everything behaves the same, plus the fixes above.\n\n## Support\n\nIf this package saves you time, you can support maintenance:\n\n[![Ko-fi](https://img.shields.io/badge/Ko--fi-buy%20me%20a%20coffee-FF5E5B?logo=kofi&logoColor=white)](https://ko-fi.com/bybrave)\n[![Bitcoin](https://img.shields.io/badge/Bitcoin-BTC-F7931A?logo=bitcoin&logoColor=white)](#support)\n\nBitcoin (BTC): `bc1q37557q5jpeaxqydzwvf3jgj7zhnfpn2td3q40q`\n\n## Credits & license\n\nMIT, same as the original — see [LICENSE](./LICENSE).\nBased on [node-promise-retry](https://github.com/IndigoUnited/node-promise-retry) by IndigoUnited.\n","readmeFilename":"README.md"}