UNPKG

dax

Version:

Cross platform shell tools inspired by zx.

62 lines 2.71 kB
import * as dntShim from "../../../../../../_dnt.shims.js"; /** Options for writing a file, used by `RequestBuilder#pipeToPath`. */ export interface WriteFileOptions { /** Append to the file rather than truncating it. */ append?: boolean; /** Create the file if it does not already exist. */ create?: boolean; /** Fail if the file already exists. */ createNew?: boolean; /** File mode (Unix permission bits) applied when creating. */ mode?: number; /** Signal that aborts the write. */ signal?: AbortSignal; } /** Options for opening a file via {@link open}. */ export interface OpenOptions { /** Open the file for reading. */ read?: boolean; /** Open the file for writing. */ write?: boolean; /** Create the file if it does not already exist. */ create?: boolean; /** Truncate the file to zero length when opening. */ truncate?: boolean; /** Append to the file rather than truncating it. */ append?: boolean; } /** File handle implementing Reader/Writer/WriterSync/Closer interfaces. */ export declare class FsFile { #private; /** Wraps an existing open file descriptor. */ constructor(fd: number); /** Reads up to `p.length` bytes into `p`, returning the number of bytes * read or `null` on EOF. */ read(p: Uint8Array): Promise<number | null>; /** Synchronous variant of {@link FsFile.read}. */ readSync(p: Uint8Array): number | null; /** Writes the provided bytes to the file, returning the number of bytes * written. */ write(p: Uint8Array): Promise<number>; /** Synchronous variant of {@link FsFile.write}. */ writeSync(p: Uint8Array): number; /** Closes the underlying file descriptor. */ close(): void; /** A `WritableStream` that writes to this file. */ get writable(): dntShim.WritableStream<Uint8Array>; /** Closes the file when used with `using` declarations. */ [Symbol.dispose](): void; } /** Opens the file at `filePath` with the given options. */ export declare function open(filePath: string, options: OpenOptions): Promise<FsFile>; /** Creates (or truncates) the file at `filePath` and opens it for writing. */ export declare function create(filePath: string): Promise<FsFile>; /** * Writes the entire buffer synchronously, retrying on EAGAIN/EWOULDBLOCK * and handling partial writes. `fs.writeSync` can surface these on * non-blocking pipes (e.g. inherited from a spawned child). */ export declare function writeSyncAll(fd: number, data: Uint8Array): number; /** Async equivalent of {@link writeSyncAll}. */ export declare function writeAll(fd: number, data: Uint8Array): Promise<number>; //# sourceMappingURL=fsFile.d.ts.map