MCPcopy Create free account
hub / github.com/callstackincubator/polygen / constructor

Method constructor

packages/polygen/src/api/Instance.ts:17–35  ·  view source on GitHub ↗
(module: Module, imports: ImportObject = {})

Source from the content-addressed store, hash-verified

15 private tables: Record<string, object> = {};
16
17 constructor(module: Module, imports: ImportObject = {}) {
18 this.#imports = imports;
19
20 if (module instanceof Module) {
21 validateImports(imports, module.metadata);
22 } else {
23 throw new TypeError('Invalid module type');
24 }
25
26 NativeWASM.createModuleInstance(this, module, imports);
27
28 for (const memoryName in this.memories) {
29 this.exports[memoryName] = new Memory(this.memories[memoryName]!);
30 }
31
32 for (const tableName in this.tables) {
33 this.exports[tableName] = new Table(this.tables[tableName]!);
34 }
35 }
36}
37
38function validateImports(

Callers

nothing calls this directly

Calls 2

validateImportsFunction · 0.85
createModuleInstanceMethod · 0.65

Tested by

no test coverage detected