UNPKG

@thi.ng/wasm-api

Version:

Generic, modular, extensible API bridge and infrastructure for hybrid JS & WebAssembly projects

28 lines (27 loc) 545 B
import { __instanceArray } from "./memory.js"; const defType = (align, size, instance) => (mem) => ({ get align() { return align; }, get size() { return size; }, instanceArray(base, num) { return __instanceArray(this, base, num); }, instance: (base) => { const inst = instance(mem, base); Object.defineProperties(inst, { __base: { value: base }, __bytes: { get() { return mem.u8.subarray(base, base + size); } } }); return inst; } }); export { defType };