{"_id":"@gar/promise-retry","_rev":"4250242","name":"@gar/promise-retry","description":"Retries a function that returns a promise, leveraging the power of the retry module.","dist-tags":{"latest":"1.0.3"},"maintainers":[{"name":"gar","email":""},{"name":"nlf","email":""}],"time":{"modified":"2026-03-29T21:56:43.000Z","created":"2026-02-20T19:42:55.434Z","1.0.3":"2026-03-18T20:15:08.115Z","1.0.2":"2026-02-24T22:43:21.975Z","1.0.1":"2026-02-24T21:47:17.312Z","1.0.0":"2026-02-20T19:42:55.434Z"},"users":{},"repository":{"type":"git","url":"git://github.com/wraithgar/node-promise-retry.git"},"versions":{"1.0.3":{"name":"@gar/promise-retry","version":"1.0.3","description":"Retries a function that returns a promise, leveraging the power of the retry module.","main":"./lib/index.js","type":"commonjs","exports":{".":[{"default":"./lib/index.js","types":"./lib/index.d.ts"},"./lib/index.js"]},"scripts":{"lint":"npx standard","lint:fix":"npx standard --fix","test":"node --test --experimental-test-coverage --test-coverage-lines=100 --test-coverage-functions=100 --test-coverage-branches=100","typelint":"npx -p typescript tsc ./lib/index.d.ts","posttest":"npm run lint","postlint":"npm run typelint"},"bugs":{"url":"https://github.com/wraithgar/node-promise-retry/issues/"},"repository":{"type":"git","url":"git://github.com/wraithgar/node-promise-retry.git"},"keywords":["retry","promise","backoff","repeat","replay"],"license":"MIT","engines":{"node":"^20.17.0 || >=22.9.0"},"types":"./lib/index.d.ts","_id":"@gar/promise-retry@1.0.3","homepage":"https://github.com/wraithgar/node-promise-retry#readme","_nodeVersion":"24.14.0","_npmVersion":"11.11.1","dist":{"shasum":"65e726428e794bc4453948e0a41e6de4215ce8b0","size":5212,"noattachment":false,"key":"/@gar/promise-retry/-/@gar/promise-retry-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/@gar/promise-retry/download/@gar/promise-retry-1.0.3.tgz"},"_npmUser":{"name":"gar","email":"gar+npm@danger.computer"},"directories":{},"maintainers":[{"name":"gar","email":""},{"name":"nlf","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/promise-retry_1.0.3_1773864907974_0.47739020217311423"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-03-18T20:15:08.115Z","publish_time":1773864908115,"_source_registry_name":"default","_cnpm_publish_time":1773864908115},"1.0.2":{"name":"@gar/promise-retry","version":"1.0.2","description":"Retries a function that returns a promise, leveraging the power of the retry module.","main":"./lib/index.js","type":"commonjs","exports":{".":[{"default":"./lib/index.js","types":"./lib/index.d.ts"},"./lib/index.js"]},"scripts":{"lint":"npx standard","lint:fix":"npx standard --fix","test":"node --test --experimental-test-coverage --test-coverage-lines=100 --test-coverage-functions=100 --test-coverage-branches=100","typelint":"npx -p typescript tsc ./lib/index.d.ts","posttest":"npm run lint","postlint":"npm run typelint"},"bugs":{"url":"https://github.com/wraithgar/node-promise-retry/issues/"},"repository":{"type":"git","url":"git://github.com/wraithgar/node-promise-retry.git"},"keywords":["retry","promise","backoff","repeat","replay"],"license":"MIT","dependencies":{"retry":"^0.13.1"},"engines":{"node":"^20.17.0 || >=22.9.0"},"types":"./lib/index.d.ts","_id":"@gar/promise-retry@1.0.2","homepage":"https://github.com/wraithgar/node-promise-retry#readme","_nodeVersion":"24.13.1","_npmVersion":"11.10.1","dist":{"shasum":"90d01966a7fcb270ce6fb4211405ab828ae6e036","size":4080,"noattachment":false,"key":"/@gar/promise-retry/-/@gar/promise-retry-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@gar/promise-retry/download/@gar/promise-retry-1.0.2.tgz"},"_npmUser":{"name":"gar","email":"gar+npm@danger.computer"},"directories":{},"maintainers":[{"name":"gar","email":""},{"name":"nlf","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/promise-retry_1.0.2_1771973001815_0.45823461713174596"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-02-24T22:43:21.975Z","publish_time":1771973001975,"_source_registry_name":"default","_cnpm_publish_time":1771973001975},"1.0.1":{"name":"@gar/promise-retry","version":"1.0.1","description":"Retries a function that returns a promise, leveraging the power of the retry module.","main":"./lib/index.js","type":"commonjs","exports":{".":[{"default":"./lib/index.js","types":"./lib/index.d.ts"},"./lib/index.js"]},"scripts":{"lint":"npx standard","lint:fix":"npx standard --fix","test":"node --test --experimental-test-coverage --test-coverage-lines=100 --test-coverage-functions=100 --test-coverage-branches=100","typelint":"npx -p typescript tsc ./lib/index.d.ts","posttest":"npm run lint","postlint":"npm run typelint"},"bugs":{"url":"https://github.com/wraithgar/node-promise-retry/issues/"},"repository":{"type":"git","url":"git://github.com/wraithgar/node-promise-retry.git"},"keywords":["retry","promise","backoff","repeat","replay"],"license":"MIT","dependencies":{"retry":"^0.13.1"},"engines":{"node":"^20.17.0 || >=22.9.0"},"types":"./lib/index.d.ts","_id":"@gar/promise-retry@1.0.1","homepage":"https://github.com/wraithgar/node-promise-retry#readme","_nodeVersion":"24.13.1","_npmVersion":"11.10.1","dist":{"shasum":"3060c1f1fee81be15e988cfa45570e0067e910c5","size":4091,"noattachment":false,"key":"/@gar/promise-retry/-/@gar/promise-retry-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@gar/promise-retry/download/@gar/promise-retry-1.0.1.tgz"},"_npmUser":{"name":"gar","email":"gar+npm@danger.computer"},"directories":{},"maintainers":[{"name":"gar","email":""},{"name":"nlf","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/promise-retry_1.0.1_1771969637153_0.7938281225008359"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-02-24T21:47:17.312Z","publish_time":1771969637312,"_source_registry_name":"default","_cnpm_publish_time":1771969637312},"1.0.0":{"name":"@gar/promise-retry","version":"1.0.0","keywords":["retry","promise","backoff","repeat","replay"],"license":"MIT","_id":"@gar/promise-retry@1.0.0","maintainers":[{"name":"gar","email":""},{"name":"nlf","email":""}],"homepage":"https://github.com/wraithgar/node-promise-retry#readme","bugs":{"url":"https://github.com/wraithgar/node-promise-retry/issues/"},"dist":{"shasum":"ffb174c7f248f3a8fcca881497395014021c5fed","size":2504,"noattachment":false,"key":"/@gar/promise-retry/-/@gar/promise-retry-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@gar/promise-retry/download/@gar/promise-retry-1.0.0.tgz"},"main":"./lib/index.js","type":"commonjs","engines":{"node":"^20.17.0 || >=22.9.0"},"exports":{".":[{"default":"./lib/index.js"},"./lib/index.js"]},"scripts":{"lint":"npx standard","test":"node --test --experimental-test-coverage --test-coverage-lines=100 --test-coverage-functions=100 --test-coverage-branches=100","lint:fix":"npx standard --fix","posttest":"npm run lint"},"_npmUser":{"name":"gar","email":"gar+npm@danger.computer"},"repository":{"url":"git://github.com/wraithgar/node-promise-retry.git","type":"git"},"_npmVersion":"11.10.0","description":"Retries a function that returns a promise, leveraging the power of the retry module.","directories":{},"_nodeVersion":"24.13.1","dependencies":{"retry":"^0.13.1"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/promise-retry_1.0.0_1771616575293_0.6759551072635421","host":"s3://npm-registry-packages-npm-production"},"_cnpmcore_publish_time":"2026-02-20T19:42:55.434Z","publish_time":1771616575434,"_source_registry_name":"default","_cnpm_publish_time":1771616575434}},"readme":"# @gar/promise-retry\n\nThis is a fork of [promise-retry](https://npm.im/promise-retry). See the [CHANGELOG.md](./CHANGELOG.md) for more info.\nIt also inlines and updates the original [retry](https://github.com/tim-kos/node-retry) package that was being promisified.\n\nRetries a function that returns a promise, leveraging the power of the [retry](https://github.com/tim-kos/node-retry) module to the promises world.\n\nThere's already some modules that are able to retry functions that return promises but they were rather difficult to use or do not offer an easy way to do conditional retries.\n\n\n## Installation\n\n`$ npm install promise-retry`\n\n\n## Usage\n\n### retry(fn(retry, number, operation), [options])\n\nCalls `fn` until the returned promise ends up fulfilled or rejected with an error different than a `retry` error.\nThe `options` argument is an object which maps to the original [retry](https://github.com/tim-kos/node-retry) module options:\n\n- `retries`: The maximum amount of times to retry the operation. Default is `10`.\n- `factor`: The exponential factor to use. Default is `2`.\n- `minTimeout`: The number of milliseconds before starting the first retry. Default is `1000`.\n- `maxTimeout`: The maximum number of milliseconds between two retries. Default is `Infinity`.\n- `randomize`: Randomizes the timeouts by multiplying with a factor between `1` to `2`. Default is `false`.\n- `forever`: Whether to retry forver, default is false.\n- `unref`: Whether to [unref](https://nodejs.org/api/timers.html#timers_unref) the underlying `setTimeout`s.\n- `maxRetryTime`: Maximum number of milliseconds that the retried operation is allowed to run.\n\n`options` can also be a Number, which is effectively the same as pasing `{ retries: Number }`\n\n\nThe `fn` function will be called with the following parameters:\n - A `retry` function as its first argument that should be called with an error whenever you want to retry `fn`. The `retry` function will always throw an error.\n - The current retry number being attempted\n - The retry operation object itself from which will allow you to call things like `operation.reset()`\n\nIf there are retries left, it will throw a special `retry` error that will be handled internally to call `fn` again.\nIf there are no retries left, it will throw the actual error passed to it.\n\n## Example\n```js\nconst { retry } = require('@gar/promise-retry');\n\n// Simple example\nretry(function (retry, number) {\n    console.log('attempt number', number);\n\n    return doSomething()\n    .catch(retry);\n})\n.then(function (value) {\n    // ..\n}, function (err) {\n    // ..\n});\n\n// Conditional example\nretry(function (retry, number) {\n    console.log('attempt number', number);\n\n    return doSomething()\n    .catch(function (err) {\n        if (err.code === 'ETIMEDOUT') {\n            retry(err);\n        }\n\n        throw err;\n    });\n})\n.then(function (value) {\n    // ..\n}, function (err) {\n    // ..\n});\n```\n\n## Tests\n\n`$ npm test`\n\n## License\n\nReleased under the [MIT License](http://www.opensource.org/licenses/mit-license.php).\n","_attachments":{},"homepage":"https://github.com/wraithgar/node-promise-retry#readme","bugs":{"url":"https://github.com/wraithgar/node-promise-retry/issues/"},"license":"MIT"}