open-index/open-npm huggingface dataset:
npm package: @jsonjoy.com/base64
Description: High-performance Base64 encoder and decoder
Author: streamich
Latest version: 18.10.0

# Base64

Fast Base64 encoder and decoder for browser and Node.js.

## Encoder

- Implements Base64 encoding algorithm compatible with Node's Buffer.
- Isomorphic&mdash;it can be used in, both, Node and the browser.
- Faster than the Node's implementation for short blobs, smaller than 40 bytes.
- Uses Node's implementation for long blobs, if available. Hence, it also works
  in browser, but in Node environment will perform faster for short strings.
- Can encode into Base64 text or Base64 `Uint8Array`.


### Usage

Use encoder compatible with Node's Buffer:

```ts
import {toBase64} from '@jsonjoy.com/base64';

toBase64(new Uint8Array([1, 2, 3]));
```

Create your custom encoder:

```ts
import {createToBase64} from '@jsonjoy.com/base64';

const encode = createToBase64('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_');

encode(new Uint8Array([1, 2, 3]));
```


### Benchmark

Below benchmark encodes random binary blobs of sizes 8, 16, 32, 64, 128, 256, 512, and 1024 byes.
`@jsonjoy.com/base64` is faster, because for short strings (less than 40 chars) it uses a
native JavaScript implementation, which is faster and also works in browsers. For blobs larger
than 40 chars, it falls back to Node `Buffer` implementation, if available.

Encoding:

```
node src/__bench__/encode.js
util/base64 toBase64(uint8) x 1,531,283 ops/sec ±0.30% (92 runs sampled), 653 ns/op
util/base64 createToBase64()(uint8) x 946,364 ops/sec ±0.76% (100 runs sampled), 1057 ns/op
js-base64 x 1,103,190 ops/sec ±1.27% (96 runs sampled), 906 ns/op
fast-base64-encode x 500,225 ops/sec ±0.64% (96 runs sampled), 1999 ns/op
base64-js x 328,368 ops/sec ±0.25% (95 runs sampled), 3045 ns/op
Buffer.from(uint8).toString('base64'); x 1,099,420 ops/sec ±0.20% (100 runs sampled), 910 ns/op
Fastest is util/base64 toBase64(uint8)
```

Decoding:

```
node src/__bench__/decode.js
@jsonjoy.com/base64 fromBase64(str) x 756,989 ops/sec ±0.46% (97 runs sampled), 1321 ns/op
@jsonjoy.com/base64 createFromBase64()(str) x 475,591 ops/sec ±0.37% (96 runs sampled), 2103 ns/op
Buffer.from(str, 'base64') x 545,012 ops/sec ±0.33% (101 runs sampled), 1835 ns/op
base64-js x 487,015 ops/sec ±1.19% (94 runs sampled), 2053 ns/op
js-base64 x 173,049 ops/sec ±0.20% (99 runs sampled), 5779 ns/op
Fastest is @jsonjoy.com/base64 fromBase64(str)
```


## Decoder

- Uses Node.js built-in `Buffer`, if available.
- When `Buffer` is not available, uses JavaScript implementation.


### Usage

Use decoder compatible with Node's Buffer:

```ts
import {toBase64, fromBase64} from '@jsonjoy.com/base64';

fromBase64(toBase64(new Uint8Array([1, 2, 3])));
```

Create your custom encoder:

```ts
import {createFromBase64} from '@jsonjoy.com/base64';

const decoder = createFromBase64('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_');

decoder(toBase64(new Uint8Array([1, 2, 3])));
```
npm package: @jsonjoy.com/codegen
Description: No-dependencies, low-level, high-performance JIT code generation package for JavaScript
Author: streamich
Latest version: 18.10.0

# @jsonjoy.com/codegen

A no-dependencies, low-level, high-performance JIT code generation package for
JavaScript. This package contains utilities for generating optimized JavaScript
code at runtime. It enables creating high-performance functions by generating
code dynamically based on schemas, templates, or runtime data.

