# cross-eventsource

> EventSource for Node.js and Browser

Latest version **1.0.0** (published 2024-01-10) · (MIT OR Apache-2.0) license · 0 weekly downloads

## Install

```sh
npm install cross-eventsource
pnpm add cross-eventsource
yarn add cross-eventsource
bun add cross-eventsource
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2024-01-10 |
| First published | 2024-01-10 |
| Weekly downloads | 0 |
| License | (MIT OR Apache-2.0) |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 2 |
| Unpacked size | 2.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sergey Ukustov |
| Maintainers | ukstv |
| Keywords | eventsource |

## Links

- npm: https://www.npmjs.com/package/cross-eventsource
- npm.io page: https://npm.io/package/cross-eventsource

## Dependencies (2)

- [eventsource](https://npm.io/package/eventsource.md) ^2.0.2
- [@types/eventsource](https://npm.io/package/@types/eventsource.md) ^1.1.15

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2024-01-10
- 0.0.5 — 2024-01-10
- 0.0.4 — 2024-01-10
- 0.0.3 — 2024-01-10
- 0.0.2 — 2024-01-10
- 0.0.1 — 2024-01-10

## README

# cross-eventsource

Provides [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) for Node.js and browser.

If in browser, use standard `globalThis.EventSource`. If in Node.js, use EventSource implementation
of [eventsource package](https://www.npmjs.com/package/eventsource).

## Installation

```shell
pnpm add cross-eventsource
```

## Usage

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

---
_Source: https://npm.io/package/cross-eventsource · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
