{
  "name": "reconnect",
  "version": "0.1.5",
  "homepage": "https://github.com/dominictarr/reconnect",
  "repository": {
    "type": "git",
    "url": "git://github.com/dominictarr/reconnect.git"
  },
  "dependencies": {
    "backoff": "~1.0.0",
    "shoe": "~0.0.7",
    "h": "~0.1.0"
  },
  "devDependencies": {
    "tap": "0.3.0",
    "macgyver": "1.7.0"
  },
  "browserify": "./shoe",
  "scripts": {
    "test": "tap test"
  },
  "author": {
    "name": "'Dominic Tarr'",
    "email": "dominic.tarr@gmail.com",
    "url": "http://dominictarr.com"
  },
  "license": "MIT",
  "readme": "# reconnect\n\nreconnect to a network stream, (currently supports [tcp](http://nodejs.org/api/net.html), \nand [shoe](https://github.com/substack/shoe) on the client-side.\n\n## Example\n\npass function will be called every time the stream connects.\nif the connection is broken, reconnect will make a new connection\nand call this function again.\n``` js\nvar reconnect = require('reconnect')\n\nreconnect(function (stream) {\n  //called every time the connection is remade.\n  //only one connection will ever be live at one time.\n}).connect(port)\n```\n\n## API\n\n### reconnect (opts, onConnect)\n\nif `opts` is an object it will be passed to [backoff](https://github.com/MathieuTurcotte/node-backoff)\nwhich handles throtteling the reconnection attempts. it also accepts a `type` parameter, which may \nbe either `'fibonacci'` or `'exponential'`.\n\n``` js\n//example opts\nvar opts = {\n  randomisationFactor: 0,\n  initialDelay: 10,\n  maxDelay: 300\n}\n```\n\n`opts` is optional.\n\npassing `onConnect` to reconnect is short hand for `reconnect(opts).on('connect', onConnect)`\n\n### reconnect.connect (...)\n\nattempt to connect. the arguments will be passed onto the underlying stream type.\n(either you are calling `shoe(uri)` or `net.connect(port)`)\nthese arguments will be used for every subsequent connection attempt.\n\n### emit('connect', stream)\n\nemitted when a new connection is made (that includes after a disconnection!)\n\n### emit('disconnect', stream)\n\nemitted when the stream has disconnected.\n\n### emit ('backoff', attempts, delay)\n\nreemitted from [backoff](https://github.com/MathieuTurcotte/node-backoff) \nwhen reconnect is waiting for the next time to connect.\n\n### emit ('reconnect', attempts, delay)\n\nemitted when attempting a new connection.\n\n### reconnector.reconnect\n\nset to `false` and `reconnect` will not automatically reconnect.\nstarts out true.\n\n## Extending\n\nInject a handler for a custom stream type, example http would look like this\n\n``` js\nvar inject  = require('reconnect/inject')\nvar request = require('request')\n\nmodule.exports = inject(function () {\n  var req = request.apply(null, [].slice.call(arguments))\n  //you might need to add some event stuff here\n  return req\n})\n\n```\n\nyou must return a stream, and it must emit a 'connect' event when it has\nactually connected to the server like in [net](http://nodejs.org/api/net.html)\n\n## Widget\n\nAlso, there is a small widget to show current connection status.\n\n``` js\nvar reconnect = require('reconnect')\n\nvar r = reconnect(function (stream) {\n  ...\n})\n//add the widget to the page.\n\ndocument.body.appendChild(r.widget())\n\n```\n\n## License\n\nMIT\n",
  "readmeFilename": "README.md",
  "_id": "reconnect@0.1.5",
  "description": "reconnect to a network stream, (currently supports [tcp](http://nodejs.org/api/net.html),  and [shoe](https://github.com/substack/shoe) on the client-side.",
  "_from": "reconnect@~0.1.2"
}
