summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/chmod.ts8
-rw-r--r--js/chown.ts8
-rw-r--r--js/compiler.ts4
-rw-r--r--js/copy_file.ts8
-rw-r--r--js/dir.ts4
-rw-r--r--js/dispatch.ts156
-rw-r--r--js/dispatch_flatbuffers.ts151
-rw-r--r--js/dispatch_minimal.ts13
-rw-r--r--js/error_stack.ts6
-rw-r--r--js/errors.ts20
-rw-r--r--js/fetch.ts4
-rw-r--r--js/files.ts22
-rw-r--r--js/format_error.ts4
-rw-r--r--js/get_random_values.ts6
-rw-r--r--js/link.ts8
-rw-r--r--js/make_temp_dir.ts8
-rw-r--r--js/metrics.ts6
-rw-r--r--js/mkdir.ts8
-rw-r--r--js/net.ts12
-rw-r--r--js/os.ts5
-rw-r--r--js/performance.ts4
-rw-r--r--js/permissions.ts8
-rw-r--r--js/process.ts10
-rw-r--r--js/read_dir.ts8
-rw-r--r--js/read_link.ts8
-rw-r--r--js/remove.ts8
-rw-r--r--js/rename.ts8
-rw-r--r--js/repl.ts12
-rw-r--r--js/resources.ts6
-rw-r--r--js/stat.ts12
-rw-r--r--js/symlink.ts8
-rw-r--r--js/timers.ts4
-rw-r--r--js/truncate.ts8
-rw-r--r--js/utime.ts8
-rw-r--r--js/workers.ts4
35 files changed, 258 insertions, 319 deletions
diff --git a/js/chmod.ts b/js/chmod.ts
index 5abecb576..2d6a5ed0f 100644
--- a/js/chmod.ts
+++ b/js/chmod.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
function req(
path: string,
@@ -19,7 +17,7 @@ function req(
* Deno.chmodSync("/path/to/file", 0o666);
*/
export function chmodSync(path: string, mode: number): void {
- dispatch.sendSync(...req(path, mode));
+ sendSync(...req(path, mode));
}
/** Changes the permission of a specific file/directory of specified path.
@@ -27,5 +25,5 @@ export function chmodSync(path: string, mode: number): void {
* await Deno.chmod("/path/to/file", 0o666);
*/
export async function chmod(path: string, mode: number): Promise<void> {
- await dispatch.sendAsync(...req(path, mode));
+ await sendAsync(...req(path, mode));
}
diff --git a/js/chown.ts b/js/chown.ts
index 5c55fdab0..8787033fc 100644
--- a/js/chown.ts
+++ b/js/chown.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as flatbuffers from "./flatbuffers";
-import * as msg from "gen/cli/msg_generated";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
function req(
path: string,
@@ -21,7 +19,7 @@ function req(
* @param gid group id of the new owner
*/
export function chownSync(path: string, uid: number, gid: number): void {
- dispatch.sendSync(...req(path, uid, gid));
+ sendSync(...req(path, uid, gid));
}
/**
@@ -35,5 +33,5 @@ export async function chown(
uid: number,
gid: number
): Promise<void> {
- await dispatch.sendAsync(...req(path, uid, gid));
+ await sendAsync(...req(path, uid, gid));
}
diff --git a/js/compiler.ts b/js/compiler.ts
index 6bda5a1ec..fd6f0ef58 100644
--- a/js/compiler.ts
+++ b/js/compiler.ts
@@ -1,5 +1,4 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
import * as ts from "typescript";
import { assetSourceCode } from "./assets";
@@ -8,8 +7,7 @@ import { Console } from "./console";
import { core } from "./core";
import { Diagnostic, fromTypeScriptDiagnostic } from "./diagnostics";
import { cwd } from "./dir";
-import { sendSync } from "./dispatch";
-import * as flatbuffers from "./flatbuffers";
+import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
import * as os from "./os";
import { TextDecoder, TextEncoder } from "./text_encoding";
import { assert, notImplemented } from "./util";
diff --git a/js/copy_file.ts b/js/copy_file.ts
index 5cab6d579..4c62ed1b0 100644
--- a/js/copy_file.ts
+++ b/js/copy_file.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
function req(
from: string,
@@ -24,7 +22,7 @@ function req(
* Deno.copyFileSync("from.txt", "to.txt");
*/
export function copyFileSync(from: string, to: string): void {
- dispatch.sendSync(...req(from, to));
+ sendSync(...req(from, to));
}
/** Copies the contents of a file to another by name.
@@ -38,5 +36,5 @@ export function copyFileSync(from: string, to: string): void {
* await Deno.copyFile("from.txt", "to.txt");
*/
export async function copyFile(from: string, to: string): Promise<void> {
- await dispatch.sendAsync(...req(from, to));
+ await sendAsync(...req(from, to));
}
diff --git a/js/dir.ts b/js/dir.ts
index cf9345110..824084f4d 100644
--- a/js/dir.ts
+++ b/js/dir.ts
@@ -1,8 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
import { assert } from "./util";
-import * as flatbuffers from "./flatbuffers";
-import { sendSync } from "./dispatch";
+import { sendSync, flatbuffers, msg } from "./dispatch_flatbuffers";
/**
* `cwd()` Return a string representing the current working directory.
diff --git a/js/dispatch.ts b/js/dispatch.ts
index babea5739..423469d38 100644
--- a/js/dispatch.ts
+++ b/js/dispatch.ts
@@ -1,146 +1,22 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import { core } from "./core";
-import * as flatbuffers from "./flatbuffers";
-import * as msg from "gen/cli/msg_generated";
-import * as errors from "./errors";
-import * as util from "./util";
-import {
- nextPromiseId,
- recordFromBufMinimal,
- handleAsyncMsgFromRustMinimal
-} from "./dispatch_minimal";
+import * as minimal from "./dispatch_minimal";
+import * as flatbuffers from "./dispatch_flatbuffers";
-// TODO(ry) Currently we only use three values for opId: OP_READ, OP_WRITE,
-// FLATBUFFER_OP_ID. Later on use opId for actual individual ops, not just
-// classes of ops.
-const FLATBUFFER_OP_ID = 44;
-
-const promiseTable = new Map<number, util.Resolvable<msg.Base>>();
-
-interface FlatbufferRecord {
- promiseId: number;
- base: msg.Base;
-}
-
-function flatbufferRecordFromBuf(buf: Uint8Array): FlatbufferRecord {
- const bb = new flatbuffers.ByteBuffer(buf);
- const base = msg.Base.getRootAsBase(bb);
- return {
- promiseId: base.cmdId(),
- base
- };
-}
+// These consts are shared with Rust. Update with care.
+export const OP_FLATBUFFER = 44;
+export const OP_READ = 1;
+export const OP_WRITE = 2;
export function handleAsyncMsgFromRust(opId: number, ui8: Uint8Array): void {
- const buf32 = new Int32Array(ui8.buffer, ui8.byteOffset, ui8.byteLength / 4);
- if (opId !== FLATBUFFER_OP_ID) {
- // Fast and new
- const recordMin = recordFromBufMinimal(opId, buf32);
- handleAsyncMsgFromRustMinimal(ui8, recordMin);
- } else {
- // Legacy
- let { promiseId, base } = flatbufferRecordFromBuf(ui8);
- const promise = promiseTable.get(promiseId);
- util.assert(promise != null, `Expecting promise in table. ${promiseId}`);
- promiseTable.delete(promiseId);
- const err = errors.maybeError(base);
- if (err != null) {
- promise!.reject(err);
- } else {
- promise!.resolve(base);
- }
- }
-}
-
-function ui8FromArrayBufferView(abv: ArrayBufferView): Uint8Array {
- return new Uint8Array(abv.buffer, abv.byteOffset, abv.byteLength);
-}
-
-function sendInternal(
- builder: flatbuffers.Builder,
- innerType: msg.Any,
- inner: flatbuffers.Offset,
- zeroCopy: undefined | ArrayBufferView,
- isSync: true
-): Uint8Array;
-function sendInternal(
- builder: flatbuffers.Builder,
- innerType: msg.Any,
- inner: flatbuffers.Offset,
- zeroCopy: undefined | ArrayBufferView,
- isSync: false
-): Promise<msg.Base>;
-function sendInternal(
- builder: flatbuffers.Builder,
- innerType: msg.Any,
- inner: flatbuffers.Offset,
- zeroCopy: undefined | ArrayBufferView,
- isSync: boolean
-): Promise<msg.Base> | Uint8Array {
- const cmdId = nextPromiseId();
- msg.Base.startBase(builder);
- msg.Base.addInner(builder, inner);
- msg.Base.addInnerType(builder, innerType);
- msg.Base.addSync(builder, isSync);
- msg.Base.addCmdId(builder, cmdId);
- builder.finish(msg.Base.endBase(builder));
-
- const control = builder.asUint8Array();
-
- const response = core.dispatch(
- FLATBUFFER_OP_ID, // TODO(ry) Use actual opId later.
- control,
- zeroCopy ? ui8FromArrayBufferView(zeroCopy) : undefined
- );
-
- builder.inUse = false;
-
- if (response == null) {
- util.assert(!isSync);
- const promise = util.createResolvable<msg.Base>();
- promiseTable.set(cmdId, promise);
- return promise;
- } else {
- if (!isSync) {
- // We can easily and correctly allow for sync responses to async calls
- // by creating and returning a promise from the sync response.
- const bb = new flatbuffers.ByteBuffer(response);
- const base = msg.Base.getRootAsBase(bb);
- const err = errors.maybeError(base);
- if (err != null) {
- return Promise.reject(err);
- } else {
- return Promise.resolve(base);
- }
- }
- return response;
- }
-}
-
-// @internal
-export function sendAsync(
- builder: flatbuffers.Builder,
- innerType: msg.Any,
- inner: flatbuffers.Offset,
- data?: ArrayBufferView
-): Promise<msg.Base> {
- return sendInternal(builder, innerType, inner, data, false);
-}
-
-// @internal
-export function sendSync(
- builder: flatbuffers.Builder,
- innerType: msg.Any,
- inner: flatbuffers.Offset,
- data?: ArrayBufferView
-): null | msg.Base {
- const response = sendInternal(builder, innerType, inner, data, true);
- if (response!.length === 0) {
- return null;
- } else {
- const bb = new flatbuffers.ByteBuffer(response!);
- const baseRes = msg.Base.getRootAsBase(bb);
- errors.maybeThrowError(baseRes);
- return baseRes;
+ switch (opId) {
+ case OP_FLATBUFFER:
+ flatbuffers.handleAsyncMsgFromRust(opId, ui8);
+ break;
+ case OP_WRITE:
+ case OP_READ:
+ minimal.handleAsyncMsgFromRust(opId, ui8);
+ break;
+ default:
+ throw Error("bad opId");
}
}
diff --git a/js/dispatch_flatbuffers.ts b/js/dispatch_flatbuffers.ts
new file mode 100644
index 000000000..87a01037c
--- /dev/null
+++ b/js/dispatch_flatbuffers.ts
@@ -0,0 +1,151 @@
+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
+import * as flatbuffers from "./flatbuffers";
+import { DenoError } from "./errors";
+import { core } from "./core";
+import * as msg from "gen/cli/msg_generated";
+import * as util from "./util";
+import { OP_FLATBUFFER } from "./dispatch";
+export { msg, flatbuffers };
+
+const promiseTable = new Map<number, util.Resolvable<msg.Base>>();
+let _nextPromiseId = 1;
+
+export function nextPromiseId(): number {
+ return _nextPromiseId++;
+}
+
+interface FlatbufferRecord {
+ promiseId: number;
+ base: msg.Base;
+}
+
+export function handleAsyncMsgFromRust(opId: number, ui8: Uint8Array): void {
+ let { promiseId, base } = flatbufferRecordFromBuf(ui8);
+ const promise = promiseTable.get(promiseId);
+ util.assert(promise != null, `Expecting promise in table. ${promiseId}`);
+ promiseTable.delete(promiseId);
+ const err = maybeError(base);
+ if (err != null) {
+ promise!.reject(err);
+ } else {
+ promise!.resolve(base);
+ }
+}
+
+function flatbufferRecordFromBuf(buf: Uint8Array): FlatbufferRecord {
+ const bb = new flatbuffers.ByteBuffer(buf);
+ const base = msg.Base.getRootAsBase(bb);
+ return {
+ promiseId: base.cmdId(),
+ base
+ };
+}
+
+function ui8FromArrayBufferView(abv: ArrayBufferView): Uint8Array {
+ return new Uint8Array(abv.buffer, abv.byteOffset, abv.byteLength);
+}
+
+function sendInternal(
+ builder: flatbuffers.Builder,
+ innerType: msg.Any,
+ inner: flatbuffers.Offset,
+ zeroCopy: undefined | ArrayBufferView,
+ isSync: true
+): Uint8Array;
+function sendInternal(
+ builder: flatbuffers.Builder,
+ innerType: msg.Any,
+ inner: flatbuffers.Offset,
+ zeroCopy: undefined | ArrayBufferView,
+ isSync: false
+): Promise<msg.Base>;
+function sendInternal(
+ builder: flatbuffers.Builder,
+ innerType: msg.Any,
+ inner: flatbuffers.Offset,
+ zeroCopy: undefined | ArrayBufferView,
+ isSync: boolean
+): Promise<msg.Base> | Uint8Array {
+ const cmdId = nextPromiseId();
+ msg.Base.startBase(builder);
+ msg.Base.addInner(builder, inner);
+ msg.Base.addInnerType(builder, innerType);
+ msg.Base.addSync(builder, isSync);
+ msg.Base.addCmdId(builder, cmdId);
+ builder.finish(msg.Base.endBase(builder));
+
+ const control = builder.asUint8Array();
+
+ const response = core.dispatch(
+ OP_FLATBUFFER, // TODO(ry) Use actual opId later.
+ control,
+ zeroCopy ? ui8FromArrayBufferView(zeroCopy) : undefined
+ );
+
+ builder.inUse = false;
+
+ if (response == null) {
+ util.assert(!isSync);
+ const promise = util.createResolvable<msg.Base>();
+ promiseTable.set(cmdId, promise);
+ return promise;
+ } else {
+ if (!isSync) {
+ // We can easily and correctly allow for sync responses to async calls
+ // by creating and returning a promise from the sync response.
+ const bb = new flatbuffers.ByteBuffer(response);
+ const base = msg.Base.getRootAsBase(bb);
+ const err = maybeError(base);
+ if (err != null) {
+ return Promise.reject(err);
+ } else {
+ return Promise.resolve(base);
+ }
+ }
+ return response;
+ }
+}
+
+// @internal
+export function sendAsync(
+ builder: flatbuffers.Builder,
+ innerType: msg.Any,
+ inner: flatbuffers.Offset,
+ data?: ArrayBufferView
+): Promise<msg.Base> {
+ return sendInternal(builder, innerType, inner, data, false);
+}
+
+// @internal
+export function sendSync(
+ builder: flatbuffers.Builder,
+ innerType: msg.Any,
+ inner: flatbuffers.Offset,
+ data?: ArrayBufferView
+): null | msg.Base {
+ const response = sendInternal(builder, innerType, inner, data, true);
+ if (response!.length === 0) {
+ return null;
+ } else {
+ const bb = new flatbuffers.ByteBuffer(response!);
+ const baseRes = msg.Base.getRootAsBase(bb);
+ maybeThrowError(baseRes);
+ return baseRes;
+ }
+}
+
+function maybeError(base: msg.Base): null | DenoError<msg.ErrorKind> {
+ const kind = base.errorKind();
+ if (kind === msg.ErrorKind.NoError) {
+ return null;
+ } else {
+ return new DenoError(kind, base.error()!);
+ }
+}
+
+function maybeThrowError(base: msg.Base): void {
+ const err = maybeError(base);
+ if (err != null) {
+ throw err;
+ }
+}
diff --git a/js/dispatch_minimal.ts b/js/dispatch_minimal.ts
index df0a290b2..fc3fc61b9 100644
--- a/js/dispatch_minimal.ts
+++ b/js/dispatch_minimal.ts
@@ -4,9 +4,9 @@ import * as util from "./util";
import { core } from "./core";
const promiseTableMin = new Map<number, util.Resolvable<number>>();
-let _nextPromiseId = 0;
+let _nextPromiseId = 1;
-export function nextPromiseId(): number {
+function nextPromiseId(): number {
return _nextPromiseId++;
}
@@ -40,12 +40,9 @@ const scratchBytes = new Uint8Array(
);
util.assert(scratchBytes.byteLength === scratch32.length * 4);
-export function handleAsyncMsgFromRustMinimal(
- ui8: Uint8Array,
- record: RecordMinimal
-): void {
- // Fast and new
- util.log("minimal handleAsyncMsgFromRust ", ui8.length);
+export function handleAsyncMsgFromRust(opId: number, ui8: Uint8Array): void {
+ const buf32 = new Int32Array(ui8.buffer, ui8.byteOffset, ui8.byteLength / 4);
+ const record = recordFromBufMinimal(opId, buf32);
const { promiseId, result } = record;
const promise = promiseTableMin.get(promiseId);
promiseTableMin.delete(promiseId);
diff --git a/js/error_stack.ts b/js/error_stack.ts
index e97020687..003717a72 100644
--- a/js/error_stack.ts
+++ b/js/error_stack.ts
@@ -2,9 +2,7 @@
// Some of the code here is adapted directly from V8 and licensed under a BSD
// style license available here: https://github.com/v8/v8/blob/24886f2d1c565287d33d71e4109a53bf0b54b75c/LICENSE.v8
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { assert } from "./util";
export interface Location {
@@ -77,7 +75,7 @@ function res(baseRes: msg.Base | null): Location {
*/
export function applySourceMap(location: Location): Location {
const { filename, line, column } = location;
- return res(dispatch.sendSync(...req(filename, line, column)));
+ return res(sendSync(...req(filename, line, column)));
}
/** Mutate the call site so that it returns the location, instead of its
diff --git a/js/errors.ts b/js/errors.ts
index 42cff60db..717015589 100644
--- a/js/errors.ts
+++ b/js/errors.ts
@@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import { Base, ErrorKind } from "gen/cli/msg_generated";
+import { ErrorKind } from "gen/cli/msg_generated";
export { ErrorKind } from "gen/cli/msg_generated";
/** A Deno specific error. The `kind` property is set to a specific error code
@@ -23,21 +23,3 @@ export class DenoError<T extends ErrorKind> extends Error {
this.name = ErrorKind[kind];
}
}
-
-// @internal
-export function maybeError(base: Base): null | DenoError<ErrorKind> {
- const kind = base.errorKind();
- if (kind === ErrorKind.NoError) {
- return null;
- } else {
- return new DenoError(kind, base.error()!);
- }
-}
-
-// @internal
-export function maybeThrowError(base: Base): void {
- const err = maybeError(base);
- if (err != null) {
- throw err;
- }
-}
diff --git a/js/fetch.ts b/js/fetch.ts
index 3911c63d0..505da218c 100644
--- a/js/fetch.ts
+++ b/js/fetch.ts
@@ -1,8 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { assert, createResolvable, notImplemented, isTypedArray } from "./util";
-import * as flatbuffers from "./flatbuffers";
-import { sendAsync } from "./dispatch";
-import * as msg from "gen/cli/msg_generated";
+import { sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
import * as domTypes from "./dom_types";
import { TextDecoder, TextEncoder } from "./text_encoding";
import { DenoBlob, bytesSymbol as blobBytesSymbol } from "./blob";
diff --git a/js/files.ts b/js/files.ts
index eb899d738..6f0e523c9 100644
--- a/js/files.ts
+++ b/js/files.ts
@@ -10,14 +10,10 @@ import {
SyncWriter,
SyncSeeker
} from "./io";
-import * as dispatch from "./dispatch";
import { sendAsyncMinimal } from "./dispatch_minimal";
-import * as msg from "gen/cli/msg_generated";
import { assert } from "./util";
-import * as flatbuffers from "./flatbuffers";
-
-const OP_READ = 1;
-const OP_WRITE = 2;
+import { sendAsync, sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
+import { OP_READ, OP_WRITE } from "./dispatch";
function reqOpen(
filename: string,
@@ -46,7 +42,7 @@ function resOpen(baseRes: null | msg.Base): File {
* const file = Deno.openSync("/foo/bar.txt");
*/
export function openSync(filename: string, mode: OpenMode = "r"): File {
- return resOpen(dispatch.sendSync(...reqOpen(filename, mode)));
+ return resOpen(sendSync(...reqOpen(filename, mode)));
}
/** Open a file and return an instance of the `File` object.
@@ -59,7 +55,7 @@ export async function open(
filename: string,
mode: OpenMode = "r"
): Promise<File> {
- return resOpen(await dispatch.sendAsync(...reqOpen(filename, mode)));
+ return resOpen(await sendAsync(...reqOpen(filename, mode)));
}
function reqRead(
@@ -93,7 +89,7 @@ function resRead(baseRes: null | msg.Base): number | EOF {
*
*/
export function readSync(rid: number, p: Uint8Array): number | EOF {
- return resRead(dispatch.sendSync(...reqRead(rid, p)));
+ return resRead(sendSync(...reqRead(rid, p)));
}
/** Read from a file ID into an array buffer.
@@ -145,7 +141,7 @@ function resWrite(baseRes: null | msg.Base): number {
* Deno.writeSync(file.rid, data);
*/
export function writeSync(rid: number, p: Uint8Array): number {
- return resWrite(dispatch.sendSync(...reqWrite(rid, p)));
+ return resWrite(sendSync(...reqWrite(rid, p)));
}
/** Write to the file ID the contents of the array buffer.
@@ -185,7 +181,7 @@ function reqSeek(
* Deno.seekSync(file.rid, 0, 0);
*/
export function seekSync(rid: number, offset: number, whence: SeekMode): void {
- dispatch.sendSync(...reqSeek(rid, offset, whence));
+ sendSync(...reqSeek(rid, offset, whence));
}
/** Seek a file ID to the given offset under mode given by `whence`.
@@ -200,14 +196,14 @@ export async function seek(
offset: number,
whence: SeekMode
): Promise<void> {
- await dispatch.sendAsync(...reqSeek(rid, offset, whence));
+ await sendAsync(...reqSeek(rid, offset, whence));
}
/** Close the file ID. */
export function close(rid: number): void {
const builder = flatbuffers.createBuilder();
const inner = msg.Close.createClose(builder, rid);
- dispatch.sendSync(builder, msg.Any.Close, inner);
+ sendSync(builder, msg.Any.Close, inner);
}
/** The Deno abstraction for reading and writing files. */
diff --git a/js/format_error.ts b/js/format_error.ts
index 1c79f36fc..6670b05e2 100644
--- a/js/format_error.ts
+++ b/js/format_error.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import { sendSync } from "./dispatch";
+import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { assert } from "./util";
export function formatError(errString: string): string {
diff --git a/js/get_random_values.ts b/js/get_random_values.ts
index eb46ed009..d5c0828c5 100644
--- a/js/get_random_values.ts
+++ b/js/get_random_values.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { assert } from "./util";
function req(
@@ -30,6 +28,6 @@ export function getRandomValues<
>(typedArray: T): T {
assert(typedArray !== null, "Input must not be null");
assert(typedArray.length <= 65536, "Input must not be longer than 65536");
- dispatch.sendSync(...req(typedArray as ArrayBufferView));
+ sendSync(...req(typedArray as ArrayBufferView));
return typedArray;
}
diff --git a/js/link.ts b/js/link.ts
index e6ffde66b..0d849d289 100644
--- a/js/link.ts
+++ b/js/link.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
function req(
oldname: string,
@@ -19,7 +17,7 @@ function req(
* Deno.linkSync("old/name", "new/name");
*/
export function linkSync(oldname: string, newname: string): void {
- dispatch.sendSync(...req(oldname, newname));
+ sendSync(...req(oldname, newname));
}
/** Creates `newname` as a hard link to `oldname`.
@@ -27,5 +25,5 @@ export function linkSync(oldname: string, newname: string): void {
* await Deno.link("old/name", "new/name");
*/
export async function link(oldname: string, newname: string): Promise<void> {
- await dispatch.sendAsync(...req(oldname, newname));
+ await sendAsync(...req(oldname, newname));
}
diff --git a/js/make_temp_dir.ts b/js/make_temp_dir.ts
index 8a3098b9e..f83f7fb60 100644
--- a/js/make_temp_dir.ts
+++ b/js/make_temp_dir.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { assert } from "./util";
export interface MakeTempDirOptions {
@@ -44,7 +42,7 @@ function res(baseRes: null | msg.Base): string {
* const tempDirName1 = Deno.makeTempDirSync({ prefix: 'my_temp' });
*/
export function makeTempDirSync(options: MakeTempDirOptions = {}): string {
- return res(dispatch.sendSync(...req(options)));
+ return res(sendSync(...req(options)));
}
/** makeTempDir creates a new temporary directory in the directory `dir`, its
@@ -61,5 +59,5 @@ export function makeTempDirSync(options: MakeTempDirOptions = {}): string {
export async function makeTempDir(
options: MakeTempDirOptions = {}
): Promise<string> {
- return res(await dispatch.sendAsync(...req(options)));
+ return res(await sendAsync(...req(options)));
}
diff --git a/js/metrics.ts b/js/metrics.ts
index 92ed5b52e..e93e9528c 100644
--- a/js/metrics.ts
+++ b/js/metrics.ts
@@ -1,8 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
import { assert } from "./util";
-import * as dispatch from "./dispatch";
+import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
export interface Metrics {
opsDispatched: number;
@@ -47,5 +45,5 @@ function res(baseRes: null | msg.Base): Metrics {
* └──────────────────┴────────┘
*/
export function metrics(): Metrics {
- return res(dispatch.sendSync(...req()));
+ return res(sendSync(...req()));
}
diff --git a/js/mkdir.ts b/js/mkdir.ts
index bf13c0e28..417c754a9 100644
--- a/js/mkdir.ts
+++ b/js/mkdir.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
function req(
path: string,
@@ -24,7 +22,7 @@ function req(
* Deno.mkdirSync("nested/directories", true);
*/
export function mkdirSync(path: string, recursive = false, mode = 0o777): void {
- dispatch.sendSync(...req(path, recursive, mode));
+ sendSync(...req(path, recursive, mode));
}
/** Creates a new directory with the specified path.
@@ -41,5 +39,5 @@ export async function mkdir(
recursive = false,
mode = 0o777
): Promise<void> {
- await dispatch.sendAsync(...req(path, recursive, mode));
+ await sendAsync(...req(path, recursive, mode));
}
diff --git a/js/net.ts b/js/net.ts
index f1470b86e..9c3bfbba5 100644
--- a/js/net.ts
+++ b/js/net.ts
@@ -1,9 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { EOF, Reader, Writer, Closer } from "./io";
-import * as msg from "gen/cli/msg_generated";
import { assert, notImplemented } from "./util";
-import * as dispatch from "./dispatch";
-import * as flatbuffers from "./flatbuffers";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { read, write, close } from "./files";
export type Network = "tcp";
@@ -40,7 +38,7 @@ enum ShutdownMode {
function shutdown(rid: number, how: ShutdownMode): void {
const builder = flatbuffers.createBuilder();
const inner = msg.Shutdown.createShutdown(builder, rid, how);
- const baseRes = dispatch.sendSync(builder, msg.Any.Shutdown, inner);
+ const baseRes = sendSync(builder, msg.Any.Shutdown, inner);
assert(baseRes == null);
}
@@ -84,7 +82,7 @@ class ListenerImpl implements Listener {
async accept(): Promise<Conn> {
const builder = flatbuffers.createBuilder();
const inner = msg.Accept.createAccept(builder, this.rid);
- const baseRes = await dispatch.sendAsync(builder, msg.Any.Accept, inner);
+ const baseRes = await sendAsync(builder, msg.Any.Accept, inner);
assert(baseRes != null);
assert(msg.Any.NewConn === baseRes!.innerType());
const res = new msg.NewConn();
@@ -149,7 +147,7 @@ export function listen(network: Network, address: string): Listener {
const network_ = builder.createString(network);
const address_ = builder.createString(address);
const inner = msg.Listen.createListen(builder, network_, address_);
- const baseRes = dispatch.sendSync(builder, msg.Any.Listen, inner);
+ const baseRes = sendSync(builder, msg.Any.Listen, inner);
assert(baseRes != null);
assert(msg.Any.ListenRes === baseRes!.innerType());
const res = new msg.ListenRes();
@@ -189,7 +187,7 @@ export async function dial(network: Network, address: string): Promise<Conn> {
const network_ = builder.createString(network);
const address_ = builder.createString(address);
const inner = msg.Dial.createDial(builder, network_, address_);
- const baseRes = await dispatch.sendAsync(builder, msg.Any.Dial, inner);
+ const baseRes = await sendAsync(builder, msg.Any.Dial, inner);
assert(baseRes != null);
assert(msg.Any.NewConn === baseRes!.innerType());
const res = new msg.NewConn();
diff --git a/js/os.ts b/js/os.ts
index ff3cd2c2a..59c44145d 100644
--- a/js/os.ts
+++ b/js/os.ts
@@ -1,8 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
import { core } from "./core";
-import { handleAsyncMsgFromRust, sendSync } from "./dispatch";
-import * as flatbuffers from "./flatbuffers";
+import { handleAsyncMsgFromRust } from "./dispatch";
+import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { assert } from "./util";
import * as util from "./util";
import { window } from "./window";
diff --git a/js/performance.ts b/js/performance.ts
index 602c8018f..7aaa7ae45 100644
--- a/js/performance.ts
+++ b/js/performance.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import { sendSync } from "./dispatch";
-import * as flatbuffers from "./flatbuffers";
+import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { assert } from "./util";
export class Performance {
diff --git a/js/permissions.ts b/js/permissions.ts
index 13bcf7f90..822ae8cbd 100644
--- a/js/permissions.ts
+++ b/js/permissions.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { assert } from "./util";
/** Permissions as granted by the caller */
@@ -42,7 +40,7 @@ function createPermissions(inner: msg.PermissionsRes): Permissions {
* }
*/
export function permissions(): Permissions {
- const baseRes = dispatch.sendSync(...getReq())!;
+ const baseRes = sendSync(...getReq())!;
assert(msg.Any.PermissionsRes === baseRes.innerType());
const res = new msg.PermissionsRes();
assert(baseRes.inner(res) != null);
@@ -71,5 +69,5 @@ function revokeReq(
* Deno.readFile("example.test"); // -> error or permission prompt
*/
export function revokePermission(permission: Permission): void {
- dispatch.sendSync(...revokeReq(permission));
+ sendSync(...revokeReq(permission));
}
diff --git a/js/process.ts b/js/process.ts
index 0629b26b0..b2b6d4734 100644
--- a/js/process.ts
+++ b/js/process.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as dispatch from "./dispatch";
-import * as flatbuffers from "./flatbuffers";
-import * as msg from "gen/cli/msg_generated";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { File, close } from "./files";
import { ReadCloser, WriteCloser } from "./io";
@@ -37,7 +35,7 @@ async function runStatus(rid: number): Promise<ProcessStatus> {
const builder = flatbuffers.createBuilder();
const inner = msg.RunStatus.createRunStatus(builder, rid);
- const baseRes = await dispatch.sendAsync(builder, msg.Any.RunStatus, inner);
+ const baseRes = await sendAsync(builder, msg.Any.RunStatus, inner);
assert(baseRes != null);
assert(msg.Any.RunStatusRes === baseRes!.innerType());
const res = new msg.RunStatusRes();
@@ -60,7 +58,7 @@ async function runStatus(rid: number): Promise<ProcessStatus> {
export function kill(pid: number, signo: number): void {
const builder = flatbuffers.createBuilder();
const inner = msg.Kill.createKill(builder, pid, signo);
- dispatch.sendSync(builder, msg.Any.Kill, inner);
+ sendSync(builder, msg.Any.Kill, inner);
}
export class Process {
@@ -227,7 +225,7 @@ export function run(opt: RunOptions): Process {
stdoutRidOffset,
stderrRidOffset
);
- const baseRes = dispatch.sendSync(builder, msg.Any.Run, inner);
+ const baseRes = sendSync(builder, msg.Any.Run, inner);
assert(baseRes != null);
assert(msg.Any.RunRes === baseRes!.innerType());
const res = new msg.RunRes();
diff --git a/js/read_dir.ts b/js/read_dir.ts
index 1394c8514..13c620916 100644
--- a/js/read_dir.ts
+++ b/js/read_dir.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { FileInfo, FileInfoImpl } from "./file_info";
import { assert } from "./util";
@@ -30,7 +28,7 @@ function res(baseRes: null | msg.Base): FileInfo[] {
* const files = Deno.readDirSync("/");
*/
export function readDirSync(path: string): FileInfo[] {
- return res(dispatch.sendSync(...req(path)));
+ return res(sendSync(...req(path)));
}
/** Reads the directory given by path and returns a list of file info.
@@ -38,5 +36,5 @@ export function readDirSync(path: string): FileInfo[] {
* const files = await Deno.readDir("/");
*/
export async function readDir(path: string): Promise<FileInfo[]> {
- return res(await dispatch.sendAsync(...req(path)));
+ return res(await sendAsync(...req(path)));
}
diff --git a/js/read_link.ts b/js/read_link.ts
index 83a4ff1ba..8cac67dd1 100644
--- a/js/read_link.ts
+++ b/js/read_link.ts
@@ -1,8 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
import { assert } from "./util";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
function req(name: string): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
const builder = flatbuffers.createBuilder();
@@ -26,7 +24,7 @@ function res(baseRes: null | msg.Base): string {
* const targetPath = Deno.readlinkSync("symlink/path");
*/
export function readlinkSync(name: string): string {
- return res(dispatch.sendSync(...req(name)));
+ return res(sendSync(...req(name)));
}
/** Returns the destination of the named symbolic link.
@@ -34,5 +32,5 @@ export function readlinkSync(name: string): string {
* const targetPath = await Deno.readlink("symlink/path");
*/
export async function readlink(name: string): Promise<string> {
- return res(await dispatch.sendAsync(...req(name)));
+ return res(await sendAsync(...req(name)));
}
diff --git a/js/remove.ts b/js/remove.ts
index 7abfd18e9..95294e6cf 100644
--- a/js/remove.ts
+++ b/js/remove.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
export interface RemoveOption {
recursive?: boolean;
@@ -25,7 +23,7 @@ function req(
* Deno.removeSync("/path/to/dir/or/file", {recursive: false});
*/
export function removeSync(path: string, options: RemoveOption = {}): void {
- dispatch.sendSync(...req(path, options));
+ sendSync(...req(path, options));
}
/** Removes the named file or directory. Would throw error if
@@ -39,5 +37,5 @@ export async function remove(
path: string,
options: RemoveOption = {}
): Promise<void> {
- await dispatch.sendAsync(...req(path, options));
+ await sendAsync(...req(path, options));
}
diff --git a/js/rename.ts b/js/rename.ts
index 9099f083a..31f480d0e 100644
--- a/js/rename.ts
+++ b/js/rename.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
function req(
oldpath: string,
@@ -22,7 +20,7 @@ function req(
* Deno.renameSync("old/path", "new/path");
*/
export function renameSync(oldpath: string, newpath: string): void {
- dispatch.sendSync(...req(oldpath, newpath));
+ sendSync(...req(oldpath, newpath));
}
/** Renames (moves) `oldpath` to `newpath`. If `newpath` already exists and is
@@ -32,5 +30,5 @@ export function renameSync(oldpath: string, newpath: string): void {
* await Deno.rename("old/path", "new/path");
*/
export async function rename(oldpath: string, newpath: string): Promise<void> {
- await dispatch.sendAsync(...req(oldpath, newpath));
+ await sendAsync(...req(oldpath, newpath));
}
diff --git a/js/repl.ts b/js/repl.ts
index daf4fd154..c971e4420 100644
--- a/js/repl.ts
+++ b/js/repl.ts
@@ -1,9 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
import { assert } from "./util";
import { close } from "./files";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { exit } from "./os";
import { window } from "./window";
import { core } from "./core";
@@ -49,7 +47,7 @@ function startRepl(historyFile: string): number {
const historyFile_ = builder.createString(historyFile);
const inner = msg.ReplStart.createReplStart(builder, historyFile_);
- const baseRes = dispatch.sendSync(builder, msg.Any.ReplStart, inner);
+ const baseRes = sendSync(builder, msg.Any.ReplStart, inner);
assert(baseRes != null);
assert(msg.Any.ReplStartRes === baseRes!.innerType());
const innerRes = new msg.ReplStartRes();
@@ -64,11 +62,7 @@ export async function readline(rid: number, prompt: string): Promise<string> {
const prompt_ = builder.createString(prompt);
const inner = msg.ReplReadline.createReplReadline(builder, rid, prompt_);
- const baseRes = await dispatch.sendAsync(
- builder,
- msg.Any.ReplReadline,
- inner
- );
+ const baseRes = await sendAsync(builder, msg.Any.ReplReadline, inner);
assert(baseRes != null);
assert(msg.Any.ReplReadlineRes === baseRes!.innerType());
diff --git a/js/resources.ts b/js/resources.ts
index 7ccc79c4d..49093fab1 100644
--- a/js/resources.ts
+++ b/js/resources.ts
@@ -1,8 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
import { assert } from "./util";
-import * as dispatch from "./dispatch";
+import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
export interface ResourceMap {
[rid: number]: string;
@@ -14,7 +12,7 @@ export interface ResourceMap {
export function resources(): ResourceMap {
const builder = flatbuffers.createBuilder();
const inner = msg.Resource.createResource(builder, 0, 0);
- const baseRes = dispatch.sendSync(builder, msg.Any.Resources, inner);
+ const baseRes = sendSync(builder, msg.Any.Resources, inner);
assert(baseRes !== null);
assert(msg.Any.ResourcesRes === baseRes!.innerType());
const res = new msg.ResourcesRes();
diff --git a/js/stat.ts b/js/stat.ts
index 755753606..1fcce82af 100644
--- a/js/stat.ts
+++ b/js/stat.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { assert } from "./util";
import { FileInfo, FileInfoImpl } from "./file_info";
@@ -30,7 +28,7 @@ function res(baseRes: null | msg.Base): FileInfo {
* assert(fileInfo.isFile());
*/
export async function lstat(filename: string): Promise<FileInfo> {
- return res(await dispatch.sendAsync(...req(filename, true)));
+ return res(await sendAsync(...req(filename, true)));
}
/** Queries the file system for information on the path provided synchronously.
@@ -41,7 +39,7 @@ export async function lstat(filename: string): Promise<FileInfo> {
* assert(fileInfo.isFile());
*/
export function lstatSync(filename: string): FileInfo {
- return res(dispatch.sendSync(...req(filename, true)));
+ return res(sendSync(...req(filename, true)));
}
/** Queries the file system for information on the path provided. `stat` Will
@@ -51,7 +49,7 @@ export function lstatSync(filename: string): FileInfo {
* assert(fileInfo.isFile());
*/
export async function stat(filename: string): Promise<FileInfo> {
- return res(await dispatch.sendAsync(...req(filename, false)));
+ return res(await sendAsync(...req(filename, false)));
}
/** Queries the file system for information on the path provided synchronously.
@@ -61,5 +59,5 @@ export async function stat(filename: string): Promise<FileInfo> {
* assert(fileInfo.isFile());
*/
export function statSync(filename: string): FileInfo {
- return res(dispatch.sendSync(...req(filename, false)));
+ return res(sendSync(...req(filename, false)));
}
diff --git a/js/symlink.ts b/js/symlink.ts
index 28bf6c859..40551e9f8 100644
--- a/js/symlink.ts
+++ b/js/symlink.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
import * as util from "./util";
import { platform } from "./build";
@@ -31,7 +29,7 @@ export function symlinkSync(
newname: string,
type?: string
): void {
- dispatch.sendSync(...req(oldname, newname, type));
+ sendSync(...req(oldname, newname, type));
}
/** Creates `newname` as a symbolic link to `oldname`. The type argument can be
@@ -45,5 +43,5 @@ export async function symlink(
newname: string,
type?: string
): Promise<void> {
- await dispatch.sendAsync(...req(oldname, newname, type));
+ await sendAsync(...req(oldname, newname, type));
}
diff --git a/js/timers.ts b/js/timers.ts
index 388827331..cb0fd531c 100644
--- a/js/timers.ts
+++ b/js/timers.ts
@@ -1,8 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { assert } from "./util";
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import { sendAsync, sendSync } from "./dispatch";
+import { sendAsync, sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { window } from "./window";
interface Timer {
diff --git a/js/truncate.ts b/js/truncate.ts
index 0e9a8b977..259c57da5 100644
--- a/js/truncate.ts
+++ b/js/truncate.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
function req(
name: string,
@@ -20,7 +18,7 @@ function req(
* Deno.truncateSync("hello.txt", 10);
*/
export function truncateSync(name: string, len?: number): void {
- dispatch.sendSync(...req(name, len));
+ sendSync(...req(name, len));
}
/**
@@ -30,5 +28,5 @@ export function truncateSync(name: string, len?: number): void {
* await Deno.truncate("hello.txt", 10);
*/
export async function truncate(name: string, len?: number): Promise<void> {
- await dispatch.sendAsync(...req(name, len));
+ await sendAsync(...req(name, len));
}
diff --git a/js/utime.ts b/js/utime.ts
index 02c423d24..89914b4ca 100644
--- a/js/utime.ts
+++ b/js/utime.ts
@@ -1,7 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
-import * as dispatch from "./dispatch";
+import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
import * as util from "./util";
function req(
@@ -34,7 +32,7 @@ export function utimeSync(
atime: number | Date,
mtime: number | Date
): void {
- dispatch.sendSync(...req(filename, atime, mtime));
+ sendSync(...req(filename, atime, mtime));
}
/** Changes the access and modification times of a file system object
@@ -48,5 +46,5 @@ export async function utime(
atime: number | Date,
mtime: number | Date
): Promise<void> {
- await dispatch.sendAsync(...req(filename, atime, mtime));
+ await sendAsync(...req(filename, atime, mtime));
}
diff --git a/js/workers.ts b/js/workers.ts
index f061a0126..e59e853c5 100644
--- a/js/workers.ts
+++ b/js/workers.ts
@@ -1,8 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
/* eslint-disable @typescript-eslint/no-explicit-any */
-import { sendAsync, sendSync } from "./dispatch";
-import * as msg from "gen/cli/msg_generated";
-import * as flatbuffers from "./flatbuffers";
+import { sendAsync, sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { assert, log } from "./util";
import { TextDecoder, TextEncoder } from "./text_encoding";
import { window } from "./window";