diff options
Diffstat (limited to 'cli/js/lib.deno.shared_globals.d.ts')
-rw-r--r-- | cli/js/lib.deno.shared_globals.d.ts | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/cli/js/lib.deno.shared_globals.d.ts b/cli/js/lib.deno.shared_globals.d.ts index fd9f3691d..ef450c201 100644 --- a/cli/js/lib.deno.shared_globals.d.ts +++ b/cli/js/lib.deno.shared_globals.d.ts @@ -1080,6 +1080,46 @@ declare class Worker extends EventTarget { options?: { type?: "classic" | "module"; name?: string; + /** UNSTABLE: New API. Expect many changes; most likely this + * field will be made into an object for more granular + * configuration of worker thread (permissions, import map, etc.). + * + * Set to `true` to make `Deno` namespace and all of its methods + * available to worker thread. + * + * Currently worker inherits permissions from main thread (permissions + * given using `--allow-*` flags). + * Configurable permissions are on the roadmap to be implemented. + * + * Example: + * // mod.ts + * const worker = new Worker("./deno_worker.ts", { type: "module", deno: true }); + * worker.postMessage({ cmd: "readFile", fileName: "./log.txt" }); + * + * // deno_worker.ts + * + * + * self.onmessage = async function (e) { + * const { cmd, fileName } = e.data; + * if (cmd !== "readFile") { + * throw new Error("Invalid command"); + * } + * const buf = await Deno.readFile(fileName); + * const fileContents = new TextDecoder().decode(buf); + * console.log(fileContents); + * } + * + * // log.txt + * hello world + * hello world 2 + * + * // run program + * $ deno run --allow-read mod.ts + * hello world + * hello world2 + * + */ + deno?: boolean; } ); postMessage(message: any, transfer: ArrayBuffer[]): void; |