From df6785e6b56853ba878558d02c400471b12a3a1a Mon Sep 17 00:00:00 2001 From: slikts Date: Tue, 24 Jan 2023 14:23:35 +0000 Subject: [PATCH] fix(Buffer): return self when reversing --- src/Buffer.spec.ts | 8 ++++++++ src/Buffer.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/src/Buffer.spec.ts b/src/Buffer.spec.ts index 90f877d6..c8a31061 100644 --- a/src/Buffer.spec.ts +++ b/src/Buffer.spec.ts @@ -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]); + }); }); diff --git a/src/Buffer.ts b/src/Buffer.ts index e024521c..9364a7db 100644 --- a/src/Buffer.ts +++ b/src/Buffer.ts @@ -52,6 +52,7 @@ export default class Buffer { reverse() { this.#reversed = true; + return this; } [Symbol.iterator]() {