UNPKG

templates-mo

Version:

Templates is a scaffolding framework that makes code generation simple, dynamic, and reusable. Generate files, parts of your app, or whole project structures—without the repetitive copy-pasting

36 lines (28 loc) • 599 B
// eslint-disable-next-line @typescript-eslint/no-explicit-any export class Stack<TData = any> { public _stack: TData[] = []; constructor() { this._stack = []; } push(...args: TData[]) { this._stack.push(...args); } // remove an item from the top of the stack pop(): TData | null { return this._stack.pop() ?? null; } stack(): TData[] { return this._stack; } next(): TData | null { const len = this.size(); if (!len) { return null; } return this._stack[len - 1]; } // return the number of items in the stack size(): number { return this._stack.length; } }