Browse Source

Fixes iterable.count signature

main
Eric Amodio 2 years ago
parent
commit
38e6aab347
2 changed files with 4 additions and 4 deletions
  1. +2
    -2
      src/system/iterable.ts
  2. +2
    -2
      src/system/searchTree.ts

+ 2
- 2
src/system/iterable.ts View File

@ -38,12 +38,12 @@ export function* chunkByStringLength(source: string[], maxLength: number): Itera
}
}
export function count<T>(source: Iterable<T> | IterableIterator<T>, predicate?: (item: T) => boolean): number {
export function count<T>(source: IterableIterator<T>, predicate?: (item: T) => boolean): number {
let count = 0;
let next: IteratorResult<T>;
while (true) {
next = (source as IterableIterator<T>).next();
next = source.next();
if (next.done) break;
if (predicate === undefined || predicate(next.value)) {

+ 2
- 2
src/system/searchTree.ts View File

@ -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]>;

Loading…
Cancel
Save