import { Effect } from 'effect'; import { FileReadError } from './error.js'; import type { File } from './file.js'; /** * Reads the file's contents as a UTF-8 string. Mirrors Elm's `File.toString`. * * Fails with a `FileReadError` if the browser's `FileReader` encounters an * error (e.g. the file was deleted while reading). Handle failures with * `Effect.catch` to convert them into a failure Message. * * @example * ```typescript * ReadResumeText( * File.readAsText(file).pipe( * Effect.map(text => GotResumeText({ text })), * Effect.catch(error => Effect.succeed(FailedReadResume({ error: error.reason }))), * ), * ) * ``` */ export declare const readAsText: (file: File) => Effect.Effect; /** * Reads the file's contents as a base64-encoded data URL. Useful for rendering * image previews without uploading the file first. Mirrors Elm's `File.toUrl`. * * @example * ```typescript * ReadImagePreview( * File.readAsDataUrl(imageFile).pipe( * Effect.map(dataUrl => GotImagePreview({ dataUrl })), * Effect.catch(error => Effect.succeed(FailedReadImage({ error: error.reason }))), * ), * ) * ``` */ export declare const readAsDataUrl: (file: File) => Effect.Effect; /** * Reads the file's contents as raw binary data. Mirrors Elm's `File.toBytes`. * * Use this when you need the full binary payload (e.g. to upload, hash, or * parse a custom file format). For images you usually want `readAsDataUrl` * instead. * * @example * ```typescript * UploadFile( * File.readAsArrayBuffer(file).pipe( * Effect.flatMap(buffer => uploadToServer(buffer)), * Effect.map(() => SucceededUpload()), * Effect.catch(error => Effect.succeed(FailedUpload({ reason: String(error) }))), * ), * ) * ``` */ export declare const readAsArrayBuffer: (file: File) => Effect.Effect; //# sourceMappingURL=reader.d.ts.map