cld3-asm
Version:
WebAssembly based Javascript bindings for google compact language detector 3
23 lines • 1.11 kB
JavaScript
import { getModuleLoader } from 'emscripten-wasm-loader';
import { cldLoader } from './cldLoader';
import { log } from './util/logger';
//imports MODULARIZED emscripten preamble
import * as runtime from './lib/node/cld3';
/**
* Load, initialize wasm binary to use actual cld wasm instances.
*
* @param [InitOptions] Options to initialize cld3 wasm binary.
* @param {number} [InitOptions.timeout] - timeout to wait wasm binary compilation & load.
* @param {string | object} [InitOptions.locateBinary] - custom resolution logic for wasm binary. (not supported)
* It could be either remote endpoint url, or loader-returned object for bundler. Check examples/browser_* for references.
*
* @returns {() => Promise<CldFactory>} Function to load module
*/
const loadModule = async (initOptions = {}) => {
const { timeout } = initOptions;
log(`loadModule: loading cld3 wasm binary`, { initOptions });
const moduleLoader = await getModuleLoader((runtime) => cldLoader(runtime), runtime, undefined, { timeout });
return moduleLoader();
};
export { loadModule };
//# sourceMappingURL=loadModule.js.map