Last updated

API / geotoolkit / util / stream / BrowserMemoryStream / BrowserMemoryStream

Class: 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.

Implements

Table of contents

Constructors
Methods

Contents

Constructors

new BrowserMemoryStream(options)

new BrowserMemoryStream(options)

Parameters

Name Type
optionsOptions
Methods

dispose

dispose(): void

Dispose

Returns

void

Implementation of

IReadable.dispose


getSize

getSize(): number

Returns the size of the underlying data

Returns

number

size The size

Implementation of

IReadable.getSize


getStride

getStride(): number

Returns the stride of this stream

Returns

number

stride The stride

Implementation of

IReadable.getStride


readChunk

readChunk(offset, length, callback): BrowserMemoryStream

Read a chunk of data and calls the callback when it's done.

Parameters

Name Type Description
offsetnumberThe position to start reading from
lengthnumberThe amount of bytes to read
callback(err: Error, buffer: Int8Array | Int16Array, bytesRead: number) => voidThe callback that will be called with the result

Returns

BrowserMemoryStream

this

Implementation of

IReadable.readChunk


stringToArrayBuffer

Static stringToArrayBuffer(string): ArrayBuffer

Converts a String in an ArrayBuffer using String.charCodeAt (encoding is forced to utf16).

Parameters

Name Type Description
stringstringThe string to convert

Returns

ArrayBuffer

buffer The resulting ArrayBuffer