UNPKG

mhtml-stream

Version:
60 lines (59 loc) 2.64 kB
/** * Compare two byte arrays for equality */ export declare function bytesEqual(left: Uint8Array, right: Uint8Array): boolean; /** * Find index of one byte array in another */ export declare function indexOf(haystack: Uint8Array, needle: Uint8Array): number; /** * Split a stream of bytes * * Takes a stream of data modeled as an async iterator of ArrayBuffer for * compatibility between node and web, and splits it into an async iterator * where each value is delimited by the split sequence. */ export declare function splitStream(iter: AsyncIterable<Uint8Array>, split: Uint8Array): AsyncIterableIterator<Uint8Array>; /** * collect an async iterable of buffers into one */ export declare function collect(stream: AsyncIterable<Uint8Array>): Promise<Uint8Array>; /** whether a character code is a hex digit (0-9, A-F, a-f) */ export declare function isHexDigit(code: number): boolean; /** * decoder for quoted printable * * If quoted printable "lines" aren't escaped with an "=" then a new line needs * to be inserted. We use `newLine`, which defaults to CRLF to match the * canonical MIME form; pass a custom separator (e.g. a single "\n") to * normalize instead. The separator goes between lines; the CRLF before the MIME * boundary belongs to the delimiter, not the body. */ export declare function decodeQuotedPrintable(lines: AsyncIterable<Uint8Array>, newLine?: Uint8Array): AsyncIterableIterator<Uint8Array>; /** * decoder for base64 * * RFC 2045 requires decoders to ignore line breaks and decode the concatenated * stream, so producers may wrap at any column. We strip whitespace and buffer * characters that don't yet form a complete four-character quantum, flushing * the remainder at the end of the part. */ export declare function decodeBase64(lines: AsyncIterable<Uint8Array>): AsyncIterableIterator<Uint8Array>; /** * decoder for 7bit and 8bit * * 7bit/8bit apply no transfer transformation, so the content bytes are the * payload as-is. parseMhtml splits the stream on CRLF to find part boundaries, * so we re-insert `newLine` (defaulting to CRLF) between lines to restore the * original bytes exactly. Pass `newLine` (e.g. a single "\n") to normalize line * endings instead. The separator goes between lines; the CRLF before the * boundary belongs to the delimiter, not the body. */ export declare function decodeIdentity(lines: AsyncIterable<Uint8Array>, newLine?: Uint8Array): AsyncIterableIterator<Uint8Array>; /** * decoder for binary * * For implementation reasons, binary can't be supported, so we throw a special * error. */ export declare function decodeBinary(): never;