# hypercast

> Client looks like this.

Latest version **0.2.1** (published 2023-03-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install hypercast
pnpm add hypercast
yarn add hypercast
bun add hypercast
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2023-03-03 |
| First published | 2022-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 74.5 KB |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| Author | estrattonbailey |
| Maintainers | estrattonbailey |

## Links

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

## Dependencies (2)

- [nanoid](https://npm.io/package/nanoid.md) ^4.0.0
- [smitter](https://npm.io/package/smitter.md) ^1.1.1

## Recent versions

- 0.2.1 (latest) — 2023-03-03
- 0.2.0 — 2023-03-02
- 0.1.0 — 2023-02-28
- 0.0.6 — 2023-02-28
- 0.0.5 — 2023-01-28
- 0.0.4 — 2023-01-28
- 0.0.3 — 2023-01-21
- 0.0.2 — 2023-01-20
- 0.0.1 — 2023-01-18
- 0.0.0 — 2022-12-02

## README

# hypercast

Client looks like this.

```typescript
// client.ts
import { Operator, Hypercast } from 'hypercast/client'

enum MessageType {
  Hello = 'hello',
  Goodbye = 'goodbye',
}

type Messages =
  | {
      type: MessageType.Hello
      name: string
    }
  | {
      type: MessageType.Goodbye
      name: string
    }

const operator = new Operator()
const { topic } = await operator.createTopic()
const hypercast = new Hypercast(topic)

hypercast.on('message', (event) => {
  switch (event.data.type) {
    case MessageType.Hello:
      console.log(`Hello ${event.data.name}`)
    case MessageType.GoodBye:
      console.log(`Hello ${event.data.name}`)
    default:
      console.log(`Unknown message type`)
  }
})

await hypercast.connect()
```

Then, to send a message:

```typescript
const ack = hypercast.send({
  type: MessageType.Hello,
  name: 'Cloudflare',
})

// optional
await ack
```

## Self Hosting a Hypercast Instance

Server looks like this, plus a little Wrangler config for the Durable Object.

```typescript
// worker.ts
import { Operator } from 'hypercast/server'
export { Hypercast } from 'hypercast/server'
export default new Operator('/hypercast') // pathname, if any
```

And when creating your client, you need to pass in your URL:

```typescript
const hypercast = new Hypercast(topic, 'https://esb.lol/hypercast')
```

Or:

```typescript
const operator = new Operator('https://esb.lol/hypercast')
```

That's the whole thing.

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