npm.io
0.0.4 • Published 13 years ago

serversentevents

Licence
MIT
Version
0.0.4
Deps
0
Vulns
0
Weekly
0

Build Status

serversentevents

Lightweight tool for building strings for Server-Sent Events.

Usage

Create a string like this:

var sse = require('serversentevents').sse

var s = sse()
  .event('update')
  .data({ prop : 'something' }) // serialized to JSON
  .id(57)
  .retry(10000)
  .comment('a comment')
  .toString()

// event:update
// id:57
// retry:10000
// comment:a comment
// data:{"prop":"something"}

Then pass it along to res.write().

Check out the examples folder for a full server and client example.

License

MIT

Keywords