/** * Fold a long stretch of bytes that is an exact repeat of one already above it. * * WHY THIS IS NOT `dedup`, `segments` OR `log`. Those three each fold a repeat * at a boundary somebody else drew: `dedup` works on whole request blocks, * `segments` on headings and blank lines, `log` on lines. A serialised message * list holding two copies of the same screenshot has none of those boundaries -- * it is one line, 780,000 characters wide, and every walker that keys on a line * or a block looks straight past 346,732 characters of byte-identical base64. * Measured on the browser workload, that hole was the whole gap: the block * router removed 5.9% where the request-level arm, which can see the image * blocks as structure, removed 49.7% of the same bytes. * * WHAT IT COSTS THE READER: nothing that needs a round trip. The referent is * still in the output, above the marker, and the marker says how much to copy * and which run to copy it from. That makes it reconstructible from the output * alone -- the same category the rest of this module's back-references sit in -- * rather than recoverable-with-a-read. */ import type { CompressionResult, Stamp } from './types.js'; /** * Is there a folded run anywhere in here? * * ASKED WITH THE STAMP, because the answer decides whether `expandLongRepeats` * runs at all: a caller that answered on the unstamped form would send content * carrying a forged back-reference into a decoder that then refuses it. */ export declare function hasFoldedRuns(text: string, stamp?: Stamp): boolean; /** * Puts every folded run back, left to right. * * LEFT TO RIGHT IS LOAD-BEARING. A marker addresses a run in the text above it, * and `foldLongRepeats` never points at a region that is itself folded, so by * the time a marker is reached everything it can name is already whole. * * STRICT, like the other decoders here: a quote that names nothing above, or * a length that runs off the end of what has been rebuilt, throws rather than * resolving to a guess. A decoder that guesses is worse than no decoder, * because the guess is silent. */ export declare function expandLongRepeats(text: string, stamp?: Stamp): string; /** * Replaces every long exact repeat with a marker naming the run it copies. * * Returns `null` when there was nothing to fold, when folding would not pay, * or when the result does not read back byte for byte. That last check is the * point rather than a belt-and-braces afterthought: this pass rewrites the * inside of a line, where no other pass in this module operates, so the cheap * way to be sure a quote still addresses what the encoder meant is to decode * the output and compare it with the input. It runs on a handful of very large * regions, so the comparison costs a scan and buys the whole guarantee. */ export declare function foldLongRepeats(text: string, stamp?: Stamp): CompressionResult | null; //# sourceMappingURL=runs.d.ts.map