Skip to main content
The Deno 2 Release Candidate is here
Learn more

wsi

Asynchronously iterate over WebSocket events.

import iterable from "https://deno.land/x/wsi/mod.ts";

const socket = new WebSocket("wss://echo.websocket.events");

for await (const event of iterable(socket)) {
    console.log(event.data);
    socket.send("hello");
}