## Features

- **Zero dependencies** - Lightweight and fast to install
- **High performance** - Generates optimized JavaScript functions at runtime
- **Type safe** - Full TypeScript support with comprehensive type definitions
- **Flexible** - Supports various code generation patterns and techniques
- **Production ready** - Battle-tested and optimized for real-world usage

## Use Cases

JIT (Just-In-Time) code generation can provide significant performance improvements
when you have advance knowledge of the data structure or execution pattern.

Some examples:

- **Deep equality comparison function**: When one object is known in advance, we can
  generate an optimized function that efficiently compares against a single object.
  This technique is implemented in the `json-equal` library.

- **JSON Patch execution**: When the JSON Patch operations are known beforehand, we can
  generate an optimized function that applies the patch in the most efficient way.
  This approach is used in the `json-patch` library.

- **Schema-based validation**: Given a `json-type` schema of a JSON object, it's possible
  to generate highly optimized functions for validation and serialization that avoid
  generic overhead and execute significantly faster than traditional approaches.

Other:

- Optimized validation and serialization functions
- Custom function generation based on runtime data
- Performance-critical code that benefits from JIT compilation


## Installation

```bash
npm install @jsonjoy.com/codegen
```

## Quick Start

```typescript
import { Codegen } from '@jsonjoy.com/codegen';

const codegen = new Codegen();
// Add your code generation logic here
const optimizedFunction = codegen.compile();
```

## License

Apache-2.0
npm package: @jsonjoy.com/fs-core
Description: Core filesystem primitives: Node, Link, File, Superblock
Author: streamich
Latest version: 4.57.1

# @jsonjoy.com/fs-core

Core filesystem primitives for building in-memory and virtual filesystems.

## Overview

This package provides the core data structures for representing a virtual filesystem:

- **Node** - Represents an i-node (index node), containing file data and metadata
- **Link** - Represents a hard link pointing to a Node
- **File** - Represents an open file descriptor
- **Superblock** - The root of a virtual filesystem, managing nodes and links

## Installation

```bash
npm install @jsonjoy.com/fs-core
```

## Usage

```typescript
import { Superblock, DirectoryJSON } from '@jsonjoy.com/fs-core';

// Create a new filesystem
const fs = new Superblock();

// Or create from a JSON structure
const json: DirectoryJSON = {
  '/file.txt': 'Hello, World!',
  '/dir/nested.txt': 'Nested content',
};
const fs = Superblock.fromJSON(json);
```
npm package: @jsonjoy.com/fs-fsa
Description: File System Access API implementation backed by core filesystem primitives
Author: streamich
Latest version: 4.57.1

# @jsonjoy.com/fs-fsa

File System Access API implementation backed by `@jsonjoy.com/fs-core` primitives.

Provides a [File System Access API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API)
implementation that works with the `Superblock` filesystem abstraction.

## Installation

```bash
npm install @jsonjoy.com/fs-fsa
```

## Usage

```ts
import { fsa } from '@jsonjoy.com/fs-fsa';

const { dir, core, FileSystemObserver } = fsa({ mode: 'readwrite' });

// Create a file
const fileHandle = await dir.getFileHandle('hello.txt', { create: true });
const writable = await fileHandle.createWritable();
await writable.write('Hello, World!');
await writable.close();

// Read a file
const file = await fileHandle.getFile();
const contents = await file.text();
console.log(contents); // 'Hello, World!'
```

## License

Apache-2.0
npm package: @jsonjoy.com/fs-fsa-to-node
Description: Adapter to convert File System Access API to Node.js fs API
Author: streamich
Latest version: 4.57.1

# @jsonjoy.com/fs-fsa-to-node

Adapter to convert [File System Access API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API) (`FileSystemDirectoryHandle`) to Node.js `fs`-like API.

## Installation

```bash
npm install @jsonjoy.com/fs-fsa-to-node
```

## Usage

