Skip to content

Commit

Permalink
fix(Channel): set default limit to infinite
Browse files Browse the repository at this point in the history
  • Loading branch information
slikts committed Jan 24, 2023
1 parent a326a66 commit 3d75244
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/adapters/Channel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ describe('Channel', () => {
expect(new Channel()).toBeInstanceOf(Channel);
});

it('pushes', async () => {
const c = new Channel<number>();
c.push(1);
expect(await c.next()).toEqual({ done: false, value: 1 });
});

it('pulls', async () => {
const c = new Channel<number>();
const p = c.next();
c.push(1);
expect(await p).toEqual({ done: false, value: 1 });
});

it('can balance pull after push', async () => {
const c = new Channel<number>();
const ns = [1, 2, 3];
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/Channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class Channel<A> implements PushAdapter<A> {

constructor(
/** Limit (bounds) after which the oldest buffered value is dropped. */
limit = 0,
limit = Infinity,
) {
this.pushBuffer = new LinkedQueue(limit);
this.pullBuffer = new LinkedQueue(limit);
Expand Down

0 comments on commit 3d75244

Please sign in to comment.