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
Read and write stream. Supports ReadableStream, WritableStream, and Node.js streams.
This package provides a simple way to create a server/client communication (request/response method) using unix sockets.
The package supports both Deno and Node.js.
Installation
deno add jsr:@xpr/jsocket npm i @xpr/jsocket
Read and write data from streams.
All read and write operations are throttled to avoid memory exhaustion.
Examples
read from a readable stream
read from a 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!
Deno version.
Built and signed on
GitHub Actions
Add Package
deno add jsr:@xpr/jsocket
Import symbol
import * as jsocket from "@xpr/jsocket";
Import directly with a jsr specifier
import * as jsocket from "jsr:@xpr/jsocket";