Skip to content
/ socket Public

A promise-based Websocket implementation

License

Notifications You must be signed in to change notification settings

typable/socket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

socket

A promise-based WebSocket implementation

import {Socket} from '...';

const socket = new Socket('ws://localhost');
await socket.connect();

const packet = await socket.send({ command: 'echo', arguments: ['Hello World!'] });
console.log(packet.message); // Hello World!

for await (const packet of socket.listen({ command: 'record', arguments: ['kitten.mp4'] })) {
    const {status, size, time} = packet;
    console.log(`[${status}] ${size}MB ${time}s`); // [recording] 240MB 00:02:05s 
}

About

A promise-based Websocket implementation

Topics

Resources

License

Stars

Watchers

Forks