UNPKG

pikchr-wasm

Version:
24 lines (23 loc) 839 B
/* IMPORT */ import once from 'function-once'; /* MAIN */ const generate = (Module) => { const Pikchr = { /* LIFECYCLE API */ loadWASM: once(async () => { const instance = await Module(); Pikchr.render = (markup, svgClass = 'pikchr', flags = 0, height = 1, width = 1) => { const svg = instance.ccall('pikchr', 'string', ['string', 'string', 'number', 'number', 'number'], [markup, svgClass, flags, height, width]); instance._free(svg); return svg; }; }), /* API */ render: (markup, svgClass = 'pikchr', flags = 0, height = 1, width = 1) => { throw new Error('[pikchr] You need to call and await "pikchr.loadWASM" first'); } }; return Pikchr; }; /* EXPORT */ export default generate;