Skip to main content
Home

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

Read and write stream. Supports ReadableStream, WritableStream, and Node.js streams.

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 Score
94%
Published
6 months ago (0.28.8)

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

New Ticket: 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";

Add Package

pnpm i jsr:@xpr/jsocket
or (using pnpm 10.8 or older)
pnpm dlx jsr add @xpr/jsocket

Import symbol

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

Add Package

yarn add jsr:@xpr/jsocket
or (using Yarn 4.8 or older)
yarn dlx jsr add @xpr/jsocket

Import symbol

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

Add Package

vlt install jsr:@xpr/jsocket

Import symbol

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

Add Package

npx jsr add @xpr/jsocket

Import symbol

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

Add Package

bunx jsr add @xpr/jsocket

Import symbol

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