stream-hooks
Version:
<div align="center"> <a aria-label="NPM version" href="https://twitter.com/dimitrikennedy"> <img alt="stream-hooks" src="https://img.shields.io/twitter/follow/dimitrikennedy?style=social&labelColor=000000"> </a> <a aria-label="GH Issues" href="h
30 lines (27 loc) • 783 B
TypeScript
import z from 'zod';
interface StartStream {
(args: StartStreamArgs): void;
}
interface StartStreamBase {
(args: StartStreamArgs): Promise<ReadableStream<Uint8Array>>;
}
interface StopStream {
(): void;
}
interface StartStreamArgs {
url: string;
body?: object;
headers?: Record<string, string>;
method?: "GET" | "POST";
}
interface UseStreamProps {
onBeforeStart?: () => void;
onStop?: () => void;
}
interface UseJsonStreamProps<T extends z.ZodType<any, any>> extends UseStreamProps {
onReceive?: (data: Partial<z.infer<T>>) => void;
onEnd?: (data: z.infer<T>) => void;
schema: T;
defaultData?: Partial<z.infer<T>>;
}
export type { StartStream, StartStreamArgs, StartStreamBase, StopStream, UseJsonStreamProps, UseStreamProps };