From 38e6aab347d82b92d2762d869be96f42b9bff2bc Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 1 Aug 2022 02:04:19 -0400 Subject: [PATCH] Fixes iterable.count signature --- src/system/iterable.ts | 4 ++-- src/system/searchTree.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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]>;