Skip to content

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.

463 B
Raw Blame
export class Stack<T> {
    items: T[];
  
    constructor() {
      this.items = [];
    }
  
    isEmpty() {
      return this.items.length === 0;
    }
  
    peek() {
      if (!this.isEmpty()) {
        return this.items[this.items.length - 1];
      }
      return undefined;
    }
  
    pop() {
      if (this.isEmpty()) {
        return undefined;
      }
      return this.items.pop();
    }
  
    push(item: T) {
      this.items.push(item);
    }
  }