UNPKG

deepinfra

Version:
50 lines (49 loc) 1.63 kB
/// <reference types="node" /> /// <reference types="node" /> import { Readable } from "stream"; /** * The input types that can be converted to a ReadableStream. * @alias ReadStreamInput */ export type ReadStreamInput = Buffer | string; /** * Utility class for working with images. * @class * @category Utils * @hideconstructor */ export declare const ReadStreamUtils: { /** * Creates a ReadableStream from a Buffer. * @param buffer - The Buffer to be streamed. * @returns A ReadableStream. */ bufferToStream(buffer: Buffer): Readable; /** * Creates a ReadableStream from a file path. * @param filePath - The path to the image file. * @returns A ReadableStream of the file contents. */ fileToStream(filePath: string): Readable; /** * Downloads an image from a URL and returns it as a ReadableStream. * @param url - The URL of the image. * @returns A ReadableStream containing the image data. */ urlToStream(url: string): Promise<Readable>; /** * Converts a Base64 string to a ReadableStream. * @param base64 - The Base64 string to be converted. * @returns A ReadableStream of the image data. * @throws {Error} If the Base64 string is invalid. */ base64ToStream(base64: string): Readable; /** * Returns a ReadableStream from an object. * The object can be a Buffer, a file path, or a URL. * @param input * @returns A ReadableStream of the image data. * @throws {Error} If the input type is invalid. */ getReadStream(input: ReadStreamInput): Promise<Readable>; };