Incremental writer for files and pipes.
Symbol
FileBlob.writer
Referenced types
interface FileSink
Fast incremental writer for files and pipes.
This uses the same interface as ArrayBufferSink, but writes to a file or pipe.
Flush the internal buffer, committing the data to disk or the pipe.
@returnsNumber of bytes flushed or a Promise resolving to the number of bytes
For FIFOs & pipes, this lets you decide whether Bun's process should remain alive until the pipe is closed.
By default, it is automatically managed. While the stream is open, the process remains alive and once the other end hangs up or the stream closes, the process exits.
If you previously called unref, you can call this again to re-enable automatic management.
Internally, it will reference count the number of times this is called. By default, that number is 1
If the file is not a FIFO or pipe, ref and unref do nothing. If the pipe is already closed, this does nothing.
Start the file sink with provided options.
@param optionsConfiguration options for the file sink
For FIFOs & pipes, this lets you decide whether Bun's process should remain alive until the pipe is closed.
If you want to allow Bun's process to terminate while the stream is open, call this.
If the file is not a FIFO or pipe, ref and unref do nothing. If the pipe is already closed, this does nothing.
Write a chunk of data to the file.
If the file descriptor is not writable yet, the data is buffered.
@param chunkThe data to write
@returnsNumber of bytes written