{"_id":"sse-stream","_rev":"4215456","name":"sse-stream","description":"expose html5 server sent events (sse) as a writable stream","dist-tags":{"latest":"0.0.5"},"maintainers":[{"name":"chrisdickinson","email":""}],"time":{"modified":"2026-03-04T17:10:02.000Z","created":"2012-11-17T22:49:11.510Z","0.0.5":"2016-10-28T08:55:16.529Z","0.0.4":"2013-09-25T00:01:08.570Z","0.0.2":"2013-03-29T05:50:58.629Z","0.0.1":"2013-03-29T05:49:07.634Z","0.0.0":"2012-11-17T22:49:11.510Z"},"users":{},"author":{"name":"Chris Dickinson","email":"chris@neversaw.us"},"repository":{"type":"git","url":"git://github.com/chrisdickinson/sse-stream.git"},"versions":{"0.0.5":{"name":"sse-stream","version":"0.0.5","description":"expose html5 server sent events (sse) as a writable stream","main":"index.js","dependencies":{"through":"~2.2.7"},"devDependencies":{},"browser":{"index.js":"browser.js"},"scripts":{"test":"node test/index.js"},"repository":{"type":"git","url":"git://github.com/chrisdickinson/sse-stream.git"},"keywords":["sse","eventsource","stream","writable"],"author":{"name":"Chris Dickinson","email":"chris@neversaw.us"},"license":"MIT","gitHead":"bfd485cb31ddf40167c8ec2d2e3cdd749ada3283","bugs":{"url":"https://github.com/chrisdickinson/sse-stream/issues"},"homepage":"https://github.com/chrisdickinson/sse-stream#readme","_id":"sse-stream@0.0.5","_shasum":"e003bec368259ee1474bd837b6c7cfeec291162e","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"chrisdickinson","email":"chris@neversaw.us"},"dist":{"shasum":"e003bec368259ee1474bd837b6c7cfeec291162e","size":4126,"noattachment":false,"key":"/sse-stream/-/sse-stream-0.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/sse-stream/download/sse-stream-0.0.5.tgz"},"maintainers":[{"name":"chrisdickinson","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/sse-stream-0.0.5.tgz_1477644912164_0.3592996292281896"},"directories":{},"publish_time":1477644916529,"_hasShrinkwrap":false,"_cnpm_publish_time":1477644916529,"_cnpmcore_publish_time":"2021-12-17T03:26:28.047Z"},"0.0.4":{"name":"sse-stream","version":"0.0.4","description":"expose html5 server sent events (sse) as a writable stream","main":"index.js","dependencies":{"through":"~2.2.7"},"devDependencies":{},"browser":{"index.js":"browser.js"},"scripts":{"test":"node test/index.js"},"repository":{"type":"git","url":"git://github.com/chrisdickinson/sse-stream.git"},"keywords":["sse","eventsource","stream","writable"],"author":{"name":"Chris Dickinson","email":"chris@neversaw.us"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/chrisdickinson/sse-stream/issues"},"_id":"sse-stream@0.0.4","dist":{"shasum":"81da2fe15c5400e68248df3d1d0ce0207b87ff1f","size":4148,"noattachment":false,"key":"/sse-stream/-/sse-stream-0.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/sse-stream/download/sse-stream-0.0.4.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"chrisdickinson","email":"chris@neversaw.us"},"maintainers":[{"name":"chrisdickinson","email":""}],"directories":{},"publish_time":1380067268570,"_hasShrinkwrap":false,"_cnpm_publish_time":1380067268570,"_cnpmcore_publish_time":"2021-12-17T03:26:28.228Z"},"0.0.2":{"name":"sse-stream","version":"0.0.2","description":"expose html5 server sent events (sse) as a writable stream","main":"index.js","dependencies":{"through":"~2.2.7"},"devDependencies":{},"browser":{"index.js":"browser.js"},"scripts":{"test":"node test/index.js"},"repository":{"type":"git","url":"git://github.com/chrisdickinson/sse-stream.git"},"keywords":["sse","eventsource","stream","writable"],"author":{"name":"Chris Dickinson","email":"chris@neversaw.us"},"license":"MIT","readmeFilename":"README.md","_id":"sse-stream@0.0.2","dist":{"shasum":"404ed7ea8fb5ffba6edb7656b982f02e94c3e984","size":4135,"noattachment":false,"key":"/sse-stream/-/sse-stream-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/sse-stream/download/sse-stream-0.0.2.tgz"},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"chrisdickinson","email":"chris@neversaw.us"},"maintainers":[{"name":"chrisdickinson","email":""}],"directories":{},"publish_time":1364536258629,"_hasShrinkwrap":false,"_cnpm_publish_time":1364536258629,"_cnpmcore_publish_time":"2021-12-17T03:26:28.423Z"},"0.0.1":{"name":"sse-stream","version":"0.0.1","description":"expose html5 server sent events (sse) as a writable stream","main":"index.js","dependencies":{"through":"~2.2.7"},"devDependencies":{},"browser":{"./index.js":"./browser.js"},"scripts":{"test":"node test/index.js"},"repository":{"type":"git","url":"git://github.com/chrisdickinson/sse-stream.git"},"keywords":["sse","eventsource","stream","writable"],"author":{"name":"Chris Dickinson","email":"chris@neversaw.us"},"license":"MIT","readmeFilename":"README.md","_id":"sse-stream@0.0.1","dist":{"shasum":"4917f23ff87ad154355f8ec7884eb3f5612418ba","size":4137,"noattachment":false,"key":"/sse-stream/-/sse-stream-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/sse-stream/download/sse-stream-0.0.1.tgz"},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"chrisdickinson","email":"chris@neversaw.us"},"maintainers":[{"name":"chrisdickinson","email":""}],"directories":{},"publish_time":1364536147634,"_hasShrinkwrap":false,"_cnpm_publish_time":1364536147634,"_cnpmcore_publish_time":"2021-12-17T03:26:28.594Z"},"0.0.0":{"name":"sse-stream","version":"0.0.0","description":"expose html5 server sent events (sse) as a writable stream","main":"index.js","dependencies":{},"devDependencies":{},"scripts":{"test":"node test/index.js"},"repository":{"type":"git","url":"git://github.com/chrisdickinson/sse-stream.git"},"keywords":["sse","eventsource","stream","writable"],"author":{"name":"Chris Dickinson","email":"chris@neversaw.us"},"license":"MIT","_id":"sse-stream@0.0.0","dist":{"shasum":"7782a8859b6008c4ead8e67a117b9935427e22cf","size":3991,"noattachment":false,"key":"/sse-stream/-/sse-stream-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sse-stream/download/sse-stream-0.0.0.tgz"},"maintainers":[{"name":"chrisdickinson","email":""}],"directories":{},"publish_time":1353192551510,"_hasShrinkwrap":false,"_cnpm_publish_time":1353192551510,"_cnpmcore_publish_time":"2021-12-17T03:26:28.776Z"}},"readme":"# sse-stream\n\nExpose [HTML5 Server Sent Events](https://developer.mozilla.org/en-US/docs/Server-sent_events/Using_server-sent_events) as an installable appliance on Node.JS `http` servers; connections are emitted as [Writable streams](https://github.com/dominictarr/stream-spec/blob/master/stream_spec.md#writablestream).\n\n```javascript\n\nvar http = require('http')\n  , fs = require('fs')\n  , through = require('through')\n  , sse = require('sse-stream')('/sse')\n  , serv\n\nmodule.exports = serv = http.createServer(function(req, resp) {\n  resp.setHeader('content-type', 'text/html')\n  resp.end('<html><body><script type=\"text/javascript\">('+js+')()</script></body></html>')\n})\n\nsse.install(serv)\n\nsse.on('connection', function(client) {\n  fs.createReadStream('/usr/share/dict/words')\n    .pipe(through(function(buf) { this.emit('data', buf.toString()) }))\n    .pipe(client)\n})\n\n// client-side code:\nfunction js() {\n  var es = new EventSource('/sse')\n    , pre = document.createElement('pre')\n    , closed = false\n\n  document.body.appendChild(pre)\n\n  es.onmessage = function(ev) {\n    if(closed) return\n\n    pre.appendChild(document.createTextNode(ev.data))\n\n    window.scrollTo(0, pre.clientHeight)\n  }\n\n  es.addEventListener('end', function() {\n    es.close()\n    closed = true\n  }, true)\n\n  es.onerror = function(e) {\n    closed = true\n  }\n}\n\n```\n\n# API\n\n### sse = require('sse-stream')(path | options)\n\nCreate a SSE server that emits `connection` events on new, successful eventstream connections.\n\nThe argument may either be a string `path` to listen on (defaults to `/sse/`) or an object:\n\n```javascript\n{ path: '/listen/on/this/path'\n, keepalive: 1000 }\n``` \n\n`keepalive` determines the interval time in ms that keepalives will be sent to all connected clients.\n\n### sse.on('connection', function(client))\n\n`client` is a writable stream representing a client connection (request response pair).\n\nOf note, all data sent through this connection will be stringified before sending due to\nthe event stream spec.\n\n### client.retry(integer ms)\n\nSend a \"retry\" message that lets the client know how many MS to wait until retrying a connection that ended.\n\n# license\n\nMIT\n","_attachments":{},"homepage":"https://github.com/chrisdickinson/sse-stream#readme","bugs":{"url":"https://github.com/chrisdickinson/sse-stream/issues"},"license":"MIT"}