Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!");

Releases

Packages

Used by

Contributors

Languages