cesr
Version:
[](https://www.npmjs.com/package/cesr) [](https://github.com/lenkan/cesr-js/blob/main/LICENSE) [ • 973 B
TypeScript
import { Message } from "./message.ts";
export type ParseInput = Uint8Array | string | AsyncIterable<Uint8Array>;
export interface ParseOptions {
/**
* CESR version to use for cold start parsing. Defaults to 1.
*/
version?: number;
}
/**
* Parses CESR messages from an incoming stream of bytes.
*
* @example
*
* ```ts
* import { parse } from "cesr";
*
* const url = "https://example.com/oobi/EAQABAA..."; // URL returning a CESR stream
* const response = await fetch(url);
*
* if (response.body) {
* for await (const message of parse(response.body)) {
* console.log(message);
* }
* }
* ```
*
* @param input
* Input to the parser. Can be an Uint8Array, string or stream.
*
* Strings are treated as UTF-8 encoded data.
*
* @param options
* Parser options
*
* @returns An async iterable of {@link Message} objects
*/
export declare function parse(input: ParseInput, options?: ParseOptions): AsyncIterableIterator<Message>;