Skip to main content


Deno standard library
Go to Latest
class BufWriter
implements Writer
import { BufWriter } from "";

BufWriter implements buffering for an deno.Writer object. If an error occurs writing to a Writer, no more data will be accepted and all subsequent writes, and flush(), will return the error. After all data has been written, the client should call the flush() method to guarantee all data has been forwarded to the underlying deno.Writer.


BufWriter(wr: Writer, size?: number)


buf: Uint8Array
err: Error | null
n: number


available(): number

Returns how many bytes are unused in the buffer.

buffered(): number

buffered returns the number of bytes that have been written into the current buffer.

flush(): Promise<void>

Flush writes any buffered data to the underlying io.Writer.

reset(w: Writer): void

Discards any unflushed buffered data, clears any error, and resets b to write its output to w.

size(): number

Size returns the size of the underlying buffer in bytes.

write(p: Uint8Array): Promise<number>

Writes the contents of p into the buffer. Returns the number of bytes written.

Static Methods

create(w: Writer, size?: number): BufWriter

return new BufWriter unless w is BufWriter