mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 02:22:40 +00:00
BREAKING: Remove Deno.EOF, use null instead (#4953)
This commit is contained in:
parent
47c2f034e9
commit
678313b176
46 changed files with 329 additions and 325 deletions
13
cli/js/io.ts
13
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue