UNPKG

@webfaas/webfaas-core

Version:

WebFaaS Framework - Core

43 lines 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ModuleCompileWasm = void 0; const Log_1 = require("../Log/Log"); const ILog_1 = require("../Log/ILog"); /** * ModuleCompileWasm */ class ModuleCompileWasm { constructor(log) { this.log = log || new Log_1.Log(); } getLog() { return this.log; } /** * return a wasm compiled * @param code * @param moduleCompileManifestData */ compile(code, moduleCompileManifestData) { return new Promise((resolve, reject) => { let timeInit = new Date().getTime(); let logDetail = {}; logDetail.manifest = moduleCompileManifestData; WebAssembly.compile(code).then((module) => { WebAssembly.instantiate(module).then((instance) => { logDetail.delay = new Date().getTime() - timeInit; this.log.write(ILog_1.LogLevelEnum.INFO, "compile", ILog_1.LogCodeEnum.COMPILE.toString(), "compiled", logDetail, __filename); resolve(instance); }).catch((errTry) => { this.log.writeError("compile", errTry, logDetail, __filename); reject(errTry); }); }).catch((errTry) => { this.log.writeError("compile", errTry, logDetail, __filename); reject(errTry); }); }); } } exports.ModuleCompileWasm = ModuleCompileWasm; //# sourceMappingURL=ModuleCompileWasm.js.map