mhtml-stream
Version:
Zero dependency stream MHTML parser
63 lines (62 loc) • 2.15 kB
TypeScript
/**
* class for storing headers parse from MHTML
*
* Tries to somewhat mimic the behavior of the fetch-api Headers object, with
* some differences, notably that it does no validation.
*/
export interface MhtmlHeaders extends Iterable<[string, string]> {
/**
* add a key-value pair
*
* If key is already present it will be appended.
*/
append(key: string, value: string): void;
/**
* iterate over all key-value pairs
*
* Multiple values for the same key will be joined in the order they were
* added by `delimiter`.
*/
entries(delimiter?: string): IterableIterator<[string, string]>;
/**
* iterate over all key-value pairs
*
* Multiple values for the same key will get iterated in the order they were
* added.
*/
entriesAll(): IterableIterator<[string, string]>;
/**
* get the value for a key
*
* If the key is missing, null will be returned, if multiple values for the
* key are present, they will be joined be `delimiter`.
*/
get(key: string, delimiter?: string): string | null;
/** get all values for a key */
getAll(key: string): string[];
/** whether key has any values associated with it */
has(key: string): boolean;
/** all keys with at least one value */
keys(): Iterable<string>;
/**
* iterate over all values
*
* If a key has multiple values they will be joined by `delimiter`.
*/
values(delimiter?: string): IterableIterator<string>;
/** iterate over all values added */
valuesAll(): IterableIterator<string>;
}
export declare class Headers implements MhtmlHeaders {
#private;
[Symbol.iterator](): Iterator<[string, string]>;
append(key: string, value: string): void;
entries(delim?: string): IterableIterator<[string, string]>;
entriesAll(): IterableIterator<[string, string]>;
get(key: string, delim?: string): string | null;
getAll(key: string): string[];
has(key: string): boolean;
keys(): Iterable<string>;
values(delim?: string): IterableIterator<string>;
valuesAll(): IterableIterator<string>;
}