{"_id":"back","_rev":"363556","name":"back","description":"Simple exponential backoff pulled out of Primus by @3rd-Eden","dist-tags":{"latest":"1.0.2"},"maintainers":[{"name":"jcrugzz","email":"jcrugzz@gmail.com"}],"time":{"modified":"2021-07-13T08:59:35.000Z","created":"2013-08-20T08:26:53.121Z","1.0.2":"2017-09-01T18:50:42.595Z","1.0.1":"2015-06-19T17:48:52.440Z","1.0.0":"2014-12-12T00:56:53.513Z","0.2.0":"2014-11-25T22:35:36.272Z","0.1.5":"2013-10-28T14:35:13.138Z","0.1.4":"2013-10-27T21:08:54.880Z","0.1.3":"2013-09-13T17:26:47.849Z","0.1.2":"2013-09-11T23:38:51.053Z","0.1.1":"2013-09-11T22:38:58.452Z","0.1.0":"2013-08-27T18:47:42.712Z","0.0.1":"2013-08-20T08:26:53.121Z"},"users":{},"author":{"name":"Jarrett Cruger","email":"jcrugzz@gmail.com"},"repository":{"url":"git://github.com/jcrugzz/back.git"},"versions":{"1.0.2":{"name":"back","description":"Simple exponential backoff pulled out of Primus by @3rd-Eden","version":"1.0.2","keywords":["random","exponential","backoff"],"author":{"name":"Jarrett Cruger","email":"jcrugzz@gmail.com"},"contributors":[{"name":"Jake Verbaten","email":"raynos2@gmail.com"}],"repository":{"url":"git://github.com/jcrugzz/back.git"},"main":"index.js","scripts":{"test":"tape test/*.js"},"engines":{"node":">=4.x || 0.12.x || 0.10.x || 0.8.x"},"dependencies":{"xtend":"^4.0.0"},"devDependencies":{"tape":"2.1.x"},"license":"MIT","gitHead":"32d6209a29068bc64ced0227d45856cfe025ef1b","bugs":{"url":"https://github.com/jcrugzz/back/issues"},"homepage":"https://github.com/jcrugzz/back#readme","_id":"back@1.0.2","_shasum":"a93f5e6ce69729984d5901a2bb16e3b01a4d6369","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.10.0","_npmUser":{"name":"jcrugzz","email":"jcrugzz@gmail.com"},"dist":{"shasum":"a93f5e6ce69729984d5901a2bb16e3b01a4d6369","size":3969,"noattachment":false,"key":"/back/-/back-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/back/download/back-1.0.2.tgz"},"maintainers":[{"name":"jcrugzz","email":"jcrugzz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/back-1.0.2.tgz_1504291841653_0.5368193071335554"},"directories":{},"publish_time":1504291842595,"_hasShrinkwrap":false,"_cnpm_publish_time":1504291842595},"1.0.1":{"name":"back","description":"Simple exponential backoff pulled out of Primus by @3rd-Eden","version":"1.0.1","keywords":["random","exponential","backoff"],"author":{"name":"Jarrett Cruger","email":"jcrugzz@gmail.com"},"contributors":[{"name":"Jake Verbaten","email":"raynos2@gmail.com"}],"repository":{"url":"git://github.com/jcrugzz/back.git"},"main":"index.js","scripts":{"test":"tape test/*.js"},"engines":{"node":"0.12.x || 0.10.x || 0.8.x"},"dependencies":{"xtend":"^4.0.0"},"devDependencies":{"tape":"2.1.x"},"license":"MIT","gitHead":"ccbaa96fdbf367648971fc776aa4917040b7994a","bugs":{"url":"https://github.com/jcrugzz/back/issues"},"homepage":"https://github.com/jcrugzz/back","_id":"back@1.0.1","_shasum":"704f8a23da7ae35b7d47b648f9a79fd2a25570e3","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.10.38","_npmUser":{"name":"jcrugzz","email":"jcrugzz@gmail.com"},"maintainers":[{"name":"jcrugzz","email":"jcrugzz@gmail.com"}],"dist":{"shasum":"704f8a23da7ae35b7d47b648f9a79fd2a25570e3","size":4903,"noattachment":false,"key":"/back/-/back-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/back/download/back-1.0.1.tgz"},"directories":{},"publish_time":1434736132440,"_cnpm_publish_time":1434736132440,"_hasShrinkwrap":false},"1.0.0":{"name":"back","description":"Simple exponential backoff pulled out of Primus by @3rd-Eden","version":"1.0.0","keywords":["random","exponential","backoff"],"author":{"name":"Jarrett Cruger","email":"jcrugzz@gmail.com"},"contributors":[{"name":"Jake Verbaten","email":"raynos2@gmail.com"}],"repository":{"url":"git://github.com/jcrugzz/back.git"},"main":"index.js","scripts":{"test":"tape test/*.js"},"engines":{"node":"0.10.x || 0.8.x"},"dependencies":{"xtend":"^4.0.0"},"devDependencies":{"tape":"2.1.x"},"license":"MIT","gitHead":"8bb1a7e66b0d2b00e2b7868dd726f7de3a06be9e","bugs":{"url":"https://github.com/jcrugzz/back/issues"},"homepage":"https://github.com/jcrugzz/back","_id":"back@1.0.0","_shasum":"6cb40866cdda6b3a614854db65ef60eb03078199","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jcrugzz","email":"jcrugzz@gmail.com"},"maintainers":[{"name":"jcrugzz","email":"jcrugzz@gmail.com"}],"dist":{"shasum":"6cb40866cdda6b3a614854db65ef60eb03078199","size":3937,"noattachment":false,"key":"/back/-/back-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/back/download/back-1.0.0.tgz"},"directories":{},"publish_time":1418345813513,"_cnpm_publish_time":1418345813513,"_hasShrinkwrap":false},"0.2.0":{"name":"back","description":"Simple exponential backoff pulled out of Primus by @3rd-Eden","version":"0.2.0","keywords":["random","exponential","backoff"],"author":{"name":"Jarrett Cruger","email":"jcrugzz@gmail.com"},"repository":{"url":"git://github.com/jcrugzz/back.git"},"main":"index.js","scripts":{"test":"tape test/*.js"},"engines":{"node":"0.10.x || 0.8.x"},"dependencies":{"xtend":"^4.0.0"},"devDependencies":{"tape":"2.1.x"},"license":"MIT","gitHead":"5bfd70ed384a12d4856898a7797d693382d3043b","bugs":{"url":"https://github.com/jcrugzz/back/issues"},"homepage":"https://github.com/jcrugzz/back","_id":"back@0.2.0","_shasum":"633f8874dd8fd7c0e73dc4dd27d7750d6a2877f3","_from":".","_npmVersion":"2.1.6","_nodeVersion":"0.10.32","_npmUser":{"name":"jcrugzz","email":"jcrugzz@gmail.com"},"maintainers":[{"name":"jcrugzz","email":"jcrugzz@gmail.com"}],"dist":{"shasum":"633f8874dd8fd7c0e73dc4dd27d7750d6a2877f3","size":3337,"noattachment":false,"key":"/back/-/back-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/back/download/back-0.2.0.tgz"},"directories":{},"publish_time":1416954936272,"_cnpm_publish_time":1416954936272,"_hasShrinkwrap":false},"0.1.5":{"name":"back","description":"Simple exponential backoff pulled out of Primus by @3rd-Eden","version":"0.1.5","keywords":["random","exponential","backoff"],"author":{"name":"Jarrett Cruger","email":"jcrugzz@gmail.com"},"repository":{"url":"git://github.com/jcrugzz/back.git"},"main":"index.js","scripts":{"test":"tape test/*.js"},"engines":{"node":"0.10.x || 0.8.x"},"dependencies":{},"devDependencies":{"tape":"2.1.x"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/jcrugzz/back/issues"},"_id":"back@0.1.5","dist":{"shasum":"342b96b804657b03ec9a31f248a11f200608dcc2","size":3125,"noattachment":false,"key":"/back/-/back-0.1.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/back/download/back-0.1.5.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"jcrugzz","email":"jcrugzz@gmail.com"},"maintainers":[{"name":"jcrugzz","email":"jcrugzz@gmail.com"}],"directories":{},"publish_time":1382970913138,"_hasShrinkwrap":false,"_cnpm_publish_time":1382970913138},"0.1.4":{"name":"back","description":"Simple exponential backoff pulled out of Primus by @3rd-Eden","version":"0.1.4","keywords":["random","exponential","backoff"],"author":{"name":"Jarrett Cruger","email":"jcrugzz@gmail.com"},"repository":{"url":"git://github.com/jcrugzz/back.git"},"main":"index.js","scripts":{"test":"tape test/*.js"},"engines":{"node":"0.10.x || 0.8.x"},"dependencies":{},"devDependencies":{"tape":"2.1.x"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/jcrugzz/back/issues"},"_id":"back@0.1.4","dist":{"shasum":"f3a497cce74fe87bbdfb2d40b663a3188ee81ca6","size":3104,"noattachment":false,"key":"/back/-/back-0.1.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/back/download/back-0.1.4.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"jcrugzz","email":"jcrugzz@gmail.com"},"maintainers":[{"name":"jcrugzz","email":"jcrugzz@gmail.com"}],"directories":{},"publish_time":1382908134880,"_hasShrinkwrap":false,"_cnpm_publish_time":1382908134880},"0.1.3":{"name":"back","description":"Simple exponential backoff pulled out of Primus by @3rd-Eden","version":"0.1.3","keywords":["random","exponential","backoff"],"author":{"name":"Jarrett Cruger","email":"jcrugzz@gmail.com"},"repository":{"url":"git://github.com/jcrugzz/back.git"},"main":"index.js","scripts":{"test":"tape test/*.js"},"engines":{"node":"0.10.x || 0.8.x"},"dependencies":{},"devDependencies":{"tape":"~1.0.2"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/jcrugzz/back/issues"},"_id":"back@0.1.3","dist":{"shasum":"09c8db3de95da15760fb0c037fa2968c16f9eff2","size":2013,"noattachment":false,"key":"/back/-/back-0.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/back/download/back-0.1.3.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"jcrugzz","email":"jcrugzz@gmail.com"},"maintainers":[{"name":"jcrugzz","email":"jcrugzz@gmail.com"}],"directories":{},"publish_time":1379093207849,"_hasShrinkwrap":false,"_cnpm_publish_time":1379093207849},"0.1.2":{"name":"back","description":"Simple exponential backoff pulled out of Primus by @3rd-Eden","version":"0.1.2","keywords":["random","exponential","backoff"],"author":{"name":"Jarrett Cruger","email":"jcrugzz@gmail.com"},"repository":{"url":"git://github.com/jcrugzz/back.git"},"main":"index.js","scripts":{"test":"tape test/*.js"},"engines":{"node":"0.10.x || 0.8.x"},"dependencies":{},"devDependencies":{"tape":"~1.0.2"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/jcrugzz/back/issues"},"_id":"back@0.1.2","dist":{"shasum":"c3845dc9fbf2805a528be32cc2a56f6a4a085db2","size":1988,"noattachment":false,"key":"/back/-/back-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/back/download/back-0.1.2.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"jcrugzz","email":"jcrugzz@gmail.com"},"maintainers":[{"name":"jcrugzz","email":"jcrugzz@gmail.com"}],"directories":{},"publish_time":1378942731053,"_hasShrinkwrap":false,"_cnpm_publish_time":1378942731053},"0.1.1":{"name":"back","description":"Simple exponential backoff pulled out of Primus by @3rd-Eden","version":"0.1.1","keywords":["random","exponential","backoff"],"author":{"name":"Jarrett Cruger","email":"jcrugzz@gmail.com"},"repository":{"url":"git://github.com/jcrugzz/back.git"},"main":"index.js","scripts":{"test":"tape test/*.js"},"engines":{"node":"0.10.x || 0.8.x"},"dependencies":{},"devDependencies":{"tape":"~1.0.2"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/jcrugzz/back/issues"},"_id":"back@0.1.1","dist":{"shasum":"deb8395d4571758fb2f8f26d245f9fda21e9bcca","size":2025,"noattachment":false,"key":"/back/-/back-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/back/download/back-0.1.1.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"jcrugzz","email":"jcrugzz@gmail.com"},"maintainers":[{"name":"jcrugzz","email":"jcrugzz@gmail.com"}],"directories":{},"publish_time":1378939138452,"_hasShrinkwrap":false,"_cnpm_publish_time":1378939138452},"0.1.0":{"name":"back","description":"Simple exponential backoff pulled out of Primus by @3rd-Eden","version":"0.1.0","keywords":["random","exponential","backoff"],"author":{"name":"Jarrett Cruger","email":"jcrugzz@gmail.com"},"repository":{"url":"git://github.com/jcrugzz/back.git"},"main":"index.js","scripts":{"test":"tape test/*.js"},"engines":{"node":"0.10.x || 0.8.x"},"dependencies":{},"devDependencies":{"tape":"~1.0.2"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/jcrugzz/back/issues"},"_id":"back@0.1.0","dist":{"shasum":"c6935ca44283cf5978eb579d65d824984adb9bac","size":1988,"noattachment":false,"key":"/back/-/back-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/back/download/back-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"jcrugzz","email":"jcrugzz@gmail.com"},"maintainers":[{"name":"jcrugzz","email":"jcrugzz@gmail.com"}],"directories":{},"publish_time":1377629262712,"_hasShrinkwrap":false,"_cnpm_publish_time":1377629262712},"0.0.1":{"name":"back","description":"Simple exponential backoff pulled out of Primus by @3rd-Eden","version":"0.0.1","author":{"name":"Jarrett Cruger","email":"jcrugzz@gmail.com"},"repository":{"url":"git://github.com/jcrugzz/back.git"},"main":"index.js","scripts":{"test":"tape test/*.js"},"engines":{"node":"0.10.x || 0.8.x"},"dependencies":{},"devDependencies":{"tape":"~1.0.2"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/jcrugzz/back/issues"},"_id":"back@0.0.1","dist":{"shasum":"2b533e58af19c14fa408e94a371d8f29f4579b4d","size":1953,"noattachment":false,"key":"/back/-/back-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/back/download/back-0.0.1.tgz"},"_from":".","_npmVersion":"1.3.2","_npmUser":{"name":"jcrugzz","email":"jcrugzz@gmail.com"},"maintainers":[{"name":"jcrugzz","email":"jcrugzz@gmail.com"}],"directories":{},"publish_time":1376987213121,"_hasShrinkwrap":false,"_cnpm_publish_time":1376987213121}},"readme":"# back\n\n[![build\nstatus](https://secure.travis-ci.org/jcrugzz/back.png)](http://travis-ci.org/jcrugzz/back)\n\n[![NPM](https://nodei.co/npm/back.png)](https://nodei.co/npm/back/)\n\nA simple module to be used for creating exponentially weighted backoff attempts.\nOriginally extracted from [Primus][Primus].\n\n__NOTICE__\nIf you were a pre-1.0.0 `back` user, the API has changed to what is found below.\nIf you do not like this slightly different abstraction and would prefer the\nformer, slightly simpler API, it is still available with `require('back/reconnect')`.\n\nThe API change thanks to a contribution from\n[@Raynos](https://github.com/Raynos) makes things simpler as you don't have to\nmanage the copying of the options object yourself in order to handle repeated\nbackoff cases.\n\n## Example\n\n```js\nvar http = require('http');\nvar back = require('back');\n//\n// Options to use for backoff\n//\n// Remark: This object is modified so it should be cloned if you are dealing\n// with independent backoff attempts and want to use these values as a base.\n//\nvar options = {\n  retries: 3,\n  minDelay: 1000, // Defaults to 500ms\n  maxDelay: 10000, // Defaults to infinity\n  // The following option is shown with its default value but you will most\n  // likely never define it as it creates the exponential curve.\n  factor: 2,\n};\n\n// Where we will store the backoff instance during a particular backoff attempt\nvar attempt;\n\nfunction retry(err) {\n  var back = attempt || (attempt = new Back(options));\n  return back.backoff(function (fail) {\n    if (fail) {\n      // Oh noez we never reconnect :(\n      console.error('Retry failed with ' + err.message);\n      process.exit(1);\n    }\n    //\n    // Remark: .attempt and .timeout are added to this object internally\n    //\n    console.log('Retry attempt # ' + back.settings.attempt +\n                ' being made after ' + back.settings.timeout + 'ms');\n  request();\n  });\n}\n\nfunction request() {\n  http.get('http://localhost:9000', function (res) {\n    console.log('Successful Response that will not happen!');\n    //\n    // If we succeeded, we would set the current to null so the next error\n    // generates a new instance.\n    //\n    attempt = null;\n  }).on('error', retry);\n}\n\nrequest();\n```\n\n## API\n\n### `var back = new Back(backoffOpts);`\n\nThe `Back` constructor function takes your backoff options and saves them as\n`settings` in the internal state of the `back` object.\n\n#### `back.backoff(callback)`\n\nThe `back` instance has a `backoff` method that takes a  `callback` that is\nexecuted after a `setTimeout`. The timeout is what is based on an [exponential\nbackoff](http://dthain.blogspot.nl/2009/02/exponential-backoff-in-distributed.html) of course!\nIt will repeatedly all this callback based on the backoff options you passed to\nthe back instance until it exhausts its efforts. When it has exhausted its\nattempts, it will return an error as the first argument to the callback.\n\n#### `back.close()`\n\nClear backoff timer in cases where you want to dispose of the instance before the `callback` is executed.\n\n[Primus]: https://github.com/3rd-Eden/primus\n\n","_attachments":{},"homepage":"https://github.com/jcrugzz/back#readme","bugs":{"url":"https://github.com/jcrugzz/back/issues"},"license":"MIT"}