Nucleic Phosphate Modifier

    ssestream
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.0 • Public • Published

    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).

    Keywords

    none

    Install

    npm i ssestream

    DownloadsWeekly Downloads

    2,162

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    22.2 kB

    Total Files

    15

    Last publish

    Collaborators

    • aslakhellesoy