{"name":"exponential-backoff","version":"3.1.3","keywords":["exponential","backoff","retry"],"author":{"name":"Sami Sayegh"},"license":"Apache-2.0","_id":"exponential-backoff@3.1.3","maintainers":[{"name":"aboissinot","email":"aboissinot@coveo.com"},{"name":"coveo-organization","email":"sandbox_JSUI@coveo.com"},{"name":"coveoit","email":"itaccounts@coveo.com"},{"name":"olamothe","email":"olamothe@coveo.com"},{"name":"sssayegh","email":"ssayegh@coveo.com"},{"name":"ylakhdar","email":"ylakhdar@coveo.com"},{"name":"ndlr","email":"ndlabarre@coveo.com"},{"name":"npmcoveo","email":"npmcoveo@coveo.com"},{"name":"pixhel","email":"lbompart@coveo.com"},{"name":"mmitiche","email":"mmitiche@coveo.com"},{"name":"nlegros","email":"nlegros@coveo.com"},{"name":"sallain","email":"sallain@coveo.com"},{"name":"msrioux","email":"msrioux@coveo.com"},{"name":"talao-coveo","email":"talao@coveo.com"},{"name":"oa-npmcoveo","email":"oa-npmcoveo@oacvo.com"}],"homepage":"https://github.com/coveooss/exponential-backoff#readme","bugs":{"url":"https://github.com/coveooss/exponential-backoff/issues"},"dist":{"shasum":"51cf92c1c0493c766053f9d3abee4434c244d2f6","tarball":"http://registry-npm.ywwl.com/exponential-backoff/download/exponential-backoff-3.1.3.tgz","fileCount":47,"integrity":"sha512-ZgEeZXj30q+I0EN+CbSSpIyPaJ5HVQD18Z1m+u1FXbAeT94mr1zw50q4q6jiiC447Nl/YTcIYSAftiGqetwXCA==","signatures":[{"sig":"MEUCIGlZUN4/E+mDno0FIRedAEDXF+iqFtmgLHjKSsO6VynJAiEAglIqH945AsbNiGEUU8MzzNZbdjLAKZKe4vLdahiuT84=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/exponential-backoff@3.1.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":55183,"size":15151,"noattachment":false,"key":"/exponential-backoff/-/exponential-backoff-3.1.3.tgz"},"jest":{"testRegex":"\\.spec\\.ts$","transform":{"^.+\\.ts$":"ts-jest"},"moduleFileExtensions":["ts","js"]},"main":"dist/backoff.js","husky":{"hooks":{"pre-commit":"lint-staged"}},"types":"dist/backoff.d.ts","gitHead":"5622170828bd91dc149585bfa3d82c8972a75ac5","scripts":{"test":"jest","build":"tsc","test:watch":"jest --watch"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:147ba6a6-2138-4282-911a-04e808e82b5a"}},"repository":{"url":"git+https://github.com/coveooss/exponential-backoff.git","type":"git"},"_npmVersion":"11.6.0","description":"A utility that allows retrying a function with an exponential delay between attempts.","directories":{},"lint-staged":{"*.{ts,json,md}":["prettier --write","git add"]},"_nodeVersion":"24.9.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^24.9.0","husky":"^3.0.9","ts-jest":"^24.1.0","prettier":"^1.18.2","typescript":"^3.6.4","@types/jest":"^24.0.18","@types/node":"^10.14.21","lint-staged":"^9.4.2"},"_npmOperationalInternal":{"tmp":"tmp/exponential-backoff_3.1.3_1760137807638_0.44791647196804507","host":"s3://npm-registry-packages-npm-production"},"readme":"# exponential-backoff\n\nA utility that allows retrying a function with an exponential delay between attempts.\n\n## Installation\n\n```\nnpm i exponential-backoff\n```\n\n## Usage\n\nThe `backOff<T>` function takes a promise-returning function to retry, and an optional `BackOffOptions` object. It returns a `Promise<T>`.\n\n```ts\nfunction backOff<T>(\n  request: () => Promise<T>,\n  options?: BackOffOptions\n): Promise<T>;\n```\n\nHere is an example retrying a function that calls a hypothetical weather endpoint:\n\n```js\nimport { backOff } from \"exponential-backoff\";\n\nfunction getWeather() {\n  return fetch(\"weather-endpoint\");\n}\n\nasync function main() {\n  try {\n    const response = await backOff(() => getWeather());\n    // process response\n  } catch (e) {\n    // handle error\n  }\n}\n\nmain();\n```\n\nMigrating across major versions? Here are our [breaking changes](https://github.com/coveo/exponential-backoff/tree/master/doc/migration-guide.md).\n\n### `BackOffOptions`\n\n- `delayFirstAttempt?: boolean`\n\n  Decides whether the `startingDelay` should be applied before the first call. If `false`, the first call will occur without a delay.\n\n  Default value is `false`.\n\n- `jitter?: JitterType | string`\n\n  Decides whether a [jitter](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/) should be applied to the delay. Possible values are `full` and `none`.\n\n  Default value is `none`.\n\n- `maxDelay?: number`\n\n  The maximum delay, in milliseconds, between two consecutive attempts.\n\n  Default value is `Infinity`.\n\n- `numOfAttempts?: number`\n\n  The maximum number of times to attempt the function.\n\n  Default value is `10`.\n\n  Minimum value is `1`.\n\n- `retry?: (e: any, attemptNumber: number) => boolean | Promise<boolean>`\n\n  The `retry` function can be used to run logic after every failed attempt (e.g. logging a message, assessing the last error, etc.). It is called with the last error and the upcoming attempt number. Returning `true` will retry the function as long as the `numOfAttempts` has not been exceeded. Returning `false` will end the execution.\n\n  Default value is a function that always returns `true`.\n\n- `startingDelay?: number`\n\n  The delay, in milliseconds, before executing the function for the first time.\n\n  Default value is `100` ms.\n\n- `timeMultiple?: number`\n\n  The `startingDelay` is multiplied by the `timeMultiple` to increase the delay between reattempts.\n\n  Default value is `2`.\n","publish_time":1760137807816,"_cnpm_publish_time":1760137807816,"dist-tags":{"latest":"3.1.3"}}