Skip to content

Buffer Class Reference

devongovett edited this page Nov 12, 2012 · 4 revisions

The AV.Buffer class wraps around JavaScript typed arrays to provide a few additional helper functions.

Constructors

Properties

Methods

Constructors

new AV.Buffer(data)

Creates a new AV.Buffer with the specified typed array.

AV.Buffer.allocate(size)

Allocates a new empty AV.Buffer of the specified size.

Properties

AV.Buffer#length

A property that holds the size of the buffer.

Methods

AV.Buffer#copy()

Returns a new AV.Buffer with a copy of the data in this buffer.

AV.Buffer#slice(offset, length)

Returns a new AV.Buffer starting at offset and ending at offset + length. The returned buffer is backed by the same typed array in memory, so changes to the sliced buffer will be reflected in the original buffer and vise versa. If you want a true sliced copy, call buf.slice(offset, length).copy().

AV.Buffer#toBlob()

Returns a Blob representation of the buffer using the Blob constructor and BlobBuilder as supported by the given browser.

AV.Buffer#toBlobURL()

Returns a Blob URL to the buffer's contents, for linking to in an image tag, for example.