summaryrefslogtreecommitdiff
path: root/cli/js
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2020-04-28 17:40:43 +0100
committerGitHub <noreply@github.com>2020-04-28 12:40:43 -0400
commit678313b17677e012ba9a07aeca58af1aafbf4e8c (patch)
treee48e25b165a7d6d566095442448f2e36fa09c561 /cli/js
parent47c2f034e95696a47770d60aec1362501e7f330d (diff)
BREAKING: Remove Deno.EOF, use null instead (#4953)
Diffstat (limited to 'cli/js')
-rw-r--r--cli/js/buffer.ts12
-rw-r--r--cli/js/deno.ts1
-rw-r--r--cli/js/files.ts9
-rw-r--r--cli/js/io.ts13
-rw-r--r--cli/js/lib.deno.ns.d.ts76
-rw-r--r--cli/js/net.ts4
-rw-r--r--cli/js/ops/io.ts9
-rw-r--r--cli/js/tests/buffer_test.ts5
-rw-r--r--cli/js/tests/files_test.ts8
-rw-r--r--cli/js/tests/io_test.ts2
-rw-r--r--cli/js/tests/net_test.ts16
-rw-r--r--cli/js/tests/process_test.ts14
-rw-r--r--cli/js/tests/tls_test.ts6
-rw-r--r--cli/js/web/fetch.ts2
14 files changed, 85 insertions, 92 deletions
diff --git a/cli/js/buffer.ts b/cli/js/buffer.ts
index e2a7e3de9..fdacf70a9 100644
--- a/cli/js/buffer.ts
+++ b/cli/js/buffer.ts
@@ -4,7 +4,7 @@
// Copyright 2009 The Go Authors. All rights reserved. BSD license.
// https://github.com/golang/go/blob/master/LICENSE
-import { Reader, Writer, EOF, ReaderSync, WriterSync } from "./io.ts";
+import { Reader, Writer, ReaderSync, WriterSync } from "./io.ts";
import { assert } from "./util.ts";
import { TextDecoder } from "./web/text_encoding.ts";
@@ -91,7 +91,7 @@ export class Buffer implements Reader, ReaderSync, Writer, WriterSync {
this.#buf = new Uint8Array(this.#buf.buffer, 0, len);
};
- readSync(p: Uint8Array): number | EOF {
+ readSync(p: Uint8Array): number | null {
if (this.empty()) {
// Buffer is empty, reset to recover space.
this.reset();
@@ -99,14 +99,14 @@ export class Buffer implements Reader, ReaderSync, Writer, WriterSync {
// this edge case is tested in 'bufferReadEmptyAtEOF' test
return 0;
}
- return EOF;
+ return null;
}
const nread = copyBytes(p, this.#buf.subarray(this.#off));
this.#off += nread;
return nread;
}
- read(p: Uint8Array): Promise<number | EOF> {
+ read(p: Uint8Array): Promise<number | null> {
const rr = this.readSync(p);
return Promise.resolve(rr);
}
@@ -169,7 +169,7 @@ export class Buffer implements Reader, ReaderSync, Writer, WriterSync {
this.#reslice(i);
const fub = new Uint8Array(this.#buf.buffer, i);
const nread = await r.read(fub);
- if (nread === EOF) {
+ if (nread === null) {
return n;
}
this.#reslice(i + nread);
@@ -188,7 +188,7 @@ export class Buffer implements Reader, ReaderSync, Writer, WriterSync {
this.#reslice(i);
const fub = new Uint8Array(this.#buf.buffer, i);
const nread = r.readSync(fub);
- if (nread === EOF) {
+ if (nread === null) {
return n;
}
this.#reslice(i + nread);
diff --git a/cli/js/deno.ts b/cli/js/deno.ts
index 3e1a2b263..0e8057b72 100644
--- a/cli/js/deno.ts
+++ b/cli/js/deno.ts
@@ -40,7 +40,6 @@ export { read, readSync, write, writeSync } from "./ops/io.ts";
export { FsEvent, watchFs } from "./ops/fs_events.ts";
export { internalSymbol as internal } from "./internals.ts";
export {
- EOF,
copy,
iter,
iterSync,
diff --git a/cli/js/files.ts b/cli/js/files.ts
index 46d6c8a85..d6df8bad0 100644
--- a/cli/js/files.ts
+++ b/cli/js/files.ts
@@ -1,6 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import {
- EOF,
Reader,
Writer,
Seeker,
@@ -76,11 +75,11 @@ export class File
return writeSync(this.rid, p);
}
- read(p: Uint8Array): Promise<number | EOF> {
+ read(p: Uint8Array): Promise<number | null> {
return read(this.rid, p);
}
- readSync(p: Uint8Array): number | EOF {
+ readSync(p: Uint8Array): number | null {
return readSync(this.rid, p);
}
@@ -103,11 +102,11 @@ class Stdin implements Reader, ReaderSync, Closer {
this.rid = 0;
}
- read(p: Uint8Array): Promise<number | EOF> {
+ read(p: Uint8Array): Promise<number | null> {
return read(this.rid, p);
}
- readSync(p: Uint8Array): number | EOF {
+ readSync(p: Uint8Array): number | null {
return readSync(this.rid, p);
}
diff --git a/cli/js/io.ts b/cli/js/io.ts
index 0b7720682..72c90d047 100644
--- a/cli/js/io.ts
+++ b/cli/js/io.ts
@@ -3,9 +3,6 @@
// Documentation liberally lifted from them too.
// Thank you! We love Go!
-export const EOF: unique symbol = Symbol("EOF");
-export type EOF = typeof EOF;
-
const DEFAULT_BUFFER_SIZE = 32 * 1024;
// Seek whence values.
@@ -19,11 +16,11 @@ export enum SeekMode {
// Reader is the interface that wraps the basic read() method.
// https://golang.org/pkg/io/#Reader
export interface Reader {
- read(p: Uint8Array): Promise<number | EOF>;
+ read(p: Uint8Array): Promise<number | null>;
}
export interface ReaderSync {
- readSync(p: Uint8Array): number | EOF;
+ readSync(p: Uint8Array): number | null;
}
// Writer is the interface that wraps the basic write() method.
@@ -65,7 +62,7 @@ export async function copy(
let gotEOF = false;
while (gotEOF === false) {
const result = await src.read(b);
- if (result === EOF) {
+ if (result === null) {
gotEOF = true;
} else {
n += await dst.write(b.subarray(0, result));
@@ -84,7 +81,7 @@ export async function* iter(
const b = new Uint8Array(bufSize);
while (true) {
const result = await r.read(b);
- if (result === EOF) {
+ if (result === null) {
break;
}
@@ -102,7 +99,7 @@ export function* iterSync(
const b = new Uint8Array(bufSize);
while (true) {
const result = r.readSync(b);
- if (result === EOF) {
+ if (result === null) {
break;
}
diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts
index 4626f6214..5defc5732 100644
--- a/cli/js/lib.deno.ns.d.ts
+++ b/cli/js/lib.deno.ns.d.ts
@@ -361,10 +361,6 @@ declare namespace Deno {
*/
export function umask(mask?: number): number;
- /** **UNSTABLE**: might be removed in favor of `null` (#3932). */
- export const EOF: unique symbol;
- export type EOF = typeof EOF;
-
export enum SeekMode {
Start = 0,
Current = 1,
@@ -379,20 +375,21 @@ declare namespace Deno {
* available but not `p.byteLength` bytes, `read()` conventionally resolves
* to what is available instead of waiting for more.
*
- * When `read()` encounters end-of-file condition, it resolves to
- * `Deno.EOF` symbol.
+ * When `read()` encounters end-of-file condition, it resolves to EOF
+ * (`null`).
*
* When `read()` encounters an error, it rejects with an error.
*
* Callers should always process the `n` > `0` bytes returned before
- * considering the `EOF`. Doing so correctly handles I/O errors that happen
- * after reading some bytes and also both of the allowed EOF behaviors.
+ * considering the EOF (`null`). Doing so correctly handles I/O errors that
+ * happen after reading some bytes and also both of the allowed EOF
+ * behaviors.
*
* Implementations should not retain a reference to `p`.
*
* Use Deno.iter() to turn a Reader into an AsyncIterator.
*/
- read(p: Uint8Array): Promise<number | EOF>;
+ read(p: Uint8Array): Promise<number | null>;
}
export interface ReaderSync {
@@ -403,20 +400,20 @@ declare namespace Deno {
* but not `p.byteLength` bytes, `read()` conventionally returns what is
* available instead of waiting for more.
*
- * When `readSync()` encounters end-of-file condition, it returns `Deno.EOF`
- * symbol.
+ * When `readSync()` encounters end-of-file condition, it returns EOF
+ * (`null`).
*
* When `readSync()` encounters an error, it throws with an error.
*
* Callers should always process the `n` > `0` bytes returned before
- * considering the `EOF`. Doing so correctly handles I/O errors that happen
+ * considering the EOF (`null`). Doing so correctly handles I/O errors that happen
* after reading some bytes and also both of the allowed EOF behaviors.
*
* Implementations should not retain a reference to `p`.
*
* Use Deno.iterSync() to turn a ReaderSync into an Iterator.
*/
- readSync(p: Uint8Array): number | EOF;
+ readSync(p: Uint8Array): number | null;
}
export interface Writer {
@@ -477,8 +474,8 @@ declare namespace Deno {
seekSync(offset: number, whence: SeekMode): number;
}
- /** Copies from `src` to `dst` until either `EOF` is reached on `src` or an
- * error occurs. It resolves to the number of bytes copied or rejects with
+ /** Copies from `src` to `dst` until either EOF (`null`) is read from `src` or
+ * an error occurs. It resolves to the number of bytes copied or rejects with
* the first error encountered while copying.
*
* const source = await Deno.open("my_file.txt");
@@ -486,9 +483,6 @@ declare namespace Deno {
* const bytesCopied1 = await Deno.copy(source, Deno.stdout);
* const bytesCopied2 = await Deno.copy(source, buffer);
*
- * Because `copy()` is defined to read from `src` until `EOF`, it does not
- * treat an `EOF` from `read()` as an error to be reported.
- *
* @param src The source to copy from
* @param dst The destination to copy to
* @param options Can be used to tune size of the buffer. Default size is 32kB
@@ -611,8 +605,11 @@ declare namespace Deno {
/** Synchronously read from a resource ID (`rid`) into an array buffer (`buffer`).
*
- * Returns either the number of bytes read during the operation or End Of File
- * (`Symbol(EOF)`) if there was nothing to read.
+ * Returns either the number of bytes read during the operation or EOF
+ * (`null`) if there was nothing more to read.
+ *
+ * It is possible for a read to successfully return with `0` bytes. This does
+ * not indicate EOF.
*
* // if "/foo/bar.txt" contains the text "hello world":
* const file = Deno.openSync("/foo/bar.txt");
@@ -621,12 +618,15 @@ declare namespace Deno {
* const text = new TextDecoder().decode(buf); // "hello world"
* Deno.close(file.rid);
*/
- export function readSync(rid: number, buffer: Uint8Array): number | EOF;
+ export function readSync(rid: number, buffer: Uint8Array): number | null;
/** Read from a resource ID (`rid`) into an array buffer (`buffer`).
*
- * Resolves to either the number of bytes read during the operation or End Of
- * File (`Symbol(EOF)`) if there was nothing to read.
+ * Resolves to either the number of bytes read during the operation or EOF
+ * (`null`) if there was nothing more to read.
+ *
+ * It is possible for a read to successfully return with `0` bytes. This does
+ * not indicate EOF.
*
* // if "/foo/bar.txt" contains the text "hello world":
* const file = await Deno.open("/foo/bar.txt");
@@ -635,7 +635,7 @@ declare namespace Deno {
* const text = new TextDecoder().decode(buf); // "hello world"
* Deno.close(file.rid);
*/
- export function read(rid: number, buffer: Uint8Array): Promise<number | EOF>;
+ export function read(rid: number, buffer: Uint8Array): Promise<number | null>;
/** Synchronously write to the resource ID (`rid`) the contents of the array
* buffer (`data`).
@@ -743,8 +743,8 @@ declare namespace Deno {
constructor(rid: number);
write(p: Uint8Array): Promise<number>;
writeSync(p: Uint8Array): number;
- read(p: Uint8Array): Promise<number | EOF>;
- readSync(p: Uint8Array): number | EOF;
+ read(p: Uint8Array): Promise<number | null>;
+ readSync(p: Uint8Array): number | null;
seek(offset: number, whence: SeekMode): Promise<number>;
seekSync(offset: number, whence: SeekMode): number;
close(): void;
@@ -863,12 +863,12 @@ declare namespace Deno {
reset(): void;
/** Reads the next `p.length` bytes from the buffer or until the buffer is
* drained. Returns the number of bytes read. If the buffer has no data to
- * return, the return is `Deno.EOF`. */
- readSync(p: Uint8Array): number | EOF;
+ * return, the return is EOF (`null`). */
+ readSync(p: Uint8Array): number | null;
/** Reads the next `p.length` bytes from the buffer or until the buffer is
* drained. Resolves to the number of bytes read. If the buffer has no
- * data to return, resolves to `Deno.EOF`. */
- read(p: Uint8Array): Promise<number | EOF>;
+ * data to return, resolves to EOF (`null`). */
+ read(p: Uint8Array): Promise<number | null>;
writeSync(p: Uint8Array): number;
write(p: Uint8Array): Promise<number>;
/** Grows the buffer's capacity, if necessary, to guarantee space for
@@ -879,14 +879,14 @@ declare namespace Deno {
* Based on Go Lang's
* [Buffer.Grow](https://golang.org/pkg/bytes/#Buffer.Grow). */
grow(n: number): void;
- /** Reads data from `r` until `Deno.EOF` and appends it to the buffer,
+ /** Reads data from `r` until EOF (`null`) and appends it to the buffer,
* growing the buffer as needed. It resolves to the number of bytes read.
* If the buffer becomes too large, `.readFrom()` will reject with an error.
*
* Based on Go Lang's
* [Buffer.ReadFrom](https://golang.org/pkg/bytes/#Buffer.ReadFrom). */
readFrom(r: Reader): Promise<number>;
- /** Reads data from `r` until `Deno.EOF` and appends it to the buffer,
+ /** Reads data from `r` until EOF (`null`) and appends it to the buffer,
* growing the buffer as needed. It returns the number of bytes read. If the
* buffer becomes too large, `.readFromSync()` will throw an error.
*
@@ -895,8 +895,8 @@ declare namespace Deno {
readFromSync(r: ReaderSync): number;
}
- /** Read Reader `r` until end of file (`Deno.EOF`) and resolve to the content
- * as `Uint8Array`.
+ /** Read Reader `r` until EOF (`null`) and resolve to the content as
+ * Uint8Array`.
*
* // Example from stdin
* const stdinContent = await Deno.readAll(Deno.stdin);
@@ -914,8 +914,8 @@ declare namespace Deno {
*/
export function readAll(r: Reader): Promise<Uint8Array>;
- /** Synchronously reads Reader `r` until end of file (`Deno.EOF`) and returns
- * the content as `Uint8Array`.
+ /** Synchronously reads Reader `r` until EOF (`null`) and returns the content
+ * as `Uint8Array`.
*
* // Example from stdin
* const stdinContent = Deno.readAllSync(Deno.stdin);
@@ -2183,13 +2183,13 @@ declare namespace Deno {
readonly stderr?: Reader & Closer;
/** Resolves to the current status of the process. */
status(): Promise<ProcessStatus>;
- /** Buffer the stdout and return it as `Uint8Array` after `Deno.EOF`.
+ /** Buffer the stdout until EOF and return it as `Uint8Array`.
*
* You must set stdout to `"piped"` when creating the process.
*
* This calls `close()` on stdout after its done. */
output(): Promise<Uint8Array>;
- /** Buffer the stderr and return it as `Uint8Array` after `Deno.EOF`.
+ /** Buffer the stderr until EOF and return it as `Uint8Array`.
*
* You must set stderr to `"piped"` when creating the process.
*
diff --git a/cli/js/net.ts b/cli/js/net.ts
index 6f6736ee2..3ca1219e6 100644
--- a/cli/js/net.ts
+++ b/cli/js/net.ts
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { errors } from "./errors.ts";
-import { EOF, Reader, Writer, Closer } from "./io.ts";
+import { Reader, Writer, Closer } from "./io.ts";
import { read, write } from "./ops/io.ts";
import { close } from "./ops/resources.ts";
import * as netOps from "./ops/net.ts";
@@ -40,7 +40,7 @@ export class ConnImpl implements Conn {
return write(this.rid, p);
}
- read(p: Uint8Array): Promise<number | EOF> {
+ read(p: Uint8Array): Promise<number | null> {
return read(this.rid, p);
}
diff --git a/cli/js/ops/io.ts b/cli/js/ops/io.ts
index 16b42bfbc..b4ef837e0 100644
--- a/cli/js/ops/io.ts
+++ b/cli/js/ops/io.ts
@@ -1,7 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendAsyncMinimal, sendSyncMinimal } from "./dispatch_minimal.ts";
-import { EOF } from "../io.ts";
// TODO(bartlomieju): remove this import and maybe lazy-initialize
// OPS_CACHE that belongs only to this module
import { OPS_CACHE } from "../runtime.ts";
@@ -10,7 +9,7 @@ import { OPS_CACHE } from "../runtime.ts";
let OP_READ = -1;
let OP_WRITE = -1;
-export function readSync(rid: number, buffer: Uint8Array): number | EOF {
+export function readSync(rid: number, buffer: Uint8Array): number | null {
if (buffer.length == 0) {
return 0;
}
@@ -21,7 +20,7 @@ export function readSync(rid: number, buffer: Uint8Array): number | EOF {
if (nread < 0) {
throw new Error("read error");
} else if (nread == 0) {
- return EOF;
+ return null;
} else {
return nread;
}
@@ -30,7 +29,7 @@ export function readSync(rid: number, buffer: Uint8Array): number | EOF {
export async function read(
rid: number,
buffer: Uint8Array
-): Promise<number | EOF> {
+): Promise<number | null> {
if (buffer.length == 0) {
return 0;
}
@@ -41,7 +40,7 @@ export async function read(
if (nread < 0) {
throw new Error("read error");
} else if (nread == 0) {
- return EOF;
+ return null;
} else {
return nread;
}
diff --git a/cli/js/tests/buffer_test.ts b/cli/js/tests/buffer_test.ts
index 9cfb71669..e45bcb976 100644
--- a/cli/js/tests/buffer_test.ts
+++ b/cli/js/tests/buffer_test.ts
@@ -65,7 +65,7 @@ async function empty(buf: Buffer, s: string, fub: Uint8Array): Promise<void> {
check(buf, s);
while (true) {
const r = await buf.read(fub);
- if (r === Deno.EOF) {
+ if (r === null) {
break;
}
s = s.slice(r);
@@ -231,8 +231,7 @@ unitTest(async function bufferTestGrow(): Promise<void> {
for (const growLen of [0, 100, 1000, 10000, 100000]) {
const buf = new Buffer(xBytes.buffer as ArrayBuffer);
// If we read, this affects buf.off, which is good to test.
- const result = await buf.read(tmp);
- const nread = result === Deno.EOF ? 0 : result;
+ const nread = (await buf.read(tmp)) ?? 0;
buf.grow(growLen);
const yBytes = repeat("y", growLen);
await buf.write(yBytes);
diff --git a/cli/js/tests/files_test.ts b/cli/js/tests/files_test.ts
index 8952166db..a035c7074 100644
--- a/cli/js/tests/files_test.ts
+++ b/cli/js/tests/files_test.ts
@@ -101,13 +101,13 @@ unitTest(async function readerIter(): Promise<void> {
this.#buf = new Uint8Array(encoder.encode(s));
}
- read(p: Uint8Array): Promise<number | Deno.EOF> {
+ read(p: Uint8Array): Promise<number | null> {
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 Promise.resolve(Deno.EOF);
+ return Promise.resolve(null);
}
return Promise.resolve(n);
@@ -136,13 +136,13 @@ unitTest(async function readerIterSync(): Promise<void> {
this.#buf = new Uint8Array(encoder.encode(s));
}
- readSync(p: Uint8Array): number | Deno.EOF {
+ readSync(p: Uint8Array): number | null {
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 null;
}
return n;
diff --git a/cli/js/tests/io_test.ts b/cli/js/tests/io_test.ts
index 5b6e860be..d6d6e35d1 100644
--- a/cli/js/tests/io_test.ts
+++ b/cli/js/tests/io_test.ts
@@ -19,7 +19,7 @@ function spyRead(obj: Deno.Buffer): Spy {
const orig = obj.read.bind(obj);
- obj.read = (p: Uint8Array): Promise<number | Deno.EOF> => {
+ obj.read = (p: Uint8Array): Promise<number | null> => {
spy.calls++;
return orig(p);
};
diff --git a/cli/js/tests/net_test.ts b/cli/js/tests/net_test.ts
index 8840730a8..ef3cd833d 100644
--- a/cli/js/tests/net_test.ts
+++ b/cli/js/tests/net_test.ts
@@ -179,10 +179,10 @@ unitTest({ perms: { net: true } }, async function netTcpDialListen(): Promise<
assertEquals(3, buf[2]);
assert(conn.rid > 0);
- assert(readResult !== Deno.EOF);
+ assert(readResult !== null);
const readResult2 = await conn.read(buf);
- assertEquals(Deno.EOF, readResult2);
+ assertEquals(readResult2, null);
listener.close();
conn.close();
@@ -214,10 +214,10 @@ unitTest(
assertEquals(3, buf[2]);
assert(conn.rid > 0);
- assert(readResult !== Deno.EOF);
+ assert(readResult !== null);
const readResult2 = await conn.read(buf);
- assertEquals(Deno.EOF, readResult2);
+ assertEquals(readResult2, null);
listener.close();
conn.close();
@@ -358,10 +358,10 @@ unitTest(
assertEquals(3, buf[2]);
assert(conn.rid > 0);
- assert(readResult !== Deno.EOF);
+ assert(readResult !== null);
const readResult2 = await conn.read(buf);
- assertEquals(Deno.EOF, readResult2);
+ assertEquals(readResult2, null);
listener.close();
conn.close();
@@ -396,7 +396,7 @@ unitTest(
closeReadDeferred.resolve();
const buf = new Uint8Array(1024);
const readResult = await conn.read(buf);
- assertEquals(Deno.EOF, readResult); // with immediate EOF
+ assertEquals(readResult, null); // with immediate EOF
// Ensure closeRead does not impact write
await conn.write(new Uint8Array([4, 5, 6]));
await closeDeferred;
@@ -523,7 +523,7 @@ unitTest(
try {
while (true) {
const nread = await conn.read(p);
- if (nread === Deno.EOF) {
+ if (nread === null) {
break;
}
await conn.write(new Uint8Array([1, 2, 3]));
diff --git a/cli/js/tests/process_test.ts b/cli/js/tests/process_test.ts
index f0615193b..b70ce8307 100644
--- a/cli/js/tests/process_test.ts
+++ b/cli/js/tests/process_test.ts
@@ -154,14 +154,14 @@ unitTest({ perms: { run: true } }, async function runStdoutPiped(): Promise<
const data = new Uint8Array(10);
let r = await p.stdout!.read(data);
- if (r === Deno.EOF) {
- throw new Error("p.stdout.read(...) should not be EOF");
+ if (r === null) {
+ throw new Error("p.stdout.read(...) should not be null");
}
assertEquals(r, 5);
const s = new TextDecoder().decode(data.subarray(0, r));
assertEquals(s, "hello");
r = await p.stdout!.read(data);
- assertEquals(r, Deno.EOF);
+ assertEquals(r, null);
p.stdout!.close();
const status = await p.status();
@@ -183,14 +183,14 @@ unitTest({ perms: { run: true } }, async function runStderrPiped(): Promise<
const data = new Uint8Array(10);
let r = await p.stderr!.read(data);
- if (r === Deno.EOF) {
- throw new Error("p.stderr.read should not return EOF here");
+ if (r === null) {
+ throw new Error("p.stderr.read should not return null here");
}
assertEquals(r, 5);
const s = new TextDecoder().decode(data.subarray(0, r));
assertEquals(s, "hello");
r = await p.stderr!.read(data);
- assertEquals(r, Deno.EOF);
+ assertEquals(r, null);
p.stderr!.close();
const status = await p.status();
@@ -313,7 +313,7 @@ unitTest({ perms: { run: true } }, async function runClose(): Promise<void> {
const data = new Uint8Array(10);
const r = await p.stderr!.read(data);
- assertEquals(r, Deno.EOF);
+ assertEquals(r, null);
p.stderr!.close();
});
diff --git a/cli/js/tests/tls_test.ts b/cli/js/tests/tls_test.ts
index ce44beac0..b971ccf5c 100644
--- a/cli/js/tests/tls_test.ts
+++ b/cli/js/tests/tls_test.ts
@@ -191,7 +191,7 @@ unitTest(
await w.flush();
const tpr = new TextProtoReader(r);
const statusLine = await tpr.readLine();
- assert(statusLine !== Deno.EOF, `line must be read: ${String(statusLine)}`);
+ assert(statusLine !== null, `line must be read: ${String(statusLine)}`);
const m = statusLine.match(/^(.+?) (.+?) (.+?)$/);
assert(m !== null, "must be matched");
const [_, proto, status, ok] = m;
@@ -199,7 +199,7 @@ unitTest(
assertEquals(status, "200");
assertEquals(ok, "OK");
const headers = await tpr.readMIMEHeader();
- assert(headers !== Deno.EOF);
+ assert(headers !== null);
const contentLength = parseInt(headers.get("content-length")!);
const bodyBuf = new Uint8Array(contentLength);
await r.readFull(bodyBuf);
@@ -225,7 +225,7 @@ unitTest(
let writer = new BufWriter(conn);
let reader = new TextProtoReader(new BufReader(conn));
- let line: string | Deno.EOF = (await reader.readLine()) as string;
+ let line: string | null = (await reader.readLine()) as string;
assert(line.startsWith("220"));
await writer.write(encoder.encode(`EHLO ${hostname}\r\n`));
diff --git a/cli/js/web/fetch.ts b/cli/js/web/fetch.ts
index 60dafa150..cbedcabfd 100644
--- a/cli/js/web/fetch.ts
+++ b/cli/js/web/fetch.ts
@@ -220,7 +220,7 @@ class Body
return decoder.decode(ab);
}
- read(p: Uint8Array): Promise<number | io.EOF> {
+ read(p: Uint8Array): Promise<number | null> {
this.#bodyUsed = true;
return read(this.#rid, p);
}