Skip to content

Commit

Permalink
refactor(io): prepare for noUncheckedIndexedAccess (#4470)
Browse files Browse the repository at this point in the history
* refactor(io): prepare for `noUncheckedIndexedAccess`

* tweak

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
  • Loading branch information
gabelluardo and iuioiua authored Mar 12, 2024
1 parent 4da7440 commit 57605ec
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion io/buf_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export class BufReader implements Reader {
if (this.#eof) return null;
await this.#fill(); // buffer is empty.
}
const c = this.#buf[this.#r];
const c = this.#buf[this.#r]!;
this.#r++;
// this.lastByte = c;
return c;
Expand Down
4 changes: 2 additions & 2 deletions io/buf_writer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Deno.test({

await bufWriter.flush();
const buf = new Uint8Array(cache.length);
for (let i = 0; i < cache.length; i++) buf.set(cache[i], i);
for (const [i, val] of cache.entries()) buf.set(val, i);

assertEquals(data, buf);
},
Expand All @@ -154,7 +154,7 @@ Deno.test({

bufWriter.flush();
const buf = new Uint8Array(cache.length);
for (let i = 0; i < cache.length; i++) buf.set(cache[i], i);
for (const [i, val] of cache.entries()) buf.set(val, i);

assertEquals(data, buf);
},
Expand Down
4 changes: 2 additions & 2 deletions io/read_delim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function createLPS(pat: Uint8Array): Uint8Array {
lps[i] = 0;
i++;
} else {
prefixEnd = lps[prefixEnd - 1];
prefixEnd = lps[prefixEnd - 1]!;
}
}
return lps;
Expand Down Expand Up @@ -76,7 +76,7 @@ export async function* readDelim(
inspectIndex++;
localIndex++;
} else {
matchIndex = delimLPS[matchIndex - 1];
matchIndex = delimLPS[matchIndex - 1]!;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion io/string_writer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@ Deno.test("ioStringWriterIsolationTest", async function () {
const written = await w.write(c);
assertEquals(written, 1);
}
srcChunks[0][0] = 88;
assertEquals(w.toString(), src);
});

0 comments on commit 57605ec

Please sign in to comment.