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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    1,012
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    1,012
  • 0.0.5
    1
  • 0.0.4
    1
  • 0.0.3
    1
  • 0.0.2
    1
  • 0.0.1
    1

Package Sidebar

Install

npm i cross-eventsource

Weekly Downloads

1,017

Version

1.0.0

License

(MIT OR Apache-2.0)

Unpacked Size

2.47 kB

Total Files

8

Last publish

Collaborators

  • ukstv