New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ssestream

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssestream

Send Server-Sent Events with a stream

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
6.5K
21.31%
Maintainers
1
Weekly downloads
 
Created
Source

SseStream

A zero-dependency node stream for writing Server-Sent Events.

Installation

npm install ssestream

Or:

yarn add ssestream

Usage

In a (req, res) handler for a request event, Express #get route or similar:

const SseStream = require('ssestream')

function (req, res) {
  const sse = new SseStream(req)
  sse.pipe(res)
  
  const message = {
    data: 'hello\nworld',
  }
  sse.write(message)
}

Properties on message:

  • data - String or object, which gets turned into JSON
  • event - (optional) String
  • id - (optional) String
  • retry - (optional) number
  • comment - (optional) String

TypeScript

The SseStream#writeMessage(message) method is a type-safe alias for SseStream#write(message).

FAQs

Package last updated on 17 Mar 2020

Did you know?

Socket

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.

Install

Related posts