rjweb-server
Version:
Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS
36 lines (35 loc) • 1.26 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
import { Duplex } from "stream";
import Logger from "../classes/Logger";
import { JSONParsed, JSONValue } from "../types/global";
export type Content = string | Buffer | ArrayBuffer | Map<string, JSONValue> | Set<JSONValue> | number | boolean | undefined | symbol | {
toString(): string;
} | Function | JSONValue[] | JSONParsed;
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<{
headers: Record<string, string>;
content: ArrayBuffer;
}>;