Skip to content
Last updated

API / geotoolkit / util / stream / BrowserMemoryStream / BrowserMemoryStream

Class: BrowserMemoryStream

stream.BrowserMemoryStream.BrowserMemoryStream

A stream implementation using a browser ArrayBuffer as backing store.<br> (Use BrowserMemoryStream.stringToArrayBuffer to convert a string into an ArrayBuffer).<br> This implementation provides compatibility with stream-based mechanism for dataset that are already in memory.<br> <br> Note that this class relies on the HTML5 File API.

Implements

Table of contents

Constructors
  • [new BrowserMemoryStream(options)](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.util.stream.browsermemorystream.browsermemorystream.md#new browsermemorystream(options))
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