{"_id":"@disruptops/reconnecting-eventsource","_rev":"5-2842e870e7cb0a9cc276c1c9f5742752","name":"@disruptops/reconnecting-eventsource","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.2":{"name":"@disruptops/reconnecting-eventsource","version":"1.0.2","description":"wrapper library around the JavaScript EventSource API to ensure it maintains a connection to the server.","main":"lib/index.js","scripts":{"clean":"rimraf lib dist","build":"npm run build:commonjs && npm run build:umd && npm run build:umd:min","build:commonjs":"cross-env BUILD_TARGET=commonjs webpack","build:umd":"cross-env BUILD_TARGET=umd webpack","build:umd:min":"cross-env BUILD_TARGET=umd-min webpack","check:src":"npm run lint","lint":"eslint src","prepublishOnly":"npm run clean && npm run check:src && npm run build","test":"node test"},"repository":{"type":"git","url":"git+https://github.com/fanout/reconnecting-eventsource.git"},"author":{"name":"Fanout, Inc.","email":"info@fanout.io"},"license":"MIT","contributors":[{"name":"Katsuyuki Ohmuro","email":"harmony7@pex2.jp"}],"keywords":["fanout","eventsource","sse","realtime","push"],"bugs":{"url":"https://github.com/fanout/reconnecting-eventsource/issues"},"homepage":"https://github.com/fanout/reconnecting-eventsource#readme","devDependencies":{"babel":"^6.23.0","babel-core":"^6.26.3","babel-eslint":"^7.2.3","babel-loader":"^7.1.1","babel-plugin-transform-es2015-modules-umd":"^6.24.1","babel-preset-env":"^1.7.0","cross-env":"^5.0.1","eslint":"^4.2.0","eventsource":"^1.0.7","rimraf":"^2.6.1","sse":"0.0.8","stoppable":"^1.1.0","webpack":"^3.12.0"},"gitHead":"aa1fc78ee427899f8efcc11380e6a219de05e2fa","_id":"@disruptops/reconnecting-eventsource@1.0.2","_npmVersion":"5.6.0","_nodeVersion":"8.10.0","_npmUser":{"name":"edorsey","email":"eric@ericdorsey.com"},"dist":{"integrity":"sha512-N/rMget2SGzKE+Dl0gVkHZq3LYiHEPr6qNjbjNQ7tUwprK2VrdvOhIT2ejrSrmDkMxuz3nKC+QAWDiJRSi6R/w==","shasum":"5971b2cd33b4264fe21b5e7cabd0c50ab1ce6d9c","tarball":"https://registry.npmjs.org/@disruptops/reconnecting-eventsource/-/reconnecting-eventsource-1.0.2.tgz","fileCount":15,"unpackedSize":50558,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdSfdTCRA9TVsSAnZWagAAK6sP/RHKAoA1gipZ2glOsjnK\nCritvGUZ//d5QUqtVrdU1nkZ6oJ3CxoZK2UIkYOz6GmdA+c4FQrz7qVVGkii\nnxsALY1jyy4njkA3o8txTiq/y7LDNy3sitR8SFOkq0nrCQ/92DjWfdMFQV3U\nmR7hUO+LLZI+xMEhQRXFnwIRN1sE+AJ0YlCvYeQq2yJ6hCMP614h6eqOgrAw\n+8XAeRd+QWc7aKXlnEak0N5Bw2nQrVKaqFSz2TMl3ySXijVl/Nj9MhA6AL9y\nsWVH3GOAWxdf9Flb34HV2SpFRCWxYKOXVenVG/9a+u5ZeIz0SwVY8J6NIBZD\nqGLX/Pq8DuZ4CVsh5EdjzvxGbxUAW4g9dIyJeRKbaj9tyVk9TG29UEUF187G\nkMaXmjTqH4d5/LVFalRoSI9BflqqOposgsto4BCBik4Ojbu4nLAljeai5qWW\ndAjQtnIcetFKd1gMGkIhtfAMkcOJ992mHweFUVfG4QE193SEZWDfGdVp4OM3\nCOvWzMD320d0TqeR2bxXrPlho8rcTPSsfjq5GBNBVOMGPzL9g2/ErBio8hKr\nuFcr3sbz+0TGbuWeyCrxwyiwiLsFy/gqHz9Y0HhXGqLRGw1kqo4TYngWpfO+\nsAsvKcUepftzswXWOXqpF3ihL8vy/RkUbReSC70H695COVUu2mDyc1MsOBQn\nEgko\r\n=YpHm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIQC6Ma3hZsEybC2Hmqi9X0QKo+D+S9+MBAo/PM1hapS/ywIfVa6OawquJMAP66S+/RCnCviT/WxpvJCudiJN7b5Oag=="}]},"maintainers":[{"name":"edorsey","email":"eric@ericdorsey.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/reconnecting-eventsource_1.0.2_1565128530377_0.771002583325999"},"_hasShrinkwrap":false}},"time":{"created":"2019-08-06T21:55:30.284Z","1.0.2":"2019-08-06T21:55:30.709Z","modified":"2022-04-05T04:46:12.057Z"},"maintainers":[{"email":"bpeterson@disruptops.com","name":"brandypeterson312"},{"email":"jcouser@disruptops.com","name":"jcouser"},{"email":"jcoon@disruptops.com","name":"jasoncoon"},{"email":"markbelles@gmail.com","name":"mbelles"},{"email":"eric@ericdorsey.com","name":"edorsey"}],"description":"wrapper library around the JavaScript EventSource API to ensure it maintains a connection to the server.","homepage":"https://github.com/fanout/reconnecting-eventsource#readme","keywords":["fanout","eventsource","sse","realtime","push"],"repository":{"type":"git","url":"git+https://github.com/fanout/reconnecting-eventsource.git"},"contributors":[{"name":"Katsuyuki Ohmuro","email":"harmony7@pex2.jp"}],"author":{"name":"Fanout, Inc.","email":"info@fanout.io"},"bugs":{"url":"https://github.com/fanout/reconnecting-eventsource/issues"},"license":"MIT","readme":"# ReconnectingEventSource\n\nThis is a small wrapper library around the [JavaScript EventSource API](https://www.w3.org/TR/eventsource/) to ensure it maintains a connection to the server. Normally, `EventSource` will reconnect on its own, however there are some cases where it may not. This library ensures a reconnect always happens.\n\nTo use it, just replace:\n\n```js\nvar es = new EventSource(url);\n```\n\nwith:\n\n```js\nvar es = new ReconnectingEventSource(url);\n```\n\n## Adding to your project\n\n```sh\nnpm install reconnecting-eventsource\n```\n\nIn a browser environment, bring this in using:\n\n```html\n<script src=\"/node_modules/reconnecting-eventsource/dist/ReconnectingEventSource[.min].js\"></script>\n```\n\n(You are free to copy this file out of `node_modules` if you wish)\n\nFor node/browserify/webpack/etc, use:\n\n```js\nimport ReconnectingEventSource from \"reconnecting-eventsource\";\n```\n\nNote: This project assumes you have a working `EventSource` available. If you are targeting a browser that doesn't support it, such as IE or Edge, you'll need to use a [polyfill for EventSource](https://github.com/Yaffle/EventSource).\n\n## Configuration\n\nLike the [`EventSource`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/EventSource#Syntax), the constructor takes an optional configuration object: `new ReconnectingEventSource(url, configuration)`. The configuration object is passed through to the underlying `EventSource` and can optionally include the following configuration:\n\n```json5\n{\n    // indicating if CORS should be set to include credentials, default `false`\n    withCredentials: false,\n\n    // the maximum time to wait before attempting to reconnect in ms, default `3000`\n    // note: wait time is randomised to prevent all clients from attempting to reconnect simultaneously\n    max_retry_time: 3000,\n}\n\n```\n\n\n## Building from source\n\nIf you wish to build this project, check out this repository and modify the source files in `src/`. Then, run the following command:\n\n```sh\nnpm run build\n```\n\nThe resulting files are in `lib/` for the node build and `dist/` for the browser build.\n\n## When does the normal `EventSource` not reconnect?\n\nTypically, the normal `EventSource` only reconnects if it is unable to reach the server at all. However, if the server is reached and it responds with an error (e.g. 500 status), then `EventSource` will stop reconnecting.\n\n## Why reconnect if the server responds with an error?\n\nSome errors, such as 502, are probably temporary, and ideally wouldn't cause client apps to break and require user intervention to get them started again.\n\n## So this thing reconnects forever. How do I make it stop?\n\nThe client has to explicitly stop by calling `es.close()`. If you want to control this from the server, have the server send some kind of close instruction for the client to act on.\n","readmeFilename":"README.md"}