UNPKG

ducjs

Version:

The duc 2D CAD file format is a cornerstone of our advanced design system, conceived to cater to professionals seeking precision and efficiency in their design work.

40 lines (39 loc) 1.78 kB
/** * Synchronously converts data to a Base64 Data URL. * * This function is truly synchronous and works in both Node.js and browser environments. * * @param data The input data. Can be a UTF-8 string, a Uint8Array, or an ArrayBuffer. * @param mimeType The MIME type for the Data URL. * @returns A fully formed Base64 Data URL string. */ export declare function toDataURL(data: string | Uint8Array | ArrayBuffer, mimeType?: string): string; /** * Synchronously decodes a Base64 Data URL into its constituent parts. * * This function only supports Base64 encoded Data URLs. * * @param dataUrl The Base64 Data URL string (e.g., "data:image/png;base64,iVBOR..."). * @returns An object containing the decoded Uint8Array and the MIME type. * @throws An error if the input is not a valid or supported Data URL. */ export declare function fromDataURL(dataUrl: string): { data: Uint8Array; mimeType: string; }; export declare function uint8ArrayToBase64(bytes: Uint8Array): string; export declare function base64ToUint8Array(base64: string): Uint8Array; /** * Converts a Uint8Array to a browser File object. * * @param bytes The Uint8Array containing the binary data of the file. * @param fileName The desired name for the file, including its extension (e.g., "thumbnail.png"). * @param options Optional settings for the file. * @param options.mimeType The MIME type of the file (e.g., "image/png"). Defaults to "application/octet-stream". * @param options.lastModified The timestamp (milliseconds since epoch) for the file's last modified date. Defaults to the current time. * @returns A File object. */ export declare function uint8ArrayToFile(bytes: Uint8Array, fileName: string, options?: { mimeType?: string; lastModified?: number; }): File;