API / geotoolkit / util / stream / BrowserMemoryStream / BrowserMemoryStream
stream.BrowserMemoryStream.BrowserMemoryStream
A stream implementation using a browser ArrayBuffer as backing store.
(Use BrowserMemoryStream.stringToArrayBuffer to convert a string into an ArrayBuffer).
This implementation provides compatibility with stream-based mechanism for dataset that are already in memory.
Note that this class relies on the HTML5 File API.
Constructors
Methods
▸ dispose(): void
Dispose
void
▸ getSize(): number
Returns the size of the underlying data
number
size The size
▸ getStride(): number
Returns the stride of this stream
number
stride The stride
▸ readChunk(offset, length, callback): BrowserMemoryStream
Read a chunk of data and calls the callback when it's done.
| Name | Type | Description |
|---|---|---|
offset | number | The position to start reading from |
length | number | The amount of bytes to read |
callback | (err: Error, buffer: Int8Array | Int16Array, bytesRead: number) => void | The callback that will be called with the result |
this
▸ Static stringToArrayBuffer(string): ArrayBuffer
Converts a String in an ArrayBuffer using String.charCodeAt (encoding is forced to utf16).
| Name | Type | Description |
|---|---|---|
string | string | The string to convert |
ArrayBuffer
buffer The resulting ArrayBuffer