summaryrefslogtreecommitdiff
path: root/cli/js
diff options
context:
space:
mode:
authorSamrith Shankar <samrith-s@users.noreply.github.com>2020-03-20 14:38:34 +0100
committerGitHub <noreply@github.com>2020-03-20 09:38:34 -0400
commit798904b0f2ed0c7284b67bba2f125f406b5850de (patch)
tree5aba8d35aa8984aa778c894258bcaed56f1ce17c /cli/js
parent35f6e2e45ddb96524a6bdf54b0a6155caa88d5e0 (diff)
Add require-await lint rule (#4401)
Diffstat (limited to 'cli/js')
-rw-r--r--cli/js/buffer.ts4
-rw-r--r--cli/js/compiler.ts4
-rw-r--r--cli/js/ops/fetch.ts2
-rw-r--r--cli/js/ops/fs/make_temp.ts8
-rw-r--r--cli/js/ops/fs/open.ts2
-rw-r--r--cli/js/ops/fs/read_link.ts2
-rw-r--r--cli/js/ops/fs/realpath.ts2
-rw-r--r--cli/js/ops/fs/seek.ts2
-rw-r--r--cli/js/ops/fs_events.ts6
-rw-r--r--cli/js/ops/net.ts6
-rw-r--r--cli/js/ops/process.ts2
-rw-r--r--cli/js/ops/repl.ts2
-rw-r--r--cli/js/ops/runtime_compiler.ts4
-rw-r--r--cli/js/ops/signal.ts2
-rw-r--r--cli/js/ops/tls.ts4
-rw-r--r--cli/js/ops/worker_host.ts2
-rw-r--r--cli/js/permissions.ts12
-rw-r--r--cli/js/process.ts2
-rw-r--r--cli/js/testing.ts17
-rw-r--r--cli/js/tests/dispatch_json_test.ts2
-rw-r--r--cli/js/tests/dispatch_minimal_test.ts2
-rw-r--r--cli/js/tests/event_target_test.ts4
-rw-r--r--cli/js/tests/files_test.ts6
-rw-r--r--cli/js/tests/process_test.ts4
-rw-r--r--cli/js/tests/read_link_test.ts4
-rw-r--r--cli/js/tests/signal_test.ts4
-rw-r--r--cli/js/tests/stat_test.ts28
-rw-r--r--cli/js/tests/test_util.ts2
-rw-r--r--cli/js/tests/timers_test.ts6
-rw-r--r--cli/js/tests/tls_test.ts37
-rw-r--r--cli/js/web/body.ts16
-rw-r--r--cli/js/web/fetch.ts18
32 files changed, 104 insertions, 114 deletions
diff --git a/cli/js/buffer.ts b/cli/js/buffer.ts
index 91c06a202..db2bb22e4 100644
--- a/cli/js/buffer.ts
+++ b/cli/js/buffer.ts
@@ -106,7 +106,7 @@ export class Buffer implements Reader, SyncReader, Writer, SyncWriter {
return nread;
}
- async read(p: Uint8Array): Promise<number | EOF> {
+ read(p: Uint8Array): Promise<number | EOF> {
const rr = this.readSync(p);
return Promise.resolve(rr);
}
@@ -116,7 +116,7 @@ export class Buffer implements Reader, SyncReader, Writer, SyncWriter {
return copyBytes(this.buf, p, m);
}
- async write(p: Uint8Array): Promise<number> {
+ write(p: Uint8Array): Promise<number> {
const n = this.writeSync(p);
return Promise.resolve(n);
}
diff --git a/cli/js/compiler.ts b/cli/js/compiler.ts
index 914a0baf0..419f07063 100644
--- a/cli/js/compiler.ts
+++ b/cli/js/compiler.ts
@@ -302,7 +302,7 @@ async function runtimeCompile(
}
}
-async function runtimeTranspile(
+function runtimeTranspile(
request: CompilerRequestRuntimeTranspile
): Promise<Record<string, TranspileOnlyResult>> {
const result: Record<string, TranspileOnlyResult> = {};
@@ -325,7 +325,7 @@ async function runtimeTranspile(
);
result[fileName] = { source, map };
}
- return result;
+ return Promise.resolve(result);
}
async function tsCompilerOnMessage({
diff --git a/cli/js/ops/fetch.ts b/cli/js/ops/fetch.ts
index 8d6a461ab..09b9ac1ec 100644
--- a/cli/js/ops/fetch.ts
+++ b/cli/js/ops/fetch.ts
@@ -15,7 +15,7 @@ export interface FetchResponse {
headers: Array<[string, string]>;
}
-export async function fetch(
+export function fetch(
args: FetchRequest,
body: ArrayBufferView | undefined
): Promise<FetchResponse> {
diff --git a/cli/js/ops/fs/make_temp.ts b/cli/js/ops/fs/make_temp.ts
index aeab9afc7..85dea5f20 100644
--- a/cli/js/ops/fs/make_temp.ts
+++ b/cli/js/ops/fs/make_temp.ts
@@ -11,9 +11,7 @@ export function makeTempDirSync(options: MakeTempOptions = {}): string {
return sendSync("op_make_temp_dir", options);
}
-export async function makeTempDir(
- options: MakeTempOptions = {}
-): Promise<string> {
+export function makeTempDir(options: MakeTempOptions = {}): Promise<string> {
return sendAsync("op_make_temp_dir", options);
}
@@ -21,8 +19,6 @@ export function makeTempFileSync(options: MakeTempOptions = {}): string {
return sendSync("op_make_temp_file", options);
}
-export async function makeTempFile(
- options: MakeTempOptions = {}
-): Promise<string> {
+export function makeTempFile(options: MakeTempOptions = {}): Promise<string> {
return sendAsync("op_make_temp_file", options);
}
diff --git a/cli/js/ops/fs/open.ts b/cli/js/ops/fs/open.ts
index 2ac5c715c..87696935f 100644
--- a/cli/js/ops/fs/open.ts
+++ b/cli/js/ops/fs/open.ts
@@ -26,7 +26,7 @@ export function openSync(
return sendSync("op_open", { path, options, openMode, mode });
}
-export async function open(
+export function open(
path: string,
openMode: OpenMode | undefined,
options: OpenOptions | undefined
diff --git a/cli/js/ops/fs/read_link.ts b/cli/js/ops/fs/read_link.ts
index 403cd6def..4ac8db3db 100644
--- a/cli/js/ops/fs/read_link.ts
+++ b/cli/js/ops/fs/read_link.ts
@@ -5,6 +5,6 @@ export function readlinkSync(path: string): string {
return sendSync("op_read_link", { path });
}
-export async function readlink(path: string): Promise<string> {
+export function readlink(path: string): Promise<string> {
return sendAsync("op_read_link", { path });
}
diff --git a/cli/js/ops/fs/realpath.ts b/cli/js/ops/fs/realpath.ts
index e68e32bf0..e8a904079 100644
--- a/cli/js/ops/fs/realpath.ts
+++ b/cli/js/ops/fs/realpath.ts
@@ -5,6 +5,6 @@ export function realpathSync(path: string): string {
return sendSync("op_realpath", { path });
}
-export async function realpath(path: string): Promise<string> {
+export function realpath(path: string): Promise<string> {
return sendAsync("op_realpath", { path });
}
diff --git a/cli/js/ops/fs/seek.ts b/cli/js/ops/fs/seek.ts
index dfac9bf63..c7e4c9172 100644
--- a/cli/js/ops/fs/seek.ts
+++ b/cli/js/ops/fs/seek.ts
@@ -10,7 +10,7 @@ export function seekSync(
return sendSync("op_seek", { rid, offset, whence });
}
-export async function seek(
+export function seek(
rid: number,
offset: number,
whence: SeekMode
diff --git a/cli/js/ops/fs_events.ts b/cli/js/ops/fs_events.ts
index 706efc1b0..4c08995b8 100644
--- a/cli/js/ops/fs_events.ts
+++ b/cli/js/ops/fs_events.ts
@@ -15,15 +15,15 @@ class FsEvents implements AsyncIterableIterator<FsEvent> {
this.rid = sendSync("op_fs_events_open", { recursive, paths });
}
- async next(): Promise<IteratorResult<FsEvent>> {
+ next(): Promise<IteratorResult<FsEvent>> {
return sendAsync("op_fs_events_poll", {
rid: this.rid
});
}
- async return(value?: FsEvent): Promise<IteratorResult<FsEvent>> {
+ return(value?: FsEvent): Promise<IteratorResult<FsEvent>> {
close(this.rid);
- return { value, done: true };
+ return Promise.resolve({ value, done: true });
}
[Symbol.asyncIterator](): AsyncIterableIterator<FsEvent> {
diff --git a/cli/js/ops/net.ts b/cli/js/ops/net.ts
index 5a72be8c6..25f3a8322 100644
--- a/cli/js/ops/net.ts
+++ b/cli/js/ops/net.ts
@@ -31,7 +31,7 @@ interface AcceptResponse {
};
}
-export async function accept(rid: number): Promise<AcceptResponse> {
+export function accept(rid: number): Promise<AcceptResponse> {
return sendAsync("op_accept", { rid });
}
@@ -74,7 +74,7 @@ export interface ConnectRequest {
port: number;
}
-export async function connect(args: ConnectRequest): Promise<ConnectResponse> {
+export function connect(args: ConnectRequest): Promise<ConnectResponse> {
return sendAsync("op_connect", args);
}
@@ -87,7 +87,7 @@ interface ReceiveResponse {
};
}
-export async function receive(
+export function receive(
rid: number,
zeroCopy: Uint8Array
): Promise<ReceiveResponse> {
diff --git a/cli/js/ops/process.ts b/cli/js/ops/process.ts
index 845909d5d..384718cef 100644
--- a/cli/js/ops/process.ts
+++ b/cli/js/ops/process.ts
@@ -12,7 +12,7 @@ interface RunStatusResponse {
exitSignal: number;
}
-export async function runStatus(rid: number): Promise<RunStatusResponse> {
+export function runStatus(rid: number): Promise<RunStatusResponse> {
return sendAsync("op_run_status", { rid });
}
diff --git a/cli/js/ops/repl.ts b/cli/js/ops/repl.ts
index 3f40f4456..1781aa089 100644
--- a/cli/js/ops/repl.ts
+++ b/cli/js/ops/repl.ts
@@ -6,6 +6,6 @@ export function startRepl(historyFile: string): number {
return sendSync("op_repl_start", { historyFile });
}
-export async function readline(rid: number, prompt: string): Promise<string> {
+export function readline(rid: number, prompt: string): Promise<string> {
return sendAsync("op_repl_readline", { rid, prompt });
}
diff --git a/cli/js/ops/runtime_compiler.ts b/cli/js/ops/runtime_compiler.ts
index 035a4ef59..b46670ace 100644
--- a/cli/js/ops/runtime_compiler.ts
+++ b/cli/js/ops/runtime_compiler.ts
@@ -9,7 +9,7 @@ interface CompileRequest {
bundle: boolean;
}
-export async function compile(request: CompileRequest): Promise<string> {
+export function compile(request: CompileRequest): Promise<string> {
return sendAsync("op_compile", request);
}
@@ -18,6 +18,6 @@ interface TranspileRequest {
options?: string;
}
-export async function transpile(request: TranspileRequest): Promise<string> {
+export function transpile(request: TranspileRequest): Promise<string> {
return sendAsync("op_transpile", request);
}
diff --git a/cli/js/ops/signal.ts b/cli/js/ops/signal.ts
index 3c8d021a0..09c178105 100644
--- a/cli/js/ops/signal.ts
+++ b/cli/js/ops/signal.ts
@@ -5,7 +5,7 @@ export function bindSignal(signo: number): { rid: number } {
return sendSync("op_signal_bind", { signo });
}
-export async function pollSignal(rid: number): Promise<{ done: boolean }> {
+export function pollSignal(rid: number): Promise<{ done: boolean }> {
return sendAsync("op_signal_poll", { rid });
}
diff --git a/cli/js/ops/tls.ts b/cli/js/ops/tls.ts
index b52ad65bb..e52143cb0 100644
--- a/cli/js/ops/tls.ts
+++ b/cli/js/ops/tls.ts
@@ -23,7 +23,7 @@ interface ConnectTLSResponse {
};
}
-export async function connectTLS(
+export function connectTLS(
args: ConnectTLSRequest
): Promise<ConnectTLSResponse> {
return sendAsync("op_connect_tls", args);
@@ -43,7 +43,7 @@ interface AcceptTLSResponse {
};
}
-export async function acceptTLS(rid: number): Promise<AcceptTLSResponse> {
+export function acceptTLS(rid: number): Promise<AcceptTLSResponse> {
return sendAsync("op_accept_tls", { rid });
}
diff --git a/cli/js/ops/worker_host.ts b/cli/js/ops/worker_host.ts
index 1a7e671f4..0b9f81795 100644
--- a/cli/js/ops/worker_host.ts
+++ b/cli/js/ops/worker_host.ts
@@ -24,6 +24,6 @@ export function hostPostMessage(id: number, data: Uint8Array): void {
sendSync("op_host_post_message", { id }, data);
}
-export async function hostGetMessage(id: number): Promise<any> {
+export function hostGetMessage(id: number): Promise<any> {
return sendAsync("op_host_get_message", { id });
}
diff --git a/cli/js/permissions.ts b/cli/js/permissions.ts
index 097c5048a..8c2025319 100644
--- a/cli/js/permissions.ts
+++ b/cli/js/permissions.ts
@@ -47,19 +47,19 @@ export class PermissionStatus {
}
export class Permissions {
- async query(desc: PermissionDescriptor): Promise<PermissionStatus> {
+ query(desc: PermissionDescriptor): Promise<PermissionStatus> {
const state = permissionsOps.query(desc);
- return new PermissionStatus(state);
+ return Promise.resolve(new PermissionStatus(state));
}
- async revoke(desc: PermissionDescriptor): Promise<PermissionStatus> {
+ revoke(desc: PermissionDescriptor): Promise<PermissionStatus> {
const state = permissionsOps.revoke(desc);
- return new PermissionStatus(state);
+ return Promise.resolve(new PermissionStatus(state));
}
- async request(desc: PermissionDescriptor): Promise<PermissionStatus> {
+ request(desc: PermissionDescriptor): Promise<PermissionStatus> {
const state = permissionsOps.request(desc);
- return new PermissionStatus(state);
+ return Promise.resolve(new PermissionStatus(state));
}
}
diff --git a/cli/js/process.ts b/cli/js/process.ts
index 991133047..ded1458a2 100644
--- a/cli/js/process.ts
+++ b/cli/js/process.ts
@@ -55,7 +55,7 @@ export class Process {
}
}
- async status(): Promise<ProcessStatus> {
+ status(): Promise<ProcessStatus> {
return runStatus(this.rid);
}
diff --git a/cli/js/testing.ts b/cli/js/testing.ts
index 08bb2db87..22e719719 100644
--- a/cli/js/testing.ts
+++ b/cli/js/testing.ts
@@ -289,7 +289,7 @@ export class ConsoleTestReporter implements TestReporter {
this.encoder = new TextEncoder();
}
- private log(msg: string, noNewLine = false): void {
+ private log(msg: string, noNewLine = false): Promise<void> {
if (!noNewLine) {
msg += "\n";
}
@@ -298,19 +298,22 @@ export class ConsoleTestReporter implements TestReporter {
// compared to `console.log`; `core.print` on the other hand
// is line-buffered and doesn't output message without newline
stdout.writeSync(this.encoder.encode(msg));
+ return Promise.resolve();
}
- async start(event: TestEventStart): Promise<void> {
+ start(event: TestEventStart): Promise<void> {
this.log(`running ${event.tests} tests`);
+ return Promise.resolve();
}
- async testStart(event: TestEventTestStart): Promise<void> {
+ testStart(event: TestEventTestStart): Promise<void> {
const { name } = event;
this.log(`test ${name} ... `, true);
+ return Promise.resolve();
}
- async testEnd(event: TestEventTestEnd): Promise<void> {
+ testEnd(event: TestEventTestEnd): Promise<void> {
const { result } = event;
switch (result.status) {
@@ -324,9 +327,11 @@ export class ConsoleTestReporter implements TestReporter {
this.log(`${YELLOW_IGNORED} ${formatDuration(result.duration)}`);
break;
}
+
+ return Promise.resolve();
}
- async end(event: TestEventEnd): Promise<void> {
+ end(event: TestEventEnd): Promise<void> {
const { stats, duration, results } = event;
// Attempting to match the output of Rust's test runner.
const failedTests = results.filter(r => r.error);
@@ -354,6 +359,8 @@ export class ConsoleTestReporter implements TestReporter {
`${stats.filtered} filtered out ` +
`${formatDuration(duration)}\n`
);
+
+ return Promise.resolve();
}
}
diff --git a/cli/js/tests/dispatch_json_test.ts b/cli/js/tests/dispatch_json_test.ts
index a2306dda8..4e95b86a2 100644
--- a/cli/js/tests/dispatch_json_test.ts
+++ b/cli/js/tests/dispatch_json_test.ts
@@ -19,7 +19,7 @@ unitTest(
}
);
-unitTest(async function malformedJsonControlBuffer(): Promise<void> {
+unitTest(function malformedJsonControlBuffer(): void {
// @ts-ignore
const opId = Deno.core.ops()["op_open"];
// @ts-ignore
diff --git a/cli/js/tests/dispatch_minimal_test.ts b/cli/js/tests/dispatch_minimal_test.ts
index 724a41698..60bb620db 100644
--- a/cli/js/tests/dispatch_minimal_test.ts
+++ b/cli/js/tests/dispatch_minimal_test.ts
@@ -25,7 +25,7 @@ unitTest(async function sendAsyncStackTrace(): Promise<void> {
}
});
-unitTest(async function malformedMinimalControlBuffer(): Promise<void> {
+unitTest(function malformedMinimalControlBuffer(): void {
// @ts-ignore
const readOpId = Deno.core.ops()["op_read"];
// @ts-ignore
diff --git a/cli/js/tests/event_target_test.ts b/cli/js/tests/event_target_test.ts
index 09d47f704..020db1acd 100644
--- a/cli/js/tests/event_target_test.ts
+++ b/cli/js/tests/event_target_test.ts
@@ -185,7 +185,7 @@ unitTest(function eventTargetShouldAcceptAsyncFunction(): void {
const event = new Event("foo", { bubbles: true, cancelable: false });
let callCount = 0;
- const listener = async (e: Event): Promise<void> => {
+ const listener = (e: Event): void => {
assertEquals(e, event);
++callCount;
};
@@ -210,7 +210,7 @@ unitTest(
let callCount = 0;
const listener = {
- async handleEvent(e: Event): Promise<void> {
+ handleEvent(e: Event): void {
assertEquals(e, event);
++callCount;
}
diff --git a/cli/js/tests/files_test.ts b/cli/js/tests/files_test.ts
index b087d7398..39af460b8 100644
--- a/cli/js/tests/files_test.ts
+++ b/cli/js/tests/files_test.ts
@@ -51,16 +51,16 @@ unitTest(async function readerToAsyncIterator(): Promise<void> {
constructor(private readonly s: string) {}
- async read(p: Uint8Array): Promise<number | Deno.EOF> {
+ read(p: Uint8Array): Promise<number | Deno.EOF> {
const n = Math.min(p.byteLength, this.buf.byteLength - this.offset);
p.set(this.buf.slice(this.offset, this.offset + n));
this.offset += n;
if (n === 0) {
- return Deno.EOF;
+ return Promise.resolve(Deno.EOF);
}
- return n;
+ return Promise.resolve(n);
}
}
diff --git a/cli/js/tests/process_test.ts b/cli/js/tests/process_test.ts
index 77c3065eb..e2da6cab5 100644
--- a/cli/js/tests/process_test.ts
+++ b/cli/js/tests/process_test.ts
@@ -359,9 +359,7 @@ if (Deno.build.os !== "win") {
p.close();
});
- unitTest({ perms: { run: true } }, async function killFailed(): Promise<
- void
- > {
+ unitTest({ perms: { run: true } }, function killFailed(): void {
const p = run({
args: ["python", "-c", "from time import sleep; sleep(10000)"]
});
diff --git a/cli/js/tests/read_link_test.ts b/cli/js/tests/read_link_test.ts
index 409f37110..156b31070 100644
--- a/cli/js/tests/read_link_test.ts
+++ b/cli/js/tests/read_link_test.ts
@@ -18,9 +18,7 @@ unitTest(
}
);
-unitTest({ perms: { read: false } }, async function readlinkSyncPerm(): Promise<
- void
-> {
+unitTest({ perms: { read: false } }, function readlinkSyncPerm(): void {
let caughtError = false;
try {
Deno.readlinkSync("/symlink");
diff --git a/cli/js/tests/signal_test.ts b/cli/js/tests/signal_test.ts
index e4339e290..c966e696b 100644
--- a/cli/js/tests/signal_test.ts
+++ b/cli/js/tests/signal_test.ts
@@ -15,7 +15,7 @@ function defer(n: number): Promise<void> {
unitTest(
{ ignore: Deno.build.os !== "win" },
- async function signalsNotImplemented(): Promise<void> {
+ function signalsNotImplemented(): void {
assertThrows(
() => {
Deno.signal(1);
@@ -162,7 +162,7 @@ unitTest(
unitTest(
{ ignore: Deno.build.os === "win", perms: { run: true } },
- async function signalShorthandsTest(): Promise<void> {
+ function signalShorthandsTest(): void {
let s: Deno.SignalStream;
s = Deno.signals.alarm(); // for SIGALRM
assert(s instanceof Deno.SignalStream);
diff --git a/cli/js/tests/stat_test.ts b/cli/js/tests/stat_test.ts
index e51204b6e..78582900e 100644
--- a/cli/js/tests/stat_test.ts
+++ b/cli/js/tests/stat_test.ts
@@ -3,9 +3,7 @@ import { unitTest, assert, assertEquals } from "./test_util.ts";
// TODO Add tests for modified, accessed, and created fields once there is a way
// to create temp files.
-unitTest({ perms: { read: true } }, async function statSyncSuccess(): Promise<
- void
-> {
+unitTest({ perms: { read: true } }, function statSyncSuccess(): void {
const packageInfo = Deno.statSync("README.md");
assert(packageInfo.isFile());
assert(!packageInfo.isSymlink());
@@ -19,9 +17,7 @@ unitTest({ perms: { read: true } }, async function statSyncSuccess(): Promise<
assert(!testsInfo.isSymlink());
});
-unitTest({ perms: { read: false } }, async function statSyncPerm(): Promise<
- void
-> {
+unitTest({ perms: { read: false } }, function statSyncPerm(): void {
let caughtError = false;
try {
Deno.statSync("README.md");
@@ -32,9 +28,7 @@ unitTest({ perms: { read: false } }, async function statSyncPerm(): Promise<
assert(caughtError);
});
-unitTest({ perms: { read: true } }, async function statSyncNotFound(): Promise<
- void
-> {
+unitTest({ perms: { read: true } }, function statSyncNotFound(): void {
let caughtError = false;
let badInfo;
@@ -49,9 +43,7 @@ unitTest({ perms: { read: true } }, async function statSyncNotFound(): Promise<
assertEquals(badInfo, undefined);
});
-unitTest({ perms: { read: true } }, async function lstatSyncSuccess(): Promise<
- void
-> {
+unitTest({ perms: { read: true } }, function lstatSyncSuccess(): void {
const packageInfo = Deno.lstatSync("README.md");
assert(packageInfo.isFile());
assert(!packageInfo.isSymlink());
@@ -65,9 +57,7 @@ unitTest({ perms: { read: true } }, async function lstatSyncSuccess(): Promise<
assert(!coreInfo.isSymlink());
});
-unitTest({ perms: { read: false } }, async function lstatSyncPerm(): Promise<
- void
-> {
+unitTest({ perms: { read: false } }, function lstatSyncPerm(): void {
let caughtError = false;
try {
Deno.lstatSync("README.md");
@@ -78,9 +68,7 @@ unitTest({ perms: { read: false } }, async function lstatSyncPerm(): Promise<
assert(caughtError);
});
-unitTest({ perms: { read: true } }, async function lstatSyncNotFound(): Promise<
- void
-> {
+unitTest({ perms: { read: true } }, function lstatSyncNotFound(): void {
let caughtError = false;
let badInfo;
@@ -185,7 +173,7 @@ unitTest({ perms: { read: true } }, async function lstatNotFound(): Promise<
unitTest(
{ ignore: Deno.build.os !== "win", perms: { read: true, write: true } },
- async function statNoUnixFields(): Promise<void> {
+ function statNoUnixFields(): void {
const enc = new TextEncoder();
const data = enc.encode("Hello");
const tempDir = Deno.makeTempDirSync();
@@ -206,7 +194,7 @@ unitTest(
unitTest(
{ ignore: Deno.build.os === "win", perms: { read: true, write: true } },
- async function statUnixFields(): Promise<void> {
+ function statUnixFields(): void {
const enc = new TextEncoder();
const data = enc.encode("Hello");
const tempDir = Deno.makeTempDirSync();
diff --git a/cli/js/tests/test_util.ts b/cli/js/tests/test_util.ts
index 42301cf72..980d32bac 100644
--- a/cli/js/tests/test_util.ts
+++ b/cli/js/tests/test_util.ts
@@ -328,7 +328,7 @@ unitTest(function permissionsMatches(): void {
*/
unitTest(
{ perms: { read: true } },
- async function assertAllUnitTestFilesImported(): Promise<void> {
+ function assertAllUnitTestFilesImported(): void {
const directoryTestFiles = Deno.readdirSync("./cli/js/tests/")
.map(k => k.name)
.filter(
diff --git a/cli/js/tests/timers_test.ts b/cli/js/tests/timers_test.ts
index 077e27ae6..b7da6a847 100644
--- a/cli/js/tests/timers_test.ts
+++ b/cli/js/tests/timers_test.ts
@@ -27,7 +27,7 @@ function deferred(): {
};
}
-async function waitForMs(ms: number): Promise<number> {
+function waitForMs(ms: number): Promise<number> {
return new Promise((resolve: () => void): number => setTimeout(resolve, ms));
}
@@ -158,7 +158,7 @@ unitTest(async function intervalOrdering(): Promise<void> {
assertEquals(timeouts, 1);
});
-unitTest(async function intervalCancelInvalidSilentFail(): Promise<void> {
+unitTest(function intervalCancelInvalidSilentFail(): void {
// Should silently fail (no panic)
clearInterval(2147483647);
});
@@ -234,7 +234,7 @@ unitTest(async function timeoutBindThis(): Promise<void> {
}
});
-unitTest(async function clearTimeoutShouldConvertToNumber(): Promise<void> {
+unitTest(function clearTimeoutShouldConvertToNumber(): void {
let called = false;
const obj = {
valueOf(): number {
diff --git a/cli/js/tests/tls_test.ts b/cli/js/tests/tls_test.ts
index b405a94dd..20dd62f9b 100644
--- a/cli/js/tests/tls_test.ts
+++ b/cli/js/tests/tls_test.ts
@@ -39,7 +39,7 @@ unitTest(async function connectTLSCertFileNoReadPerm(): Promise<void> {
unitTest(
{ perms: { read: true, net: true } },
- async function listenTLSNonExistentCertKeyFiles(): Promise<void> {
+ function listenTLSNonExistentCertKeyFiles(): void {
let err;
const options = {
hostname: "localhost",
@@ -70,30 +70,27 @@ unitTest(
}
);
-unitTest(
- { perms: { net: true } },
- async function listenTLSNoReadPerm(): Promise<void> {
- let err;
- try {
- Deno.listenTLS({
- hostname: "localhost",
- port: 4500,
- certFile: "cli/tests/tls/localhost.crt",
- keyFile: "cli/tests/tls/localhost.key"
- });
- } catch (e) {
- err = e;
- }
- assert(err instanceof Deno.errors.PermissionDenied);
- assertEquals(err.name, "PermissionDenied");
+unitTest({ perms: { net: true } }, function listenTLSNoReadPerm(): void {
+ let err;
+ try {
+ Deno.listenTLS({
+ hostname: "localhost",
+ port: 4500,
+ certFile: "cli/tests/tls/localhost.crt",
+ keyFile: "cli/tests/tls/localhost.key"
+ });
+ } catch (e) {
+ err = e;
}
-);
+ assert(err instanceof Deno.errors.PermissionDenied);
+ assertEquals(err.name, "PermissionDenied");
+});
unitTest(
{
perms: { read: true, write: true, net: true }
},
- async function listenTLSEmptyKeyFile(): Promise<void> {
+ function listenTLSEmptyKeyFile(): void {
let err;
const options = {
hostname: "localhost",
@@ -122,7 +119,7 @@ unitTest(
unitTest(
{ perms: { read: true, write: true, net: true } },
- async function listenTLSEmptyCertFile(): Promise<void> {
+ function listenTLSEmptyCertFile(): void {
let err;
const options = {
hostname: "localhost",
diff --git a/cli/js/web/body.ts b/cli/js/web/body.ts
index ed21fa0ec..03c35848a 100644
--- a/cli/js/web/body.ts
+++ b/cli/js/web/body.ts
@@ -306,7 +306,7 @@ export class Body implements domTypes.Body {
return JSON.parse(raw);
}
- public async arrayBuffer(): Promise<ArrayBuffer> {
+ public arrayBuffer(): Promise<ArrayBuffer> {
if (
this._bodySource instanceof Int8Array ||
this._bodySource instanceof Int16Array ||
@@ -318,20 +318,24 @@ export class Body implements domTypes.Body {
this._bodySource instanceof Float32Array ||
this._bodySource instanceof Float64Array
) {
- return this._bodySource.buffer as ArrayBuffer;
+ return Promise.resolve(this._bodySource.buffer as ArrayBuffer);
} else if (this._bodySource instanceof ArrayBuffer) {
- return this._bodySource;
+ return Promise.resolve(this._bodySource);
} else if (typeof this._bodySource === "string") {
const enc = new TextEncoder();
- return enc.encode(this._bodySource).buffer as ArrayBuffer;
+ return Promise.resolve(
+ enc.encode(this._bodySource).buffer as ArrayBuffer
+ );
} else if (this._bodySource instanceof ReadableStream) {
// @ts-ignore
return bufferFromStream(this._bodySource.getReader());
} else if (this._bodySource instanceof FormData) {
const enc = new TextEncoder();
- return enc.encode(this._bodySource.toString()).buffer as ArrayBuffer;
+ return Promise.resolve(
+ enc.encode(this._bodySource.toString()).buffer as ArrayBuffer
+ );
} else if (!this._bodySource) {
- return new ArrayBuffer(0);
+ return Promise.resolve(new ArrayBuffer(0));
}
throw new Error(
`Body type not yet implemented: ${this._bodySource.constructor.name}`
diff --git a/cli/js/web/fetch.ts b/cli/js/web/fetch.ts
index 7ab68d2e4..62e5d7928 100644
--- a/cli/js/web/fetch.ts
+++ b/cli/js/web/fetch.ts
@@ -60,6 +60,7 @@ class Body implements domTypes.Body, domTypes.ReadableStream, io.ReadCloser {
return this._data;
}
+ // eslint-disable-next-line require-await
async arrayBuffer(): Promise<ArrayBuffer> {
// If we've already bufferred the response, just return it.
if (this._data != null) {
@@ -223,11 +224,12 @@ class Body implements domTypes.Body, domTypes.ReadableStream, io.ReadCloser {
return read(this.rid, p);
}
- close(): void {
+ close(): Promise<void> {
close(this.rid);
+ return Promise.resolve();
}
- async cancel(): Promise<void> {
+ cancel(): Promise<void> {
return notImplemented();
}
@@ -346,7 +348,7 @@ export class Response implements domTypes.Response {
return false;
}
- async arrayBuffer(): Promise<ArrayBuffer> {
+ arrayBuffer(): Promise<ArrayBuffer> {
/* You have to do the null check here and not in the function because
* otherwise TS complains about this.body potentially being null */
if (this.bodyViewable() || this.body == null) {
@@ -355,14 +357,14 @@ export class Response implements domTypes.Response {
return this.body.arrayBuffer();
}
- async blob(): Promise<domTypes.Blob> {
+ blob(): Promise<domTypes.Blob> {
if (this.bodyViewable() || this.body == null) {
return Promise.reject(new Error("Response body is null"));
}
return this.body.blob();
}
- async formData(): Promise<domTypes.FormData> {
+ formData(): Promise<domTypes.FormData> {
if (this.bodyViewable() || this.body == null) {
return Promise.reject(new Error("Response body is null"));
}
@@ -370,14 +372,14 @@ export class Response implements domTypes.Response {
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- async json(): Promise<any> {
+ json(): Promise<any> {
if (this.bodyViewable() || this.body == null) {
return Promise.reject(new Error("Response body is null"));
}
return this.body.json();
}
- async text(): Promise<string> {
+ text(): Promise<string> {
if (this.bodyViewable() || this.body == null) {
return Promise.reject(new Error("Response body is null"));
}
@@ -437,7 +439,7 @@ export class Response implements domTypes.Response {
}
}
-async function sendFetchReq(
+function sendFetchReq(
url: string,
method: string | null,
headers: domTypes.Headers | null,