UNPKG

cld3-asm

Version:

WebAssembly based Javascript bindings for google compact language detector 3

25 lines 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const emscripten_wasm_loader_1 = require("emscripten-wasm-loader"); const cldLoader_1 = require("./cldLoader"); const logger_1 = require("./util/logger"); //imports MODULARIZED emscripten preamble const runtime = require("./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; logger_1.log(`loadModule: loading cld3 wasm binary`, { initOptions }); const moduleLoader = await emscripten_wasm_loader_1.getModuleLoader((runtime) => cldLoader_1.cldLoader(runtime), runtime, undefined, { timeout }); return moduleLoader(); }; exports.loadModule = loadModule; //# sourceMappingURL=loadModule.js.map