```ts
import { FsaNodeFs } from '@jsonjoy.com/fs-fsa-to-node';

// Get a FileSystemDirectoryHandle (e.g., from showDirectoryPicker())
const dirHandle = await window.showDirectoryPicker();

// Create a Node.js fs-like API from the directory handle
const fs = new FsaNodeFs(dirHandle);

// Use familiar Node.js fs API
await fs.promises.writeFile('/test.txt', 'Hello, World!');
const content = await fs.promises.readFile('/test.txt', 'utf8');
console.log(content); // 'Hello, World!'
```

## Features

- Provides Node.js `fs` callback and Promise APIs
- Works with any `FileSystemDirectoryHandle` implementation
- Supports file operations: read, write, append, truncate
- Supports directory operations: mkdir, readdir, rmdir
- Includes read and write streams

## License

[Apache-2.0](LICENSE)
npm package: @jsonjoy.com/fs-node
Description: In-memory filesystem with Node.js fs-compatible API
Author: streamich
Latest version: 4.57.1

# @jsonjoy.com/fs-node

In-memory filesystem with Node.js `fs`-compatible API.

## Installation

```bash
npm install @jsonjoy.com/fs-node
```

## Usage

```ts
import { Volume } from '@jsonjoy.com/fs-node';

const vol = new Volume();
vol.writeFileSync('/hello.txt', 'Hello, World!');
console.log(vol.readFileSync('/hello.txt', 'utf8')); // Hello, World!
```

### Create filesystem from JSON

```ts
import { Volume } from '@jsonjoy.com/fs-node';

const vol = Volume.fromJSON({
  '/app/index.js': 'console.log("Hello");',
  '/app/package.json': '{"name": "app"}',
});

console.log(vol.readdirSync('/app')); // ['index.js', 'package.json']
```

## API

The `Volume` class implements Node.js `fs` module's synchronous and callback APIs:

- `readFile`, `readFileSync`
- `writeFile`, `writeFileSync`
- `mkdir`, `mkdirSync`
- `readdir`, `readdirSync`
- `stat`, `statSync`
- `unlink`, `unlinkSync`
- ... and many more

It also exposes a `promises` property for the Promise-based API:

```ts
const data = await vol.promises.readFile('/hello.txt', 'utf8');
```

## License

Apache-2.0
npm package: @jsonjoy.com/fs-node-to-fsa
Description: Adapter to convert Node.js fs API to File System Access API
Author: streamich
Latest version: 4.57.1

# @jsonjoy.com/fs-node-to-fsa

Adapter to convert [Node.js fs API][node-fs] to [File System Access API][fsa] (FSA).

## Installation

```bash
npm install @jsonjoy.com/fs-node-to-fsa
```

## Usage

```ts
import { nodeToFsa } from '@jsonjoy.com/fs-node-to-fsa';
import * as fs from 'fs';

const dir = nodeToFsa(fs, '/path/to/directory', { mode: 'readwrite' });

// Now use the FSA API
for await (const [name, handle] of dir.entries()) {
  console.log(name, handle.kind);
}
```

## Reference

- [`nodeToFsa(fs, path, ctx)`](src/index.ts) - Converts a Node.js `fs` module to a `FileSystemDirectoryHandle`.

[node-fs]: https://nodejs.org/api/fs.html
[fsa]: https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API
npm package: @jsonjoy.com/fs-print
Description: File system tree printer - print a file system structure as a tree
Author: streamich
Latest version: 4.57.1

# @jsonjoy.com/fs-print

File system tree printer - print a file system structure as a tree.

Provides a simple API to print any filesystem implementing the `FsSynchronousApi` interface
as a formatted tree structure, useful for debugging and visualization.

## Installation

```bash
npm install @jsonjoy.com/fs-print
```

## Usage

```ts
import { toTreeSync } from '@jsonjoy.com/fs-print';
import { memfs } from 'memfs';

const { fs } = memfs({
  '/readme.md': '...',
  '/src/index.ts': '...',
  '/src/util.ts': '...',
});

console.log(toTreeSync(fs));
```

