diff --git a/packages/core/src/tools/boundedBuffer.spec.ts b/packages/core/src/tools/boundedBuffer.spec.ts index cd132c0c0d..31accb164b 100644 --- a/packages/core/src/tools/boundedBuffer.spec.ts +++ b/packages/core/src/tools/boundedBuffer.spec.ts @@ -15,15 +15,16 @@ describe('BoundedBuffer', () => { expect(spy.calls.count()).toBe(1) }) - it('store only the N last callbacks', () => { + it('store at most 500 callbacks', () => { const spy = jasmine.createSpy<() => void>() - const buffered = new BoundedBuffer(5) + const buffered = new BoundedBuffer() + const limit = 500 - for (let i = 0; i < 10; i += 1) { + for (let i = 0; i < limit + 1; i += 1) { buffered.add(spy) } buffered.drain() - expect(spy.calls.count()).toEqual(5) + expect(spy.calls.count()).toEqual(limit) }) }) diff --git a/packages/core/src/tools/boundedBuffer.ts b/packages/core/src/tools/boundedBuffer.ts index bdcdabfba6..60a6212a72 100644 --- a/packages/core/src/tools/boundedBuffer.ts +++ b/packages/core/src/tools/boundedBuffer.ts @@ -1,13 +1,11 @@ -const DEFAULT_LIMIT = 10_000 +const BUFFER_LIMIT = 500 export class BoundedBuffer { private buffer: Array<() => void> = [] - constructor(private limit: number = DEFAULT_LIMIT) {} - add(callback: () => void) { const length = this.buffer.push(callback) - if (length > this.limit) { + if (length > BUFFER_LIMIT) { this.buffer.splice(0, 1) } }