summaryrefslogtreecommitdiff
path: root/os.ts
blob: b2f9e93ba0ebd3bce17fa277167dd3ad1f2da5a4 (plain)
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
import { ModuleInfo } from "./types";
import { sendMsgFromObject } from "./dispatch";

export function exit(code = 0): void {
  sendMsgFromObject("os", { exit: { code } });
}

export function sourceCodeFetch(
  moduleSpecifier: string,
  containingFile: string
): ModuleInfo {
  const res = sendMsgFromObject("os", {
    sourceCodeFetch: { moduleSpecifier, containingFile }
  });
  return res.sourceCodeFetchRes;
}

export function sourceCodeCache(
  filename: string,
  sourceCode: string,
  outputCode: string
): void {
  sendMsgFromObject("os", {
    sourceCodeCache: { filename, sourceCode, outputCode }
  });
}