Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/io/mod.ts>BufWriter

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
class BufWriter
implements Writer
import { BufWriter } from "https://deno.land/std@0.39.0/io/mod.ts";

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.

Constructors

new
BufWriter(wr: Writer, size?: number)

Properties

buf: Uint8Array
err: Error | null
n: number

Methods

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