UNPKG

rjweb-server

Version:

Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS

33 lines (32 loc) 1.25 kB
/// <reference types="node" /> /// <reference types="node" /> import { Duplex } from "stream"; import Logger from "../classes/logger"; export type Content = string | Buffer | Map<any, any> | Set<any> | number | boolean | undefined | Record<any, any> | symbol | Function | any[] | Promise<Content>; export type ParseContentReturns = Awaited<ReturnType<typeof parseContent>>; /** * Parse almost anything into a Buffer that resolves to a string in a streamed manner * @example * ``` * const parseStream = new ParseStream(...) * ``` * @since 7.9.0 */ export declare class ParseStream extends Duplex { /** * Create a new Stream for Parsing Content on the fly * @since 7.9.0 */ constructor(options?: { /** * Whether to prettify output (currently just JSONs) * @default false * @since 7.9.0 */ prettify?: boolean; }, logger?: Logger); } /** * Parse almost anything into a Buffer that resolves to a string * @since 5.0.0 */ export default function parseContent(content: Content, prettify?: boolean, logger?: Logger): Promise<{ /** The Headers associated with the parsed Content */ headers: Record<string, Buffer>; /** The Parsed Content, 100% a Buffer */ content: Buffer; }>;