close
Skip to main content
This release is versions behind 0.28.8 — the latest version of @xpr/jsocket.

@xpr/jsocket@0.28.6
Built and signed on GitHub Actions

Works with
This package works with Node.js, Deno, Bun
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score94%
Publisheda year ago (0.28.6)

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

import read from "@xpr/jsocket/read";

const stream = getReadableStream();
const data = await read(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:

import createServer from "@xpr/jsocket/server";

await createServer("/tmp/my-socket", async (buf: string) => {
   return buf.toUpperCase();
});

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

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@xpr/jsocket

Import symbol

import * as jsocket from "@xpr/jsocket";
or

Import directly with a jsr specifier

import * as jsocket from "jsr:@xpr/jsocket";