import { Buffer } from "https://deno.land/x/deno@v0.28.0/cli/js/deno.ts";
A Buffer is a variable-sized buffer of bytes with read() and write() methods. Based on https://golang.org/pkg/bytes/#Buffer
Methods
_grow() grows the buffer to guarantee space for n more bytes. It returns the index where bytes should be written. If the buffer can't grow it will throw with ErrTooLarge.
_tryGrowByReslice() is a version of grow for the fast-case where the internal buffer only needs to be resliced. It returns the index where bytes should be written and whether it succeeded. It returns -1 if a reslice was not needed.
bytes() returns a slice holding the unread portion of the buffer. The slice is valid for use only until the next buffer modification (that is, only until the next call to a method like read(), write(), reset(), or truncate()). The slice aliases the buffer content at least until the next buffer modification, so immediate changes to the slice will affect the result of future reads.
empty() returns whether the unread portion of the buffer is empty.
grow() grows the buffer's capacity, if necessary, to guarantee space for another n bytes. After grow(n), at least n bytes can be written to the buffer without another allocation. If n is negative, grow() will panic. If the buffer can't grow it will throw ErrTooLarge. Based on https://golang.org/pkg/bytes/#Buffer.Grow
readFrom() reads data from r until EOF and appends it to the buffer, growing the buffer as needed. It returns the number of bytes read. If the buffer becomes too large, readFrom will panic with ErrTooLarge. Based on https://golang.org/pkg/bytes/#Buffer.ReadFrom
Sync version of readFrom
readSync() reads the next len(p) bytes from the buffer or until the buffer is drained. The return value n is the number of bytes read. If the buffer has no data to return, eof in the response will be true.
reset() resets the buffer to be empty, but it retains the underlying storage for use by future writes. reset() is the same as truncate(0)
toString() returns the contents of the unread portion of the buffer as a string. Warning - if multibyte characters are present when data is flowing through the buffer, this method may result in incorrect strings due to a character being split.
truncate() discards all but the first n unread bytes from the buffer but continues to use the same allocated storage. It throws if n is negative or greater than the length of the buffer.