UNPKG

testeranto

Version:

the AI powered BDD test framework for typescript projects

42 lines (33 loc) 556 B
export class Queue<I> { items: I[]; constructor() { this.items = []; } enqueue(element) { this.items.push(element); } dequeue() { if (this.isEmpty()) { return "Queue is empty"; } return this.items.shift(); } peek() { if (this.isEmpty()) { return "Queue is empty"; } return this.items[0]; } isEmpty() { return this.items.length === 0; } size() { return this.items.length; } clear() { this.items = []; } print() { console.log(this.items.join(" -> ")); } }