Socket
Book a DemoInstallSign in
Socket

es-sse

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es-sse

A Server-Sent Events (SSE) parsing library built with modern design patterns

1.0.5
latest
Source
npmnpm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
ย 
Created
Source

es-sse

A Server-Sent Events (SSE) parsing library built with modern design patterns

License npm version TypeScript

Features

  • ๐Ÿ”„ Modern SSE parsing implementation
  • ๐Ÿ›ก๏ธ TypeScript support
  • ๐Ÿงช Comprehensive test coverage
  • ๐Ÿš€ Zero dependencies
  • ๐Ÿ“ฆ Lightweight and fast

Installation

# npm
npm install es-sse

# pnpm
pnpm add es-sse

# yarn
yarn add es-sse

Usage

import { parseSSE } from 'es-sse';

// Parse a single event
const eventChunk = 'event: test-event\ndata: test-data\n\n';
const result = parseSSE(eventChunk);

// Result will be:
// {
//   data: [{
//     event: 'test-event',
//     data: 'test-data'
//   }],
//   restString: ''
// }

// Handle incomplete events with restString
let buffer = '';
const chunks = [
  'event: first\ndata: first-data\n\nevent: second\ndata: second-data\n\nevent: third\ndata: third',
  '-data\n\n'
];

// Process chunks
for (const chunk of chunks) {
  buffer += chunk;
  const result = parseSSE(buffer);
  
  // Process complete events
  for (const event of result.data) {
    console.log('Received event:', event);
  }
  
  // Keep the rest for next iteration
  buffer = result.restString;
}

// Final buffer state
console.log('Remaining buffer:', buffer); // Should be empty

Keywords

sse

FAQs

Package last updated on 10 Jun 2025

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.