# as-websocket

> WebSocket bindings for AssemblyScript

Latest version **1.1.2** (published 2021-04-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install as-websocket
pnpm add as-websocket
yarn add as-websocket
bun add as-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 | 1.1.2 |
| Published | 2021-04-27 |
| First published | 2021-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 150.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | JairusSW |
| Maintainers | slicewire-dev |
| Keywords | WebSocket, assemblyscript, socket, bindings, ws |

## Links

- npm: https://www.npmjs.com/package/as-websocket
- Repository: https://github.com/JairusSW/as-ws
- Homepage: https://github.com/JairusSW/as-ws#readme
- Issues: https://github.com/JairusSW/as-ws/issues
- npm.io page: https://npm.io/package/as-websocket

## Dependencies (1)

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

## 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.2 (latest) — 2021-04-27
- 1.1.1 — 2021-04-27
- 1.1.0 — 2021-04-27
- 1.0.9 — 2021-04-03
- 1.0.8 — 2021-04-02
- 1.0.7 — 2021-03-31
- 1.0.5 — 2021-03-31
- 1.0.4 — 2021-03-31
- 1.0.3 — 2021-03-31
- 1.0.2 — 2021-03-31
- 1.0.1 — 2021-03-31
- 1.0.0 — 2021-03-30

## README

# As-WebSocket
**WebSocket bindings for AssemblyScript**

## Setting up

**Add --exportTable and --exportRuntime flags**

```js

+ const asWebSocket = require('as-websocket')

+ const ws = new asWebSocket()

const imports = {
    ...ws.wasmImports
}

const wasmModule = loader.instantaniateSync()

+ ws.wasmExports = wasmModule.exports

```

## Usage

**AssemblyScript WebSocket**

```js
import { WebSocket } from 'as-ws'

const socket = new WebSocket('ws://localhost:3000')

socket.on('message', (data) => {

    console.log('Message: ' + data)

})

socket.on('listening', () => {

    console.log('Listening')

})

socket.send('Hello From AssemblyScript!')

```

**Browser**

```html
<script src="https://unpkg.com/as-websocket@latest/browser.js"></script>
```

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