# @ont-community/html5-websocket

> HTML5 WebSocket for node.js

Latest version **2.0.3** (published 2018-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ont-community/html5-websocket
pnpm add @ont-community/html5-websocket
yarn add @ont-community/html5-websocket
bun add @ont-community/html5-websocket
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2018-07-23 |
| First published | 2018-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Pedro Ladaria |
| Maintainers | backslash47 |
| Keywords | html5, websocket, node.js, facade, interface, eventtarget, es6, webapi, web, api |

## Links

- npm: https://www.npmjs.com/package/@ont-community/html5-websocket
- Repository: https://github.com/OntologyCommunityDevelopers/html5-websocket
- Homepage: https://github.com/OntologyCommunityDevelopers/html5-websocket#readme
- Issues: https://github.com/OntologyCommunityDevelopers/html5-websocket/issues
- npm.io page: https://npm.io/package/@ont-community/html5-websocket

## Dependencies (1)

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

## 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

- 2.0.3 (latest) — 2018-07-23

## README

# html5-websocket

This module implements the standard [HTML5 WebSocket API](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) as a thin layer over the great [ws](https://www.npmjs.com/package/ws) library.

The motivation behind this module is to be able to write WebSocket based libraries that will run without changes in Node.js, Browsers or React Native apps.

## Install

```bash
npm install --save @ont-community/html5-websocket
```

## Usage

The API is the same as the standard HTML5 Socket API so nothing new here...

```javascript
const WebSocket = require('@ont-community/html5-websocket');

const ws = new WebSocket('ws://html5rocks.websocket.org/echo');

ws.onopen = function () {
    ws.send('Hello!');
};

ws.onmessage = function (e) {
    console.log(e.data);
};

ws.onerror = function (error) {
    console.log('Fail:', error);
};
```

You can also use the DOM Level 2 Event Model

```javascript
const handleMessage = function (e) {
    console.log(e.data);
};

// add listener
ws.addEventListener('message', handleMessage);

// remove listener
ws.removeEventListener('message', handleMessage);
```

## License

MIT

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