This release is versions behind 0.28.8 — the latest version of @xpr/jsocket.
Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
Works with
•JSR Score94%•This package works with Node.js, Deno, Bun


Downloads1/wk
•Publisheda year ago (0.25.0)
Read and write stream. Supports ReadableStream, WritableStream, and Node.js streams.
Examples
read from any readable stream
read from any readable stream
import { read } from "@xpr/jsocket/read"; const stream = getReadableStream(); const data = await read(stream);
write to any writable stream
write to any writable stream
import { write } from "@xpr/jsocket/write"; const stream = getWritableStream(); await write(stream, data);
Creating a Unix socket server and client
example server:
example server:
import createServer from "@xpr/jsocket/server"; await createServer("/tmp/my-socket", async (buf: string) => { return buf.toUpperCase(); });
example client:
example client:
import request from "@xpr/jsocket/request"; const response = await request("/tmp/my-socket", "Hello, world!"); console.log(response); // HELLO, WORLD!
Functions
f
client<B extends ValueType, R extends ValueType>(): Promise<R>
path: string,
body: B
Create a Unix socket client and make a request.
f
read(stream: ReadableStream<Uint8Array>): Promise<Uint8Array>
Read data from a readable stream. Reads until the stream is closed or an EOF byte is encountered.
f
server(): UnixTransportServer<Deno.Listener>
path: string,
handler: ConnectionHandler
Create and start listening to Unix socket server.
f
write(): Promise<void>
stream: WritableStream<Uint8Array>,
data: Uint8Array
Write data to a writable stream in chunks of 1024 bytes.