Skip to content

Commit

Permalink
refactor(streams): prepare for noUncheckedIndexedAccess (#4377)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabelluardo authored Feb 24, 2024
1 parent 58cb4ba commit 271a100
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion streams/_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function createLPS(pat: Uint8Array): Uint8Array {
lps[i] = 0;
i++;
} else {
prefixEnd = lps[prefixEnd - 1];
prefixEnd = lps[prefixEnd - 1]!;
}
}
return lps;
Expand Down
10 changes: 5 additions & 5 deletions streams/delimiter_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class DelimiterStream extends TransformStream<Uint8Array, Uint8Array> {
// they are (with concatenation).
if (bufs.length === 1) {
// Concat not needed when a single buffer is passed.
controller.enqueue(bufs[0]);
controller.enqueue(bufs[0]!);
} else {
controller.enqueue(concat(bufs));
}
Expand All @@ -134,7 +134,7 @@ export class DelimiterStream extends TransformStream<Uint8Array, Uint8Array> {
} else if (delimitedChunkEnd < 0 && bufs.length > 0) {
// Our chunk started by finishing a partial delimiter match.
const lastIndex = bufs.length - 1;
const last = bufs[lastIndex];
const last = bufs[lastIndex]!;
const lastSliceIndex = last.byteLength + delimitedChunkEnd;
const lastSliced = last.subarray(0, lastSliceIndex);
if (lastIndex === 0) {
Expand Down Expand Up @@ -173,7 +173,7 @@ export class DelimiterStream extends TransformStream<Uint8Array, Uint8Array> {
// but now got a new 'A', then we'll drop down to having matched
// just 'A'. The while loop will turn around again and we'll rematch
// to 'AA' and proceed onwards to try and match on 'B' again.
matchIndex = lps[matchIndex - 1];
matchIndex = lps[matchIndex - 1]!;
}
}
// Save match index.
Expand Down Expand Up @@ -231,7 +231,7 @@ export class DelimiterStream extends TransformStream<Uint8Array, Uint8Array> {
// they are (with concatenation).
if (bufs.length === 1) {
// Concat not needed when a single buffer is passed.
controller.enqueue(bufs[0]);
controller.enqueue(bufs[0]!);
} else {
controller.enqueue(concat(bufs));
}
Expand Down Expand Up @@ -275,7 +275,7 @@ export class DelimiterStream extends TransformStream<Uint8Array, Uint8Array> {
if (length === 0) {
controller.enqueue(new Uint8Array());
} else if (length === 1) {
controller.enqueue(bufs[0]);
controller.enqueue(bufs[0]!);
} else {
controller.enqueue(concat(bufs));
}
Expand Down
4 changes: 2 additions & 2 deletions streams/merge_readable_streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export function mergeReadableStreams<T>(
}
controller.enqueue(data);
}
resolvePromises[index].resolve();
resolvePromises[index]!.resolve();
} catch (error) {
resolvePromises[index].reject(error);
resolvePromises[index]!.reject(error);
}
})();
}
Expand Down
2 changes: 1 addition & 1 deletion streams/text_delimiter_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class TextDelimiterStream extends TransformStream<string, string> {
this.#inspectIndex++;
localIndex++;
} else {
this.#matchIndex = this.#delimLPS[this.#matchIndex - 1];
this.#matchIndex = this.#delimLPS[this.#matchIndex - 1]!;
}
}
}
Expand Down

0 comments on commit 271a100

Please sign in to comment.