Skip to content

Commit

Permalink
ci: fix types
Browse files Browse the repository at this point in the history
Signed-off-by: Okiki <[email protected]>
  • Loading branch information
okikio committed Mar 2, 2024
1 parent 76b8b2d commit 5b0b68d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
11 changes: 9 additions & 2 deletions tests/_arrays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export async function textDecoderComplexArray<T extends Uint8Array>(
* @returns An async generator that yields Unicode code points.
*/
export async function asCodePointsBufferWindowArray<T extends Uint8Array>(
iterable: AsyncIterator<T> | Iterator<T>
iterable: AsyncIterable<T> | Iterable<T>
) {
const arr: number[] = [];

Expand All @@ -196,11 +196,18 @@ export async function asCodePointsBufferWindowArray<T extends Uint8Array>(
const byteSequence = new Uint8Array(UTF8_MAX_BYTE_LENGTH);
let byteSequenceRemainingBytes = 0;

// Create an async iterator from the source (works for both async and sync iterables).
const iterator = Symbol.asyncIterator in iterable
? iterable[Symbol.asyncIterator]() :
Symbol.iterator in iterable
? iterable[Symbol.iterator]()
: iterable;

let head = 0; // Head pointer (start position)
let tail = 0; // Tail pointer (end position)

while (true) {
const result = await iterable.next();
const result = await iterator.next();
if (result.done) break;

const chunk = result.value;
Expand Down
11 changes: 9 additions & 2 deletions tests/_callbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export async function textDecoderCustomIteratorCallback<T extends Uint8Array>(
* @returns An async generator that yields Unicode code points.
*/
export async function asCodePointsBufferWindowCallback<T extends Uint8Array>(
iterable: AsyncIterator<T> | Iterator<T>,
iterable: AsyncIterable<T> | Iterable<T>,
cb: (codePoint: number) => void
) {
/**
Expand All @@ -257,11 +257,18 @@ export async function asCodePointsBufferWindowCallback<T extends Uint8Array>(
const byteSequence = new Uint8Array(UTF8_MAX_BYTE_LENGTH);
let byteSequenceRemainingBytes = 0;

// Create an async iterator from the source (works for both async and sync iterables).
const iterator = Symbol.asyncIterator in iterable
? iterable[Symbol.asyncIterator]() :
Symbol.iterator in iterable
? iterable[Symbol.iterator]()
: iterable;

let head = 0; // Head pointer (start position)
let tail = 0; // Tail pointer (end position)

while (true) {
const result = await iterable.next();
const result = await iterator.next();
if (result.done) break;

const chunk = result.value;
Expand Down
11 changes: 9 additions & 2 deletions tests/_iterators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export async function* textDecoderComplexIterator<T extends Uint8Array>(
* @returns An async generator that yields Unicode code points.
*/
export async function* asCodePointsBufferWindowIterator<T extends Uint8Array>(
iterable: AsyncIterator<T> | Iterator<T>
iterable: AsyncIterable<T> | Iterable<T>
) {
/**
* - `byteSequence` stores the bytes of the current UTF-8 character being processed.
Expand All @@ -188,11 +188,18 @@ export async function* asCodePointsBufferWindowIterator<T extends Uint8Array>(
const byteSequence = new Uint8Array(UTF8_MAX_BYTE_LENGTH);
let byteSequenceRemainingBytes = 0;

// Create an async iterator from the source (works for both async and sync iterables).
const iterator = Symbol.asyncIterator in iterable
? iterable[Symbol.asyncIterator]() :
Symbol.iterator in iterable
? iterable[Symbol.iterator]()
: iterable;

let head = 0; // Head pointer (start position)
let tail = 0; // Tail pointer (end position)

while (true) {
const result = await iterable.next();
const result = await iterator.next();
if (result.done) break;

const chunk = result.value;
Expand Down

0 comments on commit 5b0b68d

Please sign in to comment.