initialize
Initializes geos.js module using fetch request or already compiled module.
Note that the returned module is just stateless, compiled WebAssembly code.
WebAssembly.Module could be shared with another worker or window via postMessage.
Parameters
| Name | Type | Description |
|---|---|---|
source | Response | Promise<Response> | WebAssembly.Module | Either a .wasm file fetch or already compiled module |
Returns
Promise<WebAssembly.Module>
A Promise that resolves with the WebAssembly.Module
See also
terminateterminates initializedgeos.jsinstance
Examples
browser; directly from fetch request
await initialize(fetch('geos_js.wasm'));
browser; from compiled module
const module = await WebAssembly.compileStreaming(fetch('geos_js.wasm'));
await initialize(module);
node; from a local file
const wasmData = await readFile('./geos_js.wasm');
const module = await WebAssembly.compile(wasmData);
await initialize(module);