summaryrefslogtreecommitdiff
path: root/js/repl.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-08-26 14:50:21 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-08-26 08:50:21 -0400
commit520f9631e09aa720fd8c03513ee8ea967f5ed4b2 (patch)
treefc3d1bd5182452ca1865a5c2631355e0895af94c /js/repl.ts
parent017f88ee99b0fe40221e6af92e0b6a976fbaf2ad (diff)
bring back json ops (#2815)
Diffstat (limited to 'js/repl.ts')
-rw-r--r--js/repl.ts30
1 files changed, 4 insertions, 26 deletions
diff --git a/js/repl.ts b/js/repl.ts
index c971e4420..ac6700657 100644
--- a/js/repl.ts
+++ b/js/repl.ts
@@ -1,12 +1,12 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import { assert } from "./util";
import { close } from "./files";
-import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { exit } from "./os";
import { window } from "./window";
import { core } from "./core";
import { formatError } from "./format_error";
import { stringifyArgs } from "./console";
+import * as dispatch from "./dispatch";
+import { sendSync, sendAsync } from "./dispatch_json";
/**
* REPL logging.
@@ -43,34 +43,12 @@ const replCommands = {
};
function startRepl(historyFile: string): number {
- const builder = flatbuffers.createBuilder();
- const historyFile_ = builder.createString(historyFile);
- const inner = msg.ReplStart.createReplStart(builder, historyFile_);
-
- const baseRes = sendSync(builder, msg.Any.ReplStart, inner);
- assert(baseRes != null);
- assert(msg.Any.ReplStartRes === baseRes!.innerType());
- const innerRes = new msg.ReplStartRes();
- assert(baseRes!.inner(innerRes) != null);
- const rid = innerRes.rid();
- return rid;
+ return sendSync(dispatch.OP_REPL_START, { historyFile });
}
// @internal
export async function readline(rid: number, prompt: string): Promise<string> {
- const builder = flatbuffers.createBuilder();
- const prompt_ = builder.createString(prompt);
- const inner = msg.ReplReadline.createReplReadline(builder, rid, prompt_);
-
- const baseRes = await sendAsync(builder, msg.Any.ReplReadline, inner);
-
- assert(baseRes != null);
- assert(msg.Any.ReplReadlineRes === baseRes!.innerType());
- const innerRes = new msg.ReplReadlineRes();
- assert(baseRes!.inner(innerRes) != null);
- const line = innerRes.line();
- assert(line !== null);
- return line || "";
+ return sendAsync(dispatch.OP_REPL_READLINE, { rid, prompt });
}
// Error messages that allow users to continue input