{"library":"stack-typescript","title":"TypeScript Stack with Generics","type":"library","description":"stack-typescript is a lightweight, generic Stack data structure implementation for TypeScript and JavaScript environments, currently at version 1.0.4. It is built upon the `linked-list-typescript` package, providing a LIFO (Last-In, First-Out) collection. Key features include full TypeScript generics support for strong type-checking, enabling stacks of any primitive, object, or custom class. The package also implements both the JavaScript iterator and iterable protocols, allowing seamless integration with `for...of` loops, spread syntax (`...`), and array deconstruction. Its primary differentiators are its explicit use of a linked list for underlying storage and its full adherence to TypeScript's type-templating capabilities, ensuring type safety from initialization to manipulation. The release cadence appears stable, with a focus on core data structure functionality without frequent breaking changes, typical for foundational utility libraries.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install stack-typescript"],"cli":null},"imports":["import { Stack } from 'stack-typescript';","const { Stack } = require('stack-typescript');","let myStack = new Stack<string>();"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/sfkiwi/stack-typescript","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/stack-typescript","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import { Stack } from 'stack-typescript';\n\n// Create an empty stack of numbers\nlet numberStack = new Stack<number>();\nnumberStack.push(10);\nnumberStack.push(20);\nnumberStack.push(30);\n\nconsole.log(`Number Stack Size: ${numberStack.size}`); // Expected: 3\nconsole.log(`Top of Number Stack: ${numberStack.top}`); // Expected: 30\n\n// Initialize a stack with values and custom types\nclass Foo {\n  constructor(public val: number) {}\n  get bar(): number { return this.val; }\n}\n\nlet foo1 = new Foo(100);\nlet foo2 = new Foo(200);\nlet fooStack = new Stack<Foo>(foo1, foo2, new Foo(300));\n\nconsole.log(`Foo Stack Size: ${fooStack.size}`); // Expected: 3\nconsole.log(`Top of Foo Stack: ${fooStack.top?.bar}`); // Expected: 100\n\nlet poppedFoo = fooStack.pop();\nconsole.log(`Popped Foo: ${poppedFoo?.bar}`); // Expected: 100\nconsole.log(`Foo Stack Size after pop: ${fooStack.size}`); // Expected: 2\n\n// Iterate over the stack\nconsole.log('Iterating over Foo Stack:');\nfor (let item of fooStack) {\n  console.log(item.bar);\n}\n// Expected: 200, 300\n","lang":"typescript","description":"Demonstrates creating, initializing, pushing, peeking, popping, and iterating a Stack with both primitive and custom types.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}