{"_id":"@codeo/eventually","_rev":"4-3fa05c345d02a070adc935e3dbb37f7a","name":"@codeo/eventually","dist-tags":{"latest":"1.2.0"},"versions":{"1.0.0":{"name":"@codeo/eventually","version":"1.0.0","description":"Retry async operations with back-off, handle errors by halting, suppressing or failing","main":"index.js","scripts":{"test":"jest","clean-dist":"rimraf dist","generate-index":"node generate-index.js","prebuild":"run-p clean-dist generate-index","build":"tsc","lint":"tslint -p .","pretest":"rimraf .jest-cache","zarro":"zarro","prerelease":"run-s build lint test","release":"cross-env VERSION_INCREMENT_STRATEGY=minor run-s \"zarro release-npm\"","prerelease-beta":"run-s build lint test","release-beta":"cross-env BETA=1 VERSION_INCREMENT_STRATEGY=patch run-s \"zarro release-npm\""},"keywords":[],"author":{"name":"Davyd McColl","email":"davydm@gmail.com"},"license":"BSD-3-Clause","devDependencies":{"@types/faker":"^5.1.4","@types/jest":"^26.0.15","cross-env":"^7.0.2","expect-even-more-jest":"^1.11.0","faker":"^5.1.0","jest":"^26.6.2","npm-run-all":"^4.1.5","rimraf":"^3.0.2","ts-jest":"^26.4.3","tslint":"^6.1.3","typescript":"^4.0.5","yafs":"^1.7.0","zarro":"^1.79.0"},"gitHead":"4b9c4538848443ae45727f49b2828639dd5bd3c3","_id":"@codeo/eventually@1.0.0","_nodeVersion":"12.18.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-rV3PXUjDA+N7K9HBa+7S4x0YOYJ2tB5ygE/O4kCN+rTv+jV3zbv4i1KMPelH3ZiVkSKhxLMnpaY2m0kHujK5kA==","shasum":"6c779cbb74752c2bdb320186a61721ca37e76a4c","tarball":"https://registry.npmjs.org/@codeo/eventually/-/eventually-1.0.0.tgz","fileCount":9,"unpackedSize":7183,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfoBz6CRA9TVsSAnZWagAADtYQAIJruMvGk7hynMi4fncW\nePJdFESmL9btayTGn4nEFaYfIt0tg8aKGAbfPE68HwiSaynafQlOb9B9t9uc\n3a/NU0S6bH8yGAQyh6jc1aubcdKw5HZMUfK85ZN65ASQ/FF0VAh4drUSZXSA\nDHRNXZdyE5MrBspqUaDkBDrCEgROXhVx/BW2zq8Cp10XepYg6aeMwIRbT7pM\nt0r1gXw+kgQlHJaYo7BQEsScZEuoMmC1Dsx7b3mI+evYK/xs/zNDU+a3Rqku\nrWFIDCGoKi5wl+SUAmciIZMAk6dbjy6gwygrak+pdImV7V61Xq36akZVQVnj\nDmUWQ1gkAXO54XWjzn9hGA9hBhKYNEBQKyFjyeLnABblAtY4sUxpBLTcGlbc\nNMHlraQYXNea9+D6kuHdeqjm+fSAKPqbsYZp400ZdCDtx4TGkEPY7KsMnuZ7\nM+qiAUEA2bIGOYP7Uu0SUqZILEFEimrWZ4jS4xNwciJ/MyFsGoE3SUMjUbn3\nIzHhB0dAgIDJCHMgpcfkzmGfScvrZI9aKKLgJJ63wiwSiUBCZOiBEp9g5Y+1\n8TCvD++KOtK73K9iW4L2d3fKudrqfbUuL5d7zYco7WdTOk3YvtXMtb1XCbSJ\noZBoQ4fXbZsd6uECeH1s+3jTpgI8+S/AqvH5tNAh/7/VX3a06q/kxp6dmjDk\nLTXH\r\n=vtX9\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDMAZNSQSwKxwPldLUqmk1DN3wyg55Fq+xPBhfBto1QpgIhALMisMjd3GCRmb3YVYfCPSk+BlZ2KySv+eSYVTcNOBa7"}]},"maintainers":[{"name":"fluffynuts","email":"davydm@gmail.com"},{"name":"rohland","email":"rohland@codeo.co.za"},{"name":"codeo-jenkins","email":"jenkins@codeo.co.za"}],"_npmUser":{"name":"fluffynuts","email":"davydm@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eventually_1.0.0_1604328698544_0.5255537889859665"},"_hasShrinkwrap":false},"1.0.1":{"name":"@codeo/eventually","version":"1.0.1","description":"Retry async operations with back-off, handle errors by halting, suppressing or failing","main":"index.js","scripts":{"test":"jest","clean-dist":"rimraf dist","generate-index":"node generate-index.js","prebuild":"run-p clean-dist generate-index","build":"tsc","lint":"tslint -p .","pretest":"rimraf .jest-cache","zarro":"zarro","prerelease":"run-s build lint test","release":"cross-env VERSION_INCREMENT_STRATEGY=minor run-s \"zarro release-npm\"","prerelease-beta":"run-s build lint test","release-beta":"cross-env BETA=1 VERSION_INCREMENT_STRATEGY=patch run-s \"zarro release-npm\""},"keywords":[],"author":{"name":"Davyd McColl","email":"davydm@gmail.com"},"repository":{"type":"git","url":"git+https://git@github.com/codeo-za/eventually.git"},"license":"BSD-3-Clause","devDependencies":{"@types/faker":"^5.1.4","@types/jest":"^26.0.15","cross-env":"^7.0.2","expect-even-more-jest":"^1.11.0","faker":"^5.1.0","jest":"^26.6.2","npm-run-all":"^4.1.5","rimraf":"^3.0.2","ts-jest":"^26.4.3","tslint":"^6.1.3","typescript":"^4.0.5","yafs":"^1.7.0","zarro":"^1.79.0"},"gitHead":"4372ff7865f73cac837931e92660f8c7acfa04be","bugs":{"url":"https://github.com/codeo-za/eventually/issues"},"homepage":"https://github.com/codeo-za/eventually#readme","_id":"@codeo/eventually@1.0.1","_nodeVersion":"12.18.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-3DDAlbS+f4cZUHKf6gpUglUq5i5+gFbLHgiMpXdhDtqSre0hVI/db4lZCc7kRwPwCQwMIPPjOikB1zhZ1WKkEg==","shasum":"0219b8414f2d1ef6d6782898e1f3a898e14762e5","tarball":"https://registry.npmjs.org/@codeo/eventually/-/eventually-1.0.1.tgz","fileCount":9,"unpackedSize":7281,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfoB3ECRA9TVsSAnZWagAAwaMP/1YAND5zd9jD3Xu4yjux\nTaXsZGVDDxMSUjKQm1O4PBUr1r6lMC1qGg3wg51W9SGYEOUs5JdYKUMiEGxW\nGPfUGMwnfeA0usKld/2fwshkyFrT+2lof0b27y0tNjJkYEhya3TahfzgoWkF\nzPDgH61on+ip8Ag4JofOPeOR9NAu4Ea2scemrh1y+NxhPrqZoOf1t3ycre3y\niR+Z8VwGSCDokMQoF0WxsPZJ4fk9mC8b+oGxu0yRC+mcisXNZtkF4XWJdSXU\n0KEd1fV7evnHRrib6x7IVkTbwbZhd+Or9Iv4OhLk54w14d7LgMU3EwUGnqDn\nhW0/3yfwKJqIcn5bOCI7xc8qnpOsfzWds5FgmEtWkDovTo19W4rEZz+yE2Pm\nqAA0YZquzvkZCLVMxLiXEfFb4OG2Wfd+wOhhNP2n4A2VWsQBnvu+H6frCOB9\nKkGtydwpfD6upSTALNFg5dPh5zjksQ9pcda8v9/q3wl7RgZbRUdXGBlvszJB\njPcryeMe38+pWV3cSsDH01EWhugsazXUld1BVvu1WDYJjhyxzX0oznKMxpSX\nbmTfe3Za/2FnT7VIBNFauAvzlyLQla9iQv4zzfHKQ86C5sNslMa5GNq1mqeN\n4SUK4++hbgVDB6J5JVHlRUQFndL/sk1x5U+FiU54Vb++ZEScQmDoRW9zV4+v\niEmP\r\n=tNtg\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDBR7Nqru83HMVX4MREM3k87XZA+T0OCPgexzi2UAk2dAiEA2n2z8mYCSNSh0nJVkXpwVZX/Csa76AdV/pylYeyqLBw="}]},"maintainers":[{"name":"fluffynuts","email":"davydm@gmail.com"},{"name":"rohland","email":"rohland@codeo.co.za"},{"name":"codeo-jenkins","email":"jenkins@codeo.co.za"}],"_npmUser":{"name":"fluffynuts","email":"davydm@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eventually_1.0.1_1604328899502_0.8300335705480804"},"_hasShrinkwrap":false},"1.1.0":{"name":"@codeo/eventually","version":"1.1.0","description":"Retry async operations with back-off, handle errors by halting, suppressing or failing","main":"index.js","scripts":{"test":"jest","clean-dist":"rimraf dist","generate-index":"node generate-index.js","prebuild":"run-p clean-dist generate-index","build":"tsc","lint":"tslint -p .","pretest":"rimraf .jest-cache","zarro":"zarro","prerelease":"run-s build lint test","release":"cross-env VERSION_INCREMENT_STRATEGY=minor run-s \"zarro release-npm\"","prerelease-beta":"run-s build lint test","release-beta":"cross-env BETA=1 VERSION_INCREMENT_STRATEGY=patch run-s \"zarro release-npm\""},"keywords":[],"author":{"name":"Davyd McColl","email":"davydm@gmail.com"},"repository":{"type":"git","url":"git+https://git@github.com/codeo-za/eventually.git"},"license":"BSD-3-Clause","devDependencies":{"@types/faker":"^5.1.4","@types/jest":"^26.0.15","cross-env":"^7.0.2","expect-even-more-jest":"^1.11.0","faker":"^5.1.0","jest":"^26.6.2","npm-run-all":"^4.1.5","rimraf":"^3.0.2","ts-jest":"^26.4.3","tslint":"^6.1.3","typescript":"^4.0.5","yafs":"^1.7.0","zarro":"^1.79.0"},"gitHead":"4372ff7865f73cac837931e92660f8c7acfa04be","bugs":{"url":"https://github.com/codeo-za/eventually/issues"},"homepage":"https://github.com/codeo-za/eventually#readme","_id":"@codeo/eventually@1.1.0","_nodeVersion":"12.18.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-GuRHEy4wvfS3F0DFKwtBYgvTN6qhc9ed+8iPvkdbdWltS4hu4uQP2H7EKiycSbAPb1Jyo1oTdXbbycDeFV5T0g==","shasum":"5d6625c62de2e5403f8600acc81af04f210fbdcd","tarball":"https://registry.npmjs.org/@codeo/eventually/-/eventually-1.1.0.tgz","fileCount":9,"unpackedSize":12955,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfoB3nCRA9TVsSAnZWagAAMg8P/3ZS7ZjUsMRZua1z3niD\n2B9Yv0EtRnUFtPXpBx4ffwzeTJlSVfSiidykRv4RQOiUlVs2KT+J6Pbi/GTv\nlpCLl8O02xaEY876sP5wtiAwM9ADabtuPg+KI473RZ6nVGsKeH3PkpLeP2F9\nD91z6X6TSEsSyQM11A3YjtRuy7+oSNvrYvHOR3SmO2n2TPMageFdpf3tief2\n8VaMi8oUiaMMRFxxFbOmrbyWbOYvOgSbcKS+xBjBAuZ5svh+uEvRcPdB1WXA\nDbhC2D2x6sZiPCeBFZUVeaNdDGWiGEneCLRczmDQfqziyb2bKg2MYBFfPDvI\n8RZbPe+NfgNuStCHZBJgWxLT6vMBz73nCs9OtUfUp1dtaxPKQUC5ei2drSSr\n8+cP4NV47wxhzsJ3AzJE+pIIcI5NYgfeq0e85lRxpKGrGPt898P+HnmMMfrr\nwpZn1O+RI3Z9PzDLllVmRSQGZSrrQpjOded0nMfZr4GmhaccArMWQhn5Po07\nwVMctpJc+09CHHE2/TTxJiD5RPElU8UIY3a8lnXCI/xt3ETXrc37mBEfhoE6\nKnk/x2xmUAOL+Z2j0SEtQdafE/ARkltM4UmtTeKXwtr0w7CwVevkOlmmJNI4\n5JE//uf+VCpc8wb1jUM8ZZlh5YSoPcEEYf2aJKXdut/hFql2FyDGmgV1LPU0\nzAeq\r\n=E/JE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDi1dtr8ns9tT5jv8lIEZauCy9q1CmTFqUYr5AWMfrvnAiBnUaX3w0X1ZbHCmXnMrJCidgNCiqs5lDFrLRERucb+bA=="}]},"maintainers":[{"name":"fluffynuts","email":"davydm@gmail.com"},{"name":"rohland","email":"rohland@codeo.co.za"},{"name":"codeo-jenkins","email":"jenkins@codeo.co.za"}],"_npmUser":{"name":"fluffynuts","email":"davydm@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eventually_1.1.0_1604328934776_0.19793317659503806"},"_hasShrinkwrap":false},"1.2.0":{"name":"@codeo/eventually","version":"1.2.0","description":"Retry async operations with back-off, handle errors by halting, suppressing or failing","main":"index.js","scripts":{"test":"jest","clean-dist":"rimraf dist","generate-index":"node generate-index.js","prebuild":"run-p clean-dist generate-index","build":"tsc","lint":"tslint -p .","pretest":"rimraf .jest-cache","zarro":"zarro","prerelease":"run-s build lint test","release":"cross-env VERSION_INCREMENT_STRATEGY=minor run-s \"zarro release-npm\"","prerelease-beta":"run-s build lint test","release-beta":"cross-env BETA=1 VERSION_INCREMENT_STRATEGY=patch run-s \"zarro release-npm\""},"keywords":[],"author":{"name":"Davyd McColl","email":"davydm@gmail.com"},"repository":{"type":"git","url":"git+https://git@github.com/codeo-za/eventually.git"},"license":"BSD-3-Clause","devDependencies":{"@types/faker":"^5.1.4","@types/jest":"^26.0.15","cross-env":"^7.0.2","expect-even-more-jest":"^1.11.0","faker":"^5.1.0","jest":"^26.6.2","npm-run-all":"^4.1.5","rimraf":"^3.0.2","ts-jest":"^26.4.3","tslint":"^6.1.3","typescript":"^4.0.5","yafs":"^1.7.0","zarro":"^1.79.0"},"gitHead":"742f0a37674e7611dbec1fd7212d5854515f6c24","bugs":{"url":"https://github.com/codeo-za/eventually/issues"},"homepage":"https://github.com/codeo-za/eventually#readme","_id":"@codeo/eventually@1.2.0","_nodeVersion":"12.18.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-N1HBMuN7YO8zcWDSXHi9C+PpCbHqRujmCj6s+ftohpGx1ZKqB0oWtumnSSl8gFSV4sGP98mx7VvORUbQc3yktw==","shasum":"f2ec6d8f530932005adc1c2476605fb60da9c6e2","tarball":"https://registry.npmjs.org/@codeo/eventually/-/eventually-1.2.0.tgz","fileCount":9,"unpackedSize":12955,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfoB/ICRA9TVsSAnZWagAAqq4P/2nrw+ugNZh2/W5sl92x\nNg+HZ80wq5P7rVZPRlQ6La7QNM3VQ7etjEX/wt5ACynsa7cVsDmt21TuQP08\nlVC2Zlcu4ZaLiuxQ6JI3d69TjoD64rRC18KUYUQ6/mrMERtLJlcpGZojllLr\nezayoE9Il4RsKZtEcyeBCubGIeNJusIC53u1yLXAhOvKCFbxzwT4QNtcP4I6\nQr0d8s9LY5a22hYavNALA1CCSnNrT8G3Oaol2W1v+PgWsf6R3pcbIf16DmjB\nwmJb+pVD11wQdV0SOOYvT25O7feGsdfajPVHF+HSd8frPWC6vhzgUMhfranZ\nHB53WfE00q+nUdE5YZ//hNfBRCtIryS9W8eyLrgyDWLmBi6GY5yOlOg2tbcL\nrgU0WTJRWXwQQvXW8Av7zLlvrOeWKR5d2eWesh9Pd3Tpnb29GD30bSRoQ/rZ\ngmEX+XzWyUgOUa6EKwZZxP06dzdcmUs1WegviHR6EGokC0dWkGmlZGMeFAph\neVxIhCorhG0IAs4kT/q3vmLRfcrD9V7/CcWAn3eGoEklv6dohtVnRMBWx34V\nZQN9/B2WcNh/qfKL7gSFVrtHJ2LrryBToCOi72+OCfRfOmV7GM1I1yHten7v\n8vJ9v876yhALV41unY6LSb1odgAsbiXHgCgrm2NCaYwdolh/ZTUO9/YB8VHF\nZ8U2\r\n=Lw97\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCgt0tHgEq+lc9XXiwJKK3ChgaDHKq6eHtIcaqmGm9BWgIgFIh/ougz3xCjZySzNfG9lJgFXl5RoeVAADqMj0HdnSk="}]},"maintainers":[{"name":"fluffynuts","email":"davydm@gmail.com"},{"name":"rohland","email":"rohland@codeo.co.za"},{"name":"codeo-jenkins","email":"jenkins@codeo.co.za"}],"_npmUser":{"name":"fluffynuts","email":"davydm@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eventually_1.2.0_1604329415822_0.0022882296223183385"},"_hasShrinkwrap":false}},"time":{"created":"2020-11-02T14:51:38.544Z","1.0.0":"2020-11-02T14:51:38.683Z","modified":"2022-04-05T00:04:14.719Z","1.0.1":"2020-11-02T14:54:59.661Z","1.1.0":"2020-11-02T14:55:34.876Z","1.2.0":"2020-11-02T15:03:35.944Z"},"maintainers":[{"name":"fluffynuts","email":"davydm@gmail.com"},{"name":"rohland","email":"rohland@codeo.co.za"},{"name":"codeo-jenkins","email":"jenkins@codeo.co.za"}],"description":"Retry async operations with back-off, handle errors by halting, suppressing or failing","keywords":[],"author":{"name":"Davyd McColl","email":"davydm@gmail.com"},"license":"BSD-3-Clause","readme":"eventually\n---\nRetry async operations with back-off, handle errors by halting, suppressing or failing.\n\nExamples\n---\n\n1. Easily retry an async function up to 3 times, throwing if the last attempt fails\n    ```typescript\n    import { eventually } from \"@codeo/eventually\";\n    const result = await eventually(() => queryApi(1, 2, 3), { retries: 3 });\n    ```\n\n2. Retry an async function with a back-off strategy: the passed array is\na set of millisecond values to back off by. Once the last one is reached,\nthat value is used for any further delays to retry attempts. If the following\ncode were to fail all 5 times, it would back off by 50ms on the second attempt,\n250ms on the third attempts, 1 second on the fourth and fifth attempts.\n    ```typescript\n    import { eventually } from \"@codeo/eventually\";\n    const result = await eventually(() => queryApi(\"user input\"), {\n        retries: 5,\n        backoff: [ 50, 250, 1000 ]\n    });\n    ```\n\n    `backoff` may also be specified as a single numeric value to use for all attempts.\n\n3. Halt on error: the promise never resolves. Useful for, eg, polling code where\nit's ok for an occasional failure or where failures are simply non-fatal, such as\npolling for an unread message count, which can fail when your app is backgrounded.\n    ```typescript\n   import { eventually, ErrorHandlingStrategies } from \"@codeo/eventually\";\n   const result = await eventually(() => poll(\"message-count\"), {\n       retries: 2,\n       fail: async(e) => {\n           return ErrorHandlingStrategies.halt;\n       }\n   });\n   // if the above fails completely, then this part of code is never reached\n   console.log(`you have ${result} messages`);\n    ```\n\n4. Suppress an error: in this case, the caller continues with execution (will not\nhalt the promise chain or cause an await to \"deadlock\") and `undefined` is returned\nto the caller. Since `fail` is an async function, you may choose how to proceed based on the\nerror you've received. Possible strategies are:\n    -   fail     ->  pass on the failure\n    -   halt     ->  stop the promise chain right here\n    -   suppress -> completes the chain, but resolves undefined\n    -   retry    -> just try again\n    ```typescript\n    import { eventually, ErrorHandlingStrategies } from \"@codeo/eventually\";\n    const result = await eventually(() => willFail(), {\n        retries: 1,\n        fail: async(e: Error) => {\n            return ErrorHandlingStrategies.suppress;\n        }\n    });\n    ```\n   \n5. Your `fail` handler may even return a new `IEventuallyOptions` object to \n    completely change the flow of logic\n\n6. In addition, you may redirect errors with the `redirect` property on the provided\noptions, for instance when you have a valid value to fall back on when your async\nfunction fails:\n    ```typescript\n    import { eventually } from \"@codeo/eventually\";\n    const fallbackValue = 1;\n    const result = await eventually(pollServer, {\n       redirect: (e: Error) => fallbackValue\n    });\n    ```\n    which you could use to query a secondary api eg, when the first is too loaded:\n    ```typescript\n    import { eventually } from \"@codeo/eventually\";\n    const fallbackValue = 1;\n    const result = await eventually(pollServer1, {\n       redirect: (e: Error) => eventually(pollServer2, {\n           redirect: (e: Error) => fallbackValue\n       })\n    });\n    ```\n\n","readmeFilename":"README.md","homepage":"https://github.com/codeo-za/eventually#readme","repository":{"type":"git","url":"git+https://git@github.com/codeo-za/eventually.git"},"bugs":{"url":"https://github.com/codeo-za/eventually/issues"}}