MCPcopy Create free account
hub / github.com/denoland/std / #readLine

Method #readLine

csv/parse.ts:43–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41 };
42 }
43 #readLine(): string | null {
44 if (this.#isEOF()) return null;
45
46 let buffer = "";
47 let hadNewline = false;
48 while (this.#cursor < this.#input.length) {
49 if (this.#input.startsWith("\r\n", this.#cursor)) {
50 hadNewline = true;
51 this.#cursor += 2;
52 break;
53 }
54 if (
55 this.#input.startsWith("\n", this.#cursor)
56 ) {
57 hadNewline = true;
58 this.#cursor += 1;
59 break;
60 }
61 buffer += this.#input[this.#cursor];
62 this.#cursor += 1;
63 }
64 if (!hadNewline && buffer.endsWith("\r")) {
65 buffer = buffer.slice(0, -1);
66 }
67
68 return buffer;
69 }
70 #isEOF(): boolean {
71 return this.#cursor >= this.#input.length;
72 }

Callers 1

#parseRecordMethod · 0.95

Calls 3

#isEOFMethod · 0.95
startsWithMethod · 0.80
sliceMethod · 0.45

Tested by

no test coverage detected