Nuclear Powered Marshmallows


    1.2.0 • Public • Published


    Windows Mac/Linux
    Windows Build status Build Status

    Serializing and parsing Object Streams for server sent events using the EventSource api.

    On the server side use ssejson.serialize() to turn the objectstream to sse, on the (browser) client use ssejson.fromEventSource() to parse it back to an objectstream.

    The format is pretty simple each object chunk is encoded as JSON as the name suggests and serialized and parsed by the module.

    Serialize Example

    var http = require('http')
    var fs = require('fs')
    var ssejson = require('ssejson')
    var csv = require('csv-parser')
    http.createServer(function (req, res) {

    The serializer allows an options object to be passed as the first argument. There you can specify an event attribute and it will use the name you specify there instead of sending unnamed messages.

    fromEventSource Example

    For the Use with the browser EventSource api, but should also work with compliant replacements like the eventsource module.

    The second argument is optional and declares the name of the event. Without specifying it defaults to unnamed messages.

    var htmltable = require('htmltable')
    var ssejson = require('ssejson')
    ssejson.fromEventSource(new EventSource('/'), 'data')

    Parse Example

    If you have access to the raw sse you can parse it this way. You can specify the event option to parse named events.

      var request = require('request')
      var ssejson = require('ssejson')
        .on('data', function (row) {


    npm i ssejson

    DownloadsWeekly Downloads






    Last publish


    • finnpauls