diff --git a/src/system/iterable.ts b/src/system/iterable.ts index 4b7ee70..df02f8b 100644 --- a/src/system/iterable.ts +++ b/src/system/iterable.ts @@ -38,12 +38,12 @@ export function* chunkByStringLength(source: string[], maxLength: number): Itera } } -export function count(source: Iterable | IterableIterator, predicate?: (item: T) => boolean): number { +export function count(source: IterableIterator, predicate?: (item: T) => boolean): number { let count = 0; let next: IteratorResult; while (true) { - next = (source as IterableIterator).next(); + next = source.next(); if (next.done) break; if (predicate === undefined || predicate(next.value)) { diff --git a/src/system/searchTree.ts b/src/system/searchTree.ts index a4bc2a3..b76e98b 100644 --- a/src/system/searchTree.ts +++ b/src/system/searchTree.ts @@ -380,7 +380,7 @@ export class TernarySearchTree { return count(this.entries(), predicate === undefined ? undefined : ([, e]) => predicate(e)); } - entries(): Iterable<[K, V]> { + entries(): IterableIterator<[K, V]> { return this._iterator(this._root); } @@ -391,7 +391,7 @@ export class TernarySearchTree { highlander(): [K, V] | undefined { if (this._root === undefined || this._root.isEmpty()) return undefined; - const entries = this.entries() as IterableIterator<[K, V]>; + const entries = this.entries(); let count = 0; let next: IteratorResult<[K, V]>;