Output:

```
/
├─ src/
│  ├─ index.ts
│  └─ util.ts
└─ readme.md
```

## Options

You can customize the output with options:

```ts
toTreeSync(fs, {
  dir: '/src', // Starting directory (default: '/')
  depth: 2, // Maximum depth to traverse (default: 10)
  separator: '/', // Path separator (default: '/')
  tab: '  ', // Indentation string (default: '')
  sort: true, // Sort entries (default: true)
});
```

## License

Apache-2.0
npm package: @jsonjoy.com/fs-snapshot
Description: File system snapshot - serialize and deserialize file system trees to binary or JSON
Author: streamich
Latest version: 4.57.1

# @jsonjoy.com/fs-snapshot

File system snapshot - serialize and deserialize file system trees to binary (CBOR) or JSON format.

## Installation

```bash
npm install @jsonjoy.com/fs-snapshot
```

## Features

- Serialize entire file system trees into compact binary (CBOR) or JSON snapshots
- Restore file system trees from snapshots
- Supports files, directories, and symbolic links
- Both synchronous and asynchronous APIs
- Works with any Node.js-compatible `fs` module

## Usage

### Synchronous API

```ts
import * as fs from 'fs';
import { toSnapshotSync, fromSnapshotSync } from '@jsonjoy.com/fs-snapshot';

// Create a snapshot of a directory
const snapshot = toSnapshotSync({ fs, path: '/path/to/directory' });

// Restore the snapshot to a different location
fromSnapshotSync(snapshot, { fs, path: '/path/to/restore' });
```

### Asynchronous API

```ts
import * as fs from 'fs';
import { toSnapshot, fromSnapshot } from '@jsonjoy.com/fs-snapshot';

// Create a snapshot of a directory
const snapshot = await toSnapshot({ fs: fs.promises, path: '/path/to/directory' });

// Restore the snapshot to a different location
await fromSnapshot(snapshot, { fs: fs.promises, path: '/path/to/restore' });
```

### Binary (CBOR) Snapshots

Binary snapshots are more compact and faster to serialize/deserialize:

```ts
import * as fs from 'fs';
import { toBinarySnapshotSync, fromBinarySnapshotSync } from '@jsonjoy.com/fs-snapshot';

// Create a binary snapshot
const binary = toBinarySnapshotSync({ fs, path: '/path/to/directory' });

// Restore from binary snapshot
fromBinarySnapshotSync(binary, { fs, path: '/path/to/restore' });
```

### JSON Snapshots

JSON snapshots are human-readable and easier to debug:

```ts
import * as fs from 'fs';
import { toJsonSnapshotSync, fromJsonSnapshotSync } from '@jsonjoy.com/fs-snapshot';

// Create a JSON snapshot
const jsonSnapshot = toJsonSnapshotSync({ fs, path: '/path/to/directory' });

// Restore from JSON snapshot
fromJsonSnapshotSync(jsonSnapshot, { fs, path: '/path/to/restore' });
```

## Snapshot Format

Snapshots are represented as tuples with the following structure:

- **Folder**: `[0, metadata, { entries }]`
- **File**: `[1, metadata, Uint8Array]`
- **Symlink**: `[2, { target: string }]`

## License

Apache-2.0
npm package: @jsonjoy.com/json-pointer
Description: High-performance JSON Pointer implementation
Author: streamich
Latest version: 18.10.0

# JSON Pointer - `json-pointer`

Fast implementation of [JSON Pointer (RFC 6901)][json-pointer]
specification in TypeScript.

[json-pointer]: https://tools.ietf.org/html/rfc6901


## Usage

Can find a value in a JSON object using three methods: (1) JSON Pointer string,
(2) array of steps, or (3) a pre-compiled function.


## Examples

Find the value in a JSON document at some specific location.


### Find by JSON Pointer string

```js
import { findByPointer } from '@jsonjoy.com/json-pointer';

const doc = {
  foo: {
    bar: 123,
  },
};

const res = findByPointer(doc, '/foo/bar');
```


