mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 04:39:10 +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
|
@ -64,12 +64,12 @@ async function readRecord(
|
|||
Startline: number,
|
||||
reader: BufReader,
|
||||
opt: ReadOptions = { comma: ",", trimLeadingSpace: false }
|
||||
): Promise<string[] | Deno.EOF> {
|
||||
): Promise<string[] | null> {
|
||||
const tp = new TextProtoReader(reader);
|
||||
const lineIndex = Startline;
|
||||
let line = await readLine(tp);
|
||||
|
||||
if (line === Deno.EOF) return Deno.EOF;
|
||||
if (line === null) return null;
|
||||
if (line.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ async function readRecord(
|
|||
// Hit end of line (copy all data so far).
|
||||
recordBuffer += line;
|
||||
const r = await readLine(tp);
|
||||
if (r === Deno.EOF) {
|
||||
if (r === null) {
|
||||
if (!opt.lazyQuotes) {
|
||||
quoteError = ERR_QUOTE;
|
||||
break parseField;
|
||||
|
@ -182,13 +182,13 @@ async function readRecord(
|
|||
}
|
||||
|
||||
async function isEOF(tp: TextProtoReader): Promise<boolean> {
|
||||
return (await tp.r.peek(0)) === Deno.EOF;
|
||||
return (await tp.r.peek(0)) === null;
|
||||
}
|
||||
|
||||
async function readLine(tp: TextProtoReader): Promise<string | Deno.EOF> {
|
||||
async function readLine(tp: TextProtoReader): Promise<string | null> {
|
||||
let line: string;
|
||||
const r = await tp.readLine();
|
||||
if (r === Deno.EOF) return Deno.EOF;
|
||||
if (r === null) return null;
|
||||
line = r;
|
||||
|
||||
// For backwards compatibility, drop trailing \r before EOF.
|
||||
|
@ -226,7 +226,7 @@ export async function readMatrix(
|
|||
|
||||
for (;;) {
|
||||
const r = await readRecord(lineIndex, reader, opt);
|
||||
if (r === Deno.EOF) break;
|
||||
if (r === null) break;
|
||||
lineResult = r;
|
||||
lineIndex++;
|
||||
// If fieldsPerRecord is 0, Read sets it to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue