Skip to content

Commit

Permalink
fix(Buffer): return self when reversing
Browse files Browse the repository at this point in the history
  • Loading branch information
slikts committed Jan 24, 2023
1 parent c816c3c commit df6785e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Buffer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,12 @@ describe('Buffer', () => {
const q = Buffer.from([1, 2, 3], 2);
expect([...q]).toEqual([2, 3]);
});

it('reverses', () => {
const q = new Buffer();
q.enqueue(1);
q.enqueue(2);
q.enqueue(3);
expect([...q.reverse()]).toEqual([3, 2, 1]);
});
});
1 change: 1 addition & 0 deletions src/Buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class Buffer<A> {

reverse() {
this.#reversed = true;
return this;
}

[Symbol.iterator]() {
Expand Down

0 comments on commit df6785e

Please sign in to comment.