### Find by path array

Alternatively, you can specify an array of steps, such as `['foo', 'bar']`. Or,
use the `parseJsonPointer` function to convert a JSON Pointer string to an array.

```js
import { find, parseJsonPointer } from '@jsonjoy.com/json-pointer';

const doc = {
  foo: {
    bar: 123,
  },
};

const path = parseJsonPointer('/foo/bar');
const ref = find(doc, path);

console.log(ref);
// { val: 123, obj: { bar: 123 }, key: 'bar' }
```


### Pre-compiled function

If you know the path in advance, you can compile a function that will find the
value at that location, it will work few times faster than the previous methods.

```js
import { $$find } from '@jsonjoy.com/json-pointer/lib/codegen';

const doc = {
  foo: {
    bar: 123,
  },
};
const finder = $$find(['foo', 'bar']);

const res = finder(doc);
```


## Low-level API

Convert JSON Pointer to path array and back.

```js
import { parseJsonPointer } from '@jsonjoy.com/json-pointer';

console.log(parseJsonPointer('/f~0o~1o/bar/1/baz'));
// [ 'f~o/o', 'bar', '1', 'baz' ]

console.log(formatJsonPointer(['f~o/o', 'bar', '1', 'baz']));
// /f~0o~1o/bar/1/baz
```

Decode and encode a single step of JSON Pointer.

```js
console.log(unescapeComponent('~0~1'));
// ~/

console.log(escapeComponent('~/'));
// ~0~1
```
npm package: @jsonjoy.com/rpc-client
Description: HTTP and WebSocket client implementations for Reactive JSON RPC.
Author: streamich
Latest version: 18.10.0

# `@jsonjoy.com/rpc-client`

Browser client for Reactive JSON RPC servers.


## Installation

```
npm install @jsonjoy.com/rpc-client
```

## License

Apache-2.0
npm package: @jsonjoy.com/rpc-codec
Description: RPC message codec aggregator for Reactive RPC
Author: streamich
Latest version: 18.10.0

# `@jsonjoy.com/rpc-codec`

