@sachin.talekar07/stack

1.0.8 • Public • Published

Stack Data Structure

GitHub license (https://www.npmjs.com/package/@sachintalekar07/stack

Description

A simple and efficient implementation of a stack data structure in JavaScript. This module provides methods for managing a stack, such as push, pop, peek, and more.

Installation

To install the Stack module, use npm:

npm install @sachin.talekar07/stack

Usage

Basic Usage

const Stack = require('@sachin.talekar07/stack');

const stack = Stack();

stack.push(42);
stack.push(13);
stack.push(7);

console.log(stack.peek()); // Output: 7

stack.pop();
console.log(stack.size()); // Output: 2

API

The Stack module provides the following methods:

  • push(item): Add an item to the top of the stack.
  • pop(): Remove and return the top item from the stack.
  • peek(): Return the top item without removing it from the stack.
  • isEmpty(): Check if the stack is empty (returns true or false).
  • size(): Get the number of items in the stack.
  • clear(): Remove all items from the stack.

Contributing Contributions are welcome! If you find any issues or have suggestions for improvement, feel free to open an issue or submit a pull request.

License This project is licensed under the MIT License.

Contact If you have any questions or feedback, you can reach me at sachin.talekar07@gmail.com or https://github.com/sachintalekar07.

Package Sidebar

Install

npm i @sachin.talekar07/stack

Weekly Downloads

8

Version

1.0.8

License

MIT

Unpacked Size

3.81 kB

Total Files

4

Last publish

Collaborators

  • sachin.talekar07