{"_id":"@ambassify/backoff-strategies","_rev":"7-d131832ad10067c0e9b7e6b66bb37198","name":"@ambassify/backoff-strategies","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@ambassify/backoff-strategies","version":"1.0.0","keywords":["exponential backoff","backoff"],"author":{"name":"Ambassify","email":"dev@ambassify.com"},"license":"MIT","_id":"@ambassify/backoff-strategies@1.0.0","maintainers":[{"name":"ambassify","email":"dev@ambassify.com"}],"homepage":"https://github.com/ambassify/backoff-strategies#readme","bugs":{"url":"https://github.com/ambassify/backoff-strategies/issues"},"dist":{"shasum":"eac6a59951f1497740636c06462d906d729f43a5","tarball":"https://registry.npmjs.org/@ambassify/backoff-strategies/-/backoff-strategies-1.0.0.tgz","integrity":"sha512-0SWWkDcxT3OK4A8UTqCFp4gILNHu463U9lb+sQNO9HiqR0YuNYSS/Konu3Bpn4bHMeo3TraqYIeCi0RFPR2qkQ==","signatures":[{"sig":"MEUCIGZgb6smyB8I41jrmWv8jZhrarL3m1d0/JyC2MMds9YeAiEA1RHznoKZrFLtLV42lXMkCSPc8/ap9M4RqgDRiei5qPA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"src/index.js","_from":".","_shasum":"eac6a59951f1497740636c06462d906d729f43a5","engines":{"node":">= 6"},"gitHead":"d859c9be4349e72983c5051200b6dbca31479c9e","scripts":{"test":"npm -s run test:lint && npm -s run test:unit","release":"npm version patch && npm publish","test:lint":"eslint src","test:unit":"nyc mocha"},"_npmUser":{"name":"ambassify","email":"dev@ambassify.com"},"repository":{"url":"git+https://github.com/ambassify/backoff-strategies.git","type":"git"},"_npmVersion":"3.10.10","description":"Backoff strategies for retrying things like HTTP requests.","_nodeVersion":"6.10.0","devDependencies":{"nyc":"^10.1.2","mocha":"^3.2.0","eslint":"^3.12.2","eslint-config-ambassify":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/backoff-strategies-1.0.0.tgz_1489421629584_0.2589942794293165","host":"packages-18-east.internal.npmjs.com"},"directories":{}}},"time":{"created":"2017-03-13T16:13:50.463Z","modified":"2025-10-09T08:36:10.356Z","1.0.0":"2017-03-13T16:13:50.463Z"},"bugs":{"url":"https://github.com/ambassify/backoff-strategies/issues"},"author":{"name":"Ambassify","email":"dev@ambassify.com"},"license":"MIT","homepage":"https://github.com/ambassify/backoff-strategies#readme","keywords":["exponential backoff","backoff"],"repository":{"url":"git+https://github.com/ambassify/backoff-strategies.git","type":"git"},"description":"Backoff strategies for retrying things like HTTP requests.","maintainers":[{"email":"dev@ambassify.com","name":"ambassify-admin"},{"email":"jorgen@evens.eu","name":"jorgenevens"},{"email":"wim@sitebase.be","name":"sitebase"}],"readme":"# backoff-strategies\n\n[![CircleCI](https://circleci.com/gh/ambassify/backoff-strategies/tree/master.svg?style=svg)](https://circleci.com/gh/ambassify/backoff-strategies/tree/master)\n\nBackoff strategies for retrying things like HTTP requests.\n\n## Installation\n\n```shell\nnpm install --save @ambassify/backoff-strategies\n```\n\n\n### Usage\n\nStrategies are attached to the default import of this package and can be accessed using.\n\nEvery strategy will return a new function that accepts the amount of attempts that were previously executed as its only parameter and returns the matching delay.\n\n```javascript\nconst { exponential, linear } = require('@ambassify/backoff-strategies');\n\n// Usage:\nconst linearDelayGenerator = linear(50);\nlinearDelayGenerator(0); // 0\nlinearDelayGenerator(1); // 50\nlinearDelayGenerator(2); // 100\n```\n\n### Strategies\n\n**constant**\n\n`function constant(delay) {}`\n\n`f(x) = delay`\n\nAlways returns the same delay, no matter how many attempts are passed in.\n\n**linear**\n\n`function linear(delay) {}`\n\n`f(x) = x * delay`\n\nThe delay shows linear growth for every attempt.\n\n\n**exponential**\n\n`function exponential(delay, factor = 2) {}`\n\n`f(x) = (factor ^ (x - 1)) * delay` (exception: `f(0) = 0`)\n\nThe delay shows exponential growth by a specific factor\n\n**binary exponential**\n\n`function binaryExponential(delay) {}`\n\n`f(x) = random(0, ((2 ^ x) − 1)) * delay`\n\nThe delay shows binary exponential growth as explained [here](https://en.wikipedia.org/wiki/Exponential_backoff)\n\n## Contribute\n\nWe really appreciate any contribution you would like to make, so don't\nhesitate to report issues or submit pull requests.\n\n## License\n\nThis project is released under a MIT license.\n\n## About us\n\nIf you would like to know more about us, be sure to have a look at [our website](https://www.ambassify.com), or our Twitter accounts [Ambassify](https://twitter.com/Ambassify), [Sitebase](https://twitter.com/Sitebase), [JorgenEvens](https://twitter.com/JorgenEvens)\n","readmeFilename":"README.md"}