@sebastianwessel/quickjs
Version:
A typescript package to execute JavaScript and TypeScript code in a WebAssembly QuickJS sandbox
18 lines (17 loc) • 542 B
JavaScript
import { call } from '../../helper.js';
import { handleToNative } from '../handleToNative.js';
export const serializeHeaders = (ctx, handle) => {
const h = new Headers();
ctx
.newFunction('', (value, name) => {
const v = handleToNative(ctx, value);
const n = handleToNative(ctx, name);
h.append(n, v);
})
.consume(f => {
call(ctx, 'internal/serializer/serializeHeaders.js', `(h, fn) => {
h.forEach(fn)
}`, undefined, handle, f).dispose();
});
return h;
};