UNPKG

@sebastianwessel/quickjs

Version:

A typescript package to execute JavaScript and TypeScript code in a WebAssembly QuickJS sandbox

17 lines (16 loc) 487 B
import { call } from '../../helper.js'; import { handleToNative } from '../handleToNative.js'; export const serializeBuffer = (ctx, handle) => { let b; ctx .newFunction('', value => { const v = handleToNative(ctx, value); b = Buffer.from(v); }) .consume(f => { call(ctx, 'internal/serializer/serializeBuffer.js', `(b,fn) => { fn(b.buffer) }`, undefined, handle, f).dispose(); }); return b; };