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

1.0.0 • Public • Published

cross-eventsource

Provides EventSource for Node.js and browser.

If in browser, use standard globalThis.EventSource. If in Node.js, use EventSource implementation of eventsource package.

Installation

pnpm add cross-eventsource

Usage

import { EventSource  } from "cross-eventsource";

// And then use it like in a browser
const source = new EventSource('http://localhost/feed')
source.addEventListener('message', (event) => {
  console.log('message', event)
})
source.addEventListener('error', error => {
  console.log('error', error)
})
console.log('listening...')

Readme

Keywords

Package Sidebar

Install

npm i cross-eventsource

Weekly Downloads

686

Version

1.0.0

License

(MIT OR Apache-2.0)

Unpacked Size

2.47 kB

Total Files

8

Last publish

Collaborators

  • ukstv