0.2.3 • Published 2 years ago

workersocket v0.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

workersocket

A WebSocket that runs in a Web Worker.

Published as an ES module only.

Node.js

Web Workers are not available in Node.js. As a fallback, this module will return a ws object. This is intended to support both dual browser/node libraries and browser libraries that run unit tests in Node.

Deps

  • ws to support use with Node. Adds nothing to a browser bundle.

Example

This library strives to be as similar to the WebSocket API as possible.

import { WorkerSocket } from "workersocket";

const socket = new WorkerSocket("ws://echo.websocket.events");

socket.onmessage = (event) => {
  console.log(event.data);
  socket.close();
};

socket.send("Hello, world!");
0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago