
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
sse-transform
Advanced tools
A transform stream for converting JavaScript objects or JSON streams into Server-Sent Events. Only known fields (including comments) are processed and all other fields are ignored.
In default mode JSON objects are delimited using CrLf (\r\n). Each encountered
JSON object is parsed and transformed into SSE format. If a JSON object isn't able
to be parsed an error event is emitted on the stream and no transform is performed.
'use strict';
var sse = require('sse-transform');
var through = require('through2');
var xform = sse();
xform.pipe(through(function (chunk, encoding, done) {
console.log(chunk.toString('utf8'));
done();
}));
xform.write('{"data":"foo"}\r\n');
xform.write('{"id":123,"data":"abc"}\r\n');
xform.write('{"event":"myevent","data":"foo\\nbar"}\r\n');
xform.write('{"event":"myevent2","data":"moo\\nmar"}\r\n');
xform.end();
data:foo
id:123
data:abc
event:myevent
data:foo
data:bar
event:myevent2
data:moo
data:mar
In object mode each field processed such that if it is a string, newline delimiting rules
are applied and each newline results in a new field entry (see data fields below). If a
non-string-literal is encountered, the value is JSON.stringified during transform.
'use strict';
var sse = require('sse-transform');
var through = require('through2');
var xform = sse({ objectMode: true });
xform.pipe(through(function (chunk, encoding, done) {
console.log(chunk.toString('utf8'));
done();
}));
xform.write({ data: 'foo'});
xform.write({ id:123, data: 'abc' });
xform.write({ event: 'myevent', data: 'foo\nbar' });
xform.write({ event: 'myevent2', data: 'moo\nmar' });
xform.write({ event: 'myevent', data: { foo: true, bar: 123, baz: 'foo\nbar' }});
xform.end();
data:foo
id:123
data:abc
event:myevent
data:foo
data:bar
event:myevent2
data:moo
data:mar
event:myevent
data:{"foo":true,"bar":123,"baz":"foo\nbar"}
The JSON or JavaScript object written to the stream can contain any properties, but only the following will be consumed
by sse-transform, any other being ignored.
event - An event can contain any character besides carriage return or line feed. If the value contains a carriage return or
line feed, the value is split on that character and the first segment used as the value.
data - The data field can include any string, including strings with carriage returns and/or line feeds. If the string contains
newline characters, the string is split and multiple data fields are written per the SSE specification.
id - An id can contain any character besides carriage return or line feed. If the value contains a carriage return or
line feed, the value is split on that character and the first segment used as the value.
retry - Per the Mozilla docs: "The reconnection time to use when attempting to send the event. This must be an integer,
specifying the reconnection time in milliseconds. If a non-integer value is specified, the field is ignored."
$comment - Setting this property to include a comment in the event (any line starting with :). Comments can be used for keep-alives, etc.
FAQs
A transform stream for converting JavaScript objects to Server-Sent Events.
We found that sse-transform demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.