Aggregator package for all [JSON Reactive RPC](https://jsonjoy.com/specs/json-rx)
message codecs. Re-exports `RpcCodec`, `RpcCodecs`, `RpcMessageCodecs`, and
`JsonCompactMsgCodec`.

## Usage

```ts
import {RpcCodec, RpcMessageCodecs, RpcCodecs} from '@jsonjoy.com/rpc-codec';
```

## `nominal` codec for Reactive-RPC messages

`nominal` codec specifies, in principle, what messages and what fields exist in
Reactive-RPC protocol.

| No.       | Message                | Message ID   | Method name | Payload    |
|-----------|------------------------|--------------|-------------|------------|
| 1         | Notification            | No           | Yes         | Maybe      |
| 2         | Request Data           | Yes          | Yes         | Yes        |
| 3         | Request Complete       | Yes          | Maybe       | Maybe      |
| 4         | Request Error          | Yes          | Maybe       | Yes        |
| 5         | Request Un-subscribe   | Yes          | No          | No         |
| 6         | Response Data          | Yes          | No          | Yes        |
| 7         | Response Complete      | Yes          | No          | Maybe      |
| 8         | Response Error         | Yes          | No          | Yes        |
| 9         | Response Un-subscribe  | Yes          | No          | No         |
npm package: @jsonjoy.com/rpc-codec-base
Description: Base types and utilities for RPC message codecs
Author: streamich
Latest version: 18.10.0

# `@jsonjoy.com/rpc-codec-base`

Base types and utilities for RPC message codecs. Provides the `MsgStreamCodec`
interface, `MsgCodec` interface, codec format constants, and the `getTypeEncoder`
helper used by all codec implementations.

## Usage

```ts
import {RpcMessageFormat} from '@jsonjoy.com/rpc-codec-base';
import type {MsgStreamCodec} from '@jsonjoy.com/rpc-codec-base';
```
npm package: @jsonjoy.com/rpc-codec-binary
Description: Binary codec for Reactive RPC messages
Author: streamich
Latest version: 18.10.0

# `@jsonjoy.com/rpc-codec-binary`

Binary codec for [JSON Reactive RPC](https://jsonjoy.com/specs/json-rx)
messages. Encodes and decodes RPC messages using the
[binary encoding](https://jsonjoy.com/specs/json-rx/binary-encoding).

## Usage

```ts
import {BinaryMsgStreamCodec} from '@jsonjoy.com/rpc-codec-binary';
```
npm package: @jsonjoy.com/rpc-codec-compact
Description: Compact codec for Reactive RPC messages
Author: streamich
Latest version: 18.10.0

# `@jsonjoy.com/rpc-codec-compact`

Compact codec for [JSON Reactive RPC](https://jsonjoy.com/specs/json-rx)
messages. Encodes and decodes RPC messages using the
[compact JSON encoding](https://jsonjoy.com/specs/json-rx/json-encoding).

## Usage

```ts
import {CompactMsgStreamCodec} from '@jsonjoy.com/rpc-codec-compact';
```
npm package: @jsonjoy.com/rpc-codec-json-rpc-2
Description: JSON-RPC 2.0 codec for Reactive RPC messages
Author: streamich
Latest version: 18.10.0

# `@jsonjoy.com/rpc-codec-json-rpc-2`

JSON-RPC 2.0 codec for [JSON Reactive RPC](https://jsonjoy.com/specs/json-rx)
messages. Encodes and decodes RPC messages using the standard
[JSON-RPC 2.0](https://www.jsonrpc.org/specification) format.

## Usage

```ts
import {JsonRpc2TypedMsgStreamCodec} from '@jsonjoy.com/rpc-codec-json-rpc-2';
```
npm package: @jsonjoy.com/rpc-error
Description: RPC error class and error codes for JSON RPC APIs
Author: streamich
Latest version: 18.10.0

# `@jsonjoy.com/rpc-error`

RPC error class and error codes for JSON Reactive RPC APIs.

## Usage

```ts
import {RpcError, RpcErrorCodes} from '@jsonjoy.com/rpc-error';
```

## `RpcError`

`RpcError` extends `Error` and implements `IRpcError`. It carries a `code`
(string), `errno` (number), optional `errorId`, `meta`, and `originalError`.

### Factory methods

```ts
// Wrap any unknown error as INTERNAL_ERROR
RpcError.from(err);

// Create from a numeric error code
RpcError.fromErrno(RpcErrorCodes.NOT_FOUND, 'Not Found');

// Create from a named error code
RpcError.fromCode('CONFLICT', 'Already exists');

// Create with a fully custom code string
RpcError.create('MY_CODE', 'Something went wrong', 42, meta, cause);

// Convenience factories
RpcError.internal(cause);
RpcError.badRequest('Invalid input', meta);
RpcError.notFound('User not found');
RpcError.validation('Invalid id', meta);
RpcError.conflict('Duplicate key');
```

### Serialization

```ts
const err = RpcError.badRequest('Missing field');
err.toJson();
// { message: 'Missing field', code: 'BAD_REQUEST', errno: 1 }
```

### Type guard

```ts
RpcError.isRpcError(value); // true if value is an RpcError instance
```

## `RpcErrorCodes`

| Name             | Value | HTTP equivalent |
|------------------|-------|-----------------|
| `INTERNAL_ERROR` | 0     | 500             |
| `BAD_REQUEST`    | 1     | 400             |
| `TIMEOUT`        | 2     | 408             |
| `NOT_FOUND`      | 3     | 404             |
| `CONFLICT`       | 4     | 409             |
| `METHOD_UNK`     | 5     |                 |
| `METHOD_INV`     | 6     |                 |
| `STOP`           | 7     |                 |
| `DISCONNECT`     | 8     |                 |
| `OVERFLOW`       | 9     |                 |
| `THROTTLE`       | 10    |                 |
| `AUTH`           | 11    | 401             |
| `AUTHC`          | 12    | 401             |
| `AUTHZ`          | 13    | 403             |
npm package: @jsonjoy.com/rpc-messages
Description: RPC message types and utilities for JSON RPC APIs
Author: streamich
Latest version: 18.10.0

# `@jsonjoy.com/rpc-messages`

Message types for the [JSON Reactive RPC](https://jsonjoy.com/specs/json-rx)
protocol. JSON Rx is a lightweight bi-directional RPC protocol with reactive
(Observable) request and response payloads. It supports notifications,
request/response, and full bidirectional streaming over any message-passing
transport (WebSocket, HTTP, IPC, etc.).

## Usage

```ts
import {
  NotificationMessage,
  RequestDataMessage,
  RequestCompleteMessage,
  RequestErrorMessage,
  RequestUnsubscribeMessage,
  ResponseDataMessage,
  ResponseCompleteMessage,
  ResponseErrorMessage,
  ResponseUnsubscribeMessage,
} from '@jsonjoy.com/rpc-messages';
```

## Messages

JSON Rx defines nine message types split between client-sent and server-sent
messages.

### Client to Server

| Class | Description |
|---|---|
| `NotificationMessage` | Fire-and-forget notification; no response expected. |
| `RequestDataMessage` | Initiates a subscription or emits a value into an existing one. |
| `RequestCompleteMessage` | Starts and immediately completes a subscription (unary request). |
| `RequestErrorMessage` | Starts and immediately completes a subscription with an error. |
| `ResponseUnsubscribeMessage` | Client cancels an active response subscription. |

### Server to Client

| Class | Description |
|---|---|
| `NotificationMessage` | Fire-and-forget notification from server. |
| `ResponseDataMessage` | Emits a value in a response subscription. |
| `ResponseCompleteMessage` | Completes a response subscription (with an optional final value). |
| `ResponseErrorMessage` | Completes a response subscription with an error. |
| `RequestUnsubscribeMessage` | Server asks client to stop a request subscription. |

### Communication patterns

- **Notification** — client sends one `NotificationMessage`; server sends nothing back.
- **Request/response** — client sends `RequestCompleteMessage`; server sends `ResponseCompleteMessage`. Both sides emit exactly one value.
- **Server-streaming** — client sends `RequestCompleteMessage`; server sends zero or more `ResponseDataMessage`s followed by `ResponseCompleteMessage`.
- **Client-streaming** — client sends one or more `RequestDataMessage`s followed by `RequestCompleteMessage`; server sends `ResponseCompleteMessage`.
- **Bidirectional streaming** — client streams `RequestDataMessage`s; server streams `ResponseDataMessage`s.

## Validation

Every message class exposes a `validate()` method that throws an
[`RpcError`](../rpc-error) (`BAD_REQUEST`) if the message fields are invalid
(e.g. `id` out of range, `method` name contains illegal characters).
npm package: @jsonjoy.com/rpc-server
Description: HTTP and WebSocket server implementations for Reactive JSON RPC.
Author: streamich
Latest version: 18.10.0

# `@jsonjoy.com/rpc-server`

HTTP/1.1 and WebSocket server for JSON RPC. Built on Node.js `http`/`https`
modules with a built-in WebSocket implementation (no external WS dependency).

## Features

- HTTP/1.1 server with path-based routing (via `@jsonjoy.com/jit-router`)
- WebSocket upgrade handling with built-in frame codec
- TLS support with automatic secure context refresh
- Multiple RPC codec support: Compact, Binary, JSON-RPC 2.0
- Multiple value encodings: JSON, CBOR, MessagePack
- Content-type based codec negotiation
- Authentication token extraction from headers, query, cookies
- CORS support

## Usage

```ts
import {RpcServer} from '@jsonjoy.com/rpc-server/lib/http1/RpcServer';

const server = await RpcServer.startWithDefaults({
  caller: myCallee,
  port: 8080,
});
```