run

API Reference for run.

run()

Execute JavaScript or type-stripped TypeScript in a fresh, hardened QuickJS context.

import { run } from 'run';

const result = await run<number>({
  source: 'return await math.add(20, 22);',
  hostFunctions: {
    math: {
      add: (left: number, right: number) => left + right,
    },
  },
});

if (result.status === 'completed') {
  console.log(result.value); // 42
}

Import

import { run } from 'run';

API Signature

Type Parameters

Prop

Type

Parameters

Prop

Type

Returns

Prop

Type