@compdict/core
v0.1.1
Published
RFC 9842 Compression Dictionary Transport: framing, header parsing, URL matching and codecs.
Maintainers
Readme
@compdict/core
Node.js primitives for RFC 9842 Compression Dictionary Transport:
Use-As-Dictionary,Available-Dictionary, andDictionary-ID- URL pattern matching and dictionary selection
dcbanddczframing and window inspection- bundled Brotli and Zstandard codecs
- stream and captured-HTTP validation
- build-time encoding and baseline measurement
Requires Node.js 22 or later.
npm install @compdict/coreValidate a stream
import { validateStream } from '@compdict/core';
import { readFile } from 'node:fs/promises';
const [stream, dictionary, original] = await Promise.all([
readFile('app.v2.js.dcb'),
readFile('app.v1.js'),
readFile('app.v2.js'),
]);
const result = await validateStream({
stream,
dictionary,
original,
expectedEncoding: 'dcb',
});
for (const finding of result.findings) {
if (finding.kind === 'conformance') {
console.log(
`${finding.code} RFC 9842 §${finding.rfc.section}: ${finding.message}`,
);
}
}A conformance finding always carries an RFC 9842 citation. Network, input, and codec failures are separate operational findings, so an incomplete test is not reported as a server violation.
Encode an artifact
import { encodeStream } from '@compdict/core';
import { readFile, writeFile } from 'node:fs/promises';
const input = await readFile('app.v2.js');
const dictionary = await readFile('app.v1.js');
const encoded = await encodeStream(input, {
encoding: 'dcz',
dictionary,
});
if (encoded.verified !== true) throw new Error('round-trip failed');
await writeFile('app.v2.js.dcz', encoded.stream);Round-trip verification is on by default.
The main entry point does not load a wasm binary until an operation needs one. Direct codec access is available through:
@compdict/core/codec/brotli@compdict/core/codec/zstd
The WebAssembly artifacts are built from pinned upstream commits. Codec choice
and URLPattern behaviour therefore do not depend on the host's Node build.
urlpattern-polyfill is the package's only runtime dependency.
For the command-line tool, install
compdict.
Apache-2.0.
