aboutsummaryrefslogtreecommitdiff
path: root/src/js/node/vm.ts
blob: 331f4fbc69a525aba9f0e66ae8ebb44075821b28 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Hardcoded module "node:vm"
import { throwNotImplemented } from "../shared";

const vm = $lazy("vm");

const { createContext, isContext, Script, runInNewContext, runInThisContext } = vm;

function runInContext(code, context, options) {
  return new Script(code, options).runInContext(context);
}

function compileFunction() {
  throwNotImplemented("node:vm compileFunction", 401);
}
function measureMemory() {
  throwNotImplemented("node:vm measureMemory", 401);
}

const defaultObject = {
  createContext,
  runInContext,
  runInNewContext,
  runInThisContext,
  isContext,
  compileFunction,
  measureMemory,
  Script,
  [Symbol.for("CommonJS")]: 0,
};

export {
  defaultObject as default,
  createContext,
  runInContext,
  runInNewContext,
  runInThisContext,
  isContext,
  compileFunction,
  measureMemory,
  Script,
};