From 873114d52f196d9b32e3979361d8963720b17e90 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Tue, 31 Jul 2018 01:20:06 -0400 Subject: [PATCH 1/2] nuke unused code --- src/NetscriptJSEvaluator.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NetscriptJSEvaluator.js b/src/NetscriptJSEvaluator.js index ea17c0116..7ca62437d 100644 --- a/src/NetscriptJSEvaluator.js +++ b/src/NetscriptJSEvaluator.js @@ -1,4 +1,3 @@ -import {registerEnv, unregisterEnv, makeEnvHeader} from "./NetscriptJSPreamble"; import {makeRuntimeRejectMsg} from "./NetscriptEvaluator"; // Makes a blob that contains the code of a given script. From 1cf276fa996ed2ca7db82c6fa16eb58251a1fe81 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Tue, 31 Jul 2018 01:21:29 -0400 Subject: [PATCH 2/2] deleted the file --- src/NetscriptJSPreamble.js | 42 -------------------------------------- 1 file changed, 42 deletions(-) delete mode 100644 src/NetscriptJSPreamble.js diff --git a/src/NetscriptJSPreamble.js b/src/NetscriptJSPreamble.js deleted file mode 100644 index 2fd35b6dc..000000000 --- a/src/NetscriptJSPreamble.js +++ /dev/null @@ -1,42 +0,0 @@ -// A utility function that adds a preamble to each Netscript JS -// script. This preamble will set all the global functions and -// variables appropriately for the module. -// -// One caveat is that we don't allow the variables in the preable -// to change. Unlike in normal Javascript, this would not change -// properties of self. It would instead just change the variable -// within the given module -- not good! Users should not really -// need to do this anyway. - -import uuidv4 from "uuid/v4"; -import {sprintf} from "sprintf-js"; - -window.__NSJS__environments = {}; - -// Returns the UUID for the env. -export function registerEnv(env) { - const uuid = uuidv4(); - window.__NSJS__environments[uuid] = env; - return uuid; -} - -export function unregisterEnv(uuid) { - delete window.__NSJS__environments[uuid]; -} - -export function makeEnvHeader(uuid) { - if (!(uuid in window.__NSJS__environments)) throw new Error("uuid is not in the environment" + uuid); - - const env = window.__NSJS__environments[uuid]; - var envLines = []; - for (const prop in env) { - envLines.push("const ", prop, " = ", "__NSJS_ENV[\"", prop, "\"];\n"); - } - - return sprintf(` - 'use strict'; - const __NSJS_ENV = window.__NSJS__environments['%s']; - // The global variable assignments (hack, weaken, etc.). - %s - `, uuid, envLines.join("")); -} \ No newline at end of file