Removed hard limit on unprocessed messages in cache
This commit is contained in:
parent
1381e8df5d
commit
e51f582bfb
6 changed files with 130 additions and 44 deletions
|
@ -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) {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue