UNPKG

@sebastianwessel/quickjs

Version:

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

17 lines (16 loc) 495 B
import { call } from '../../helper.js'; import { handleToNative } from '../handleToNative.js'; export const serializeDate = (ctx, handle) => { const d = new Date(); ctx .newFunction('', value => { const v = handleToNative(ctx, value); d.setTime(v); }) .consume(f => { call(ctx, 'internal/serializer/serializeDate.js', `(d,fn) => { fn(d.getTime()) }`, undefined, handle, f).dispose(); }); return d; };