Removed hard limit on unprocessed messages in cache

This commit is contained in:
Alvaro 2023-02-02 12:39:07 -07:00 committed by GitHub
parent 1381e8df5d
commit e51f582bfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 130 additions and 44 deletions

View file

@ -257,6 +257,23 @@ export function repeat<T>(value: T): Iterable<T> {
return new RepeatIterable(value);
}
export function* chunk<A>(
iterable: Iterable<A>,
chunkSize: number
): Iterable<Array<A>> {
let aChunk: Array<A> = [];
for (const item of iterable) {
aChunk.push(item);
if (aChunk.length === chunkSize) {
yield aChunk;
aChunk = [];
}
}
if (aChunk.length > 0) {
yield aChunk;
}
}
class RepeatIterable<T> implements Iterable<T> {
constructor(private readonly value: T) {}