UNPKG

cesr

Version:

[![NPM Version](https://img.shields.io/npm/v/cesr.svg?style=flat)](https://www.npmjs.com/package/cesr) [![NPM License](https://img.shields.io/npm/l/cesr.svg?style=flat)](https://github.com/lenkan/cesr-js/blob/main/LICENSE) [![CI](https://github.com/lenkan

38 lines (37 loc) 973 B
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>;