# bs-ws

> ws bindings for Reason

Latest version **1.1.4** (published 2020-02-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install bs-ws
pnpm add bs-ws
yarn add bs-ws
bun add bs-ws
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2020-02-19 |
| First published | 2018-05-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | kfish610 |
| Maintainers | kfish610 |
| Keywords | bucklescript, bs, reason, reasonml, websocket, websockets, ws, node |

## Links

- npm: https://www.npmjs.com/package/bs-ws
- Repository: https://github.com/kfish610/bs-ws
- Issues: https://github.com/kfish610/bs-ws/issues
- npm.io page: https://npm.io/package/bs-ws

## Dependencies (1)

- [ws](https://npm.io/package/ws.md) ^7.2.1

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.1.4 (latest) — 2020-02-19
- 1.1.3 — 2020-02-19
- 1.1.2 — 2019-11-08
- 1.1.1 — 2019-03-31
- 1.0.9 — 2018-12-03
- 1.0.8 — 2018-05-19
- 1.0.7 — 2018-05-16
- 1.0.5 — 2018-05-16
- 1.0.4 — 2018-05-16
- 1.0.3 — 2018-05-15
- 1.0.2 — 2018-05-15
- 1.0.1 — 2018-05-15
- 1.0.0 — 2018-05-15
- 0.1.0 — 2018-05-15

## README

# bs-ws

Simple node websocket implementation for Reason

[![npm](https://img.shields.io/npm/v/bs-ws.svg)](https://www.npmjs.com/package/bs-ws)

[![GitHub issues](https://img.shields.io/github/issues/kfish610/bs-ws.svg)](https://github.com/kfish610/bs-ws/issues)


# Installation

```
npm install --save bs-ws
```
or
```
npm i -S bs-ws
```

Then add bs-ws to bs-dependencies in your bsconfig.json:
```
{
  ...
  "bs-dependencies": ["bs-ws"]
}
```

# Examples

Simple Example
```
let ws = Ws.WebSocket.make("wss://www.example.com");
Ws.WebSocket.(
ws
-> on(`message((data) => Js.log("Message: " ++ data)))
-> on(`close((code, reason) => Js.log("Closed: " ++ string_of_int(code) ++ reason)))
-> on(`open_(() => Js.log("Opened!")))
-> on(`error(error => Js.log("Error: " ++ Ws.ErrorEvent.message(error))))
);
```

Example with subprotocols
```
let ws = Ws.WebSocket.makeWithProtocols("wss://www.example.com", [| "soap" |]);
Ws.WebSocket.(
ws
-> on(`message((data) => Js.log("Message: " ++ data)))
-> on(`close((code, reason) => Js.log("Closed: " ++ string_of_int(code) ++ reason)))
-> on(`open_(() => Js.log("Opened!")))
-> on(`error(error => Js.log("Error: " ++ Ws.ErrorEvent.message(error))))
);
```

Send
```
let ws = Ws.WebSocket.make("wss://www.example.com");
Ws.WebSocket.(
ws
-> send("Hello World!")
);
```

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