UNPKG

js-dsa-utils

Version:

Basic DSA utilities (sorting, searching, stack, queue,linked list etc.)

20 lines (18 loc) 309 B
class Stack { constructor() { this.stack = []; } push(val) { this.stack.push(val); } pop() { return this.stack.pop(); } peek() { return this.stack[this.stack.length - 1]; } isEmpty() { return this.stack.length === 0; } } module.exports = { Stack };