Skip to content
On this page

UTF8ToString ⇒ string

Reads a null-terminated string from the Emscripten heap.

Kind: Exported member
Returns: string - The string.
See: https://emscripten.org/docs/api_reference/preamble.js.html#UTF8ToString

ParamTypeDescription
ptrnumberThe pointer to the string.

Example

js
const wkt = geos.Module.UTF8ToString(wktPtr)

_malloc ⇒ number

Allocates memory on the Emscripten heap.

Kind: Exported member
Returns: number - The pointer to the allocated memory.
See: https://emscripten.org/docs/api_reference/preamble.js.html#_malloc

ParamTypeDescription
sizenumberThe size of the memory to allocate.

Example

js
const wktPtr = geos.Module._malloc(wkt.length + 1)

getValue ⇒ number

Reads a value from the Emscripten heap.

Kind: Exported member
Returns: number - The value.
See: https://emscripten.org/docs/api_reference/preamble.js.html#getValue

ParamTypeDescription
ptrnumberThe pointer to the value.
typestringThe type of the value.

Example

js
const area = geos.Module.getValue(areaPtr, 'double')
console.log(area) // area = 1

setValue ⏏

Writes a value to the Emscripten heap.

Kind: Exported member
See: https://emscripten.org/docs/api_reference/preamble.js.html#setValue

ParamTypeDescription
ptrnumberThe pointer to the value.
typestringThe type of the value.
valuenumberThe value.

Example

js
geos.Module.setValue(areaPtr, 'double', 0)

stringToUTF8 ⏏

Writes a string to the Emscripten heap.

Kind: Exported member
See: https://emscripten.org/docs/api_reference/preamble.js.html#stringToUTF8

ParamTypeDescription
strstringThe string.
ptrnumberThe pointer to the string.
[maxLength]numberThe maximum length of the string.

Example

js
geos.Module.stringToUTF8(wkt, wktPtr)