summaryrefslogtreecommitdiff
path: root/cli/js/repl.ts
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2020-01-21 01:30:30 +1100
committerRy Dahl <ry@tinyclouds.org>2020-01-20 09:30:30 -0500
commit60b53fd6b6dc2af83a64c332b9f3a1926f43d631 (patch)
tree4f4ef1aadb8c79ef2319d728b9d5b132af40ef83 /cli/js/repl.ts
parent23e67eb5153bd26dbae471b27dc6a21a6d283b0b (diff)
Use globalThis to reference global scope (#3719)
Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/js/repl.ts')
-rw-r--r--cli/js/repl.ts17
1 files changed, 8 insertions, 9 deletions
diff --git a/cli/js/repl.ts b/cli/js/repl.ts
index 922cd499d..813f0cb21 100644
--- a/cli/js/repl.ts
+++ b/cli/js/repl.ts
@@ -1,7 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { close } from "./files.ts";
import { exit } from "./os.ts";
-import { window } from "./window.ts";
import { core } from "./core.ts";
import { formatError } from "./format_error.ts";
import { stringifyArgs } from "./console.ts";
@@ -104,8 +103,8 @@ function evaluate(code: string): boolean {
// @internal
export async function replLoop(): Promise<void> {
- const { console } = window;
- Object.defineProperties(window, replCommands);
+ const { console } = globalThis;
+ Object.defineProperties(globalThis, replCommands);
const historyFile = "deno_history.txt";
const rid = startRepl(historyFile);
@@ -118,12 +117,12 @@ export async function replLoop(): Promise<void> {
exit(exitCode);
};
- // Configure window._ to give the last evaluation result.
- Object.defineProperty(window, "_", {
+ // Configure globalThis._ to give the last evaluation result.
+ Object.defineProperty(globalThis, "_", {
configurable: true,
get: (): Value => lastEvalResult,
set: (value: Value): Value => {
- Object.defineProperty(window, "_", {
+ Object.defineProperty(globalThis, "_", {
value: value,
writable: true,
enumerable: true,
@@ -133,12 +132,12 @@ export async function replLoop(): Promise<void> {
}
});
- // Configure window._error to give the last thrown error.
- Object.defineProperty(window, "_error", {
+ // Configure globalThis._error to give the last thrown error.
+ Object.defineProperty(globalThis, "_error", {
configurable: true,
get: (): Value => lastThrownError,
set: (value: Value): Value => {
- Object.defineProperty(window, "_error", {
+ Object.defineProperty(globalThis, "_error", {
value: value,
writable: true,
enumerable: true,