1class Queue {
2 constructor(maxSize = 10) {
3 this.items = [];
4 this.maxSize = maxSize;
5 }
6
7 enqueue(value) {
8 if (this.items.length >= this.maxSize) {
9 throw new Error("Queue full");
10 }
11 this.items.push(value);
12 }
13
14 dequeue() {
15 if (this.items.length === 0) {
16 throw new Error("Queue empty");
17 }
18 return this.items.shift();
19 }
20}