.writer()
on a BunFile
to retrieve a FileSink
instance. This instance can be used to efficiently buffer data and periodically “flush” it to disk. You can write & flush many times.
The
.write()
method can accept strings or binary data.
The
FileSink
will also auto-flush when its internal buffer is full. You can configure the buffer size with the highWaterMark
option.
When you’re done writing to the file, call
.end()
to auto-flush the buffer and close the file.
Full documentation: FileSink.