๐Ÿ“ฆ IamLizu / stack

A simple library, JavaScript implementation of Stack data structure, using Array.

โ˜… 1 stars โ‘‚ 0 forks ๐Ÿ‘ 1 watching
data-structuresstack
๐Ÿ“ฅ Clone https://github.com/IamLizu/stack.git
HTTPS git clone https://github.com/IamLizu/stack.git
SSH git clone git@github.com:IamLizu/stack.git
CLI gh repo clone IamLizu/stack
IamLizu IamLizu Init v1.0.0 f9aa004 4 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ .github
๐Ÿ“„ .gitignore
๐Ÿ“„ index.js
๐Ÿ“„ index.test.js
๐Ÿ“„ package-lock.json
๐Ÿ“„ package.json
๐Ÿ“„ README.md
๐Ÿ“„ README.md

stack

Javascript implementation of Stack data structure>), using Array.

Getting Started


Install in your project with,

npm install @iamlizu/stack

Usage example,

const Stack = require("@iamlizu/stack")

// Create new instance
const stack1 = new Stack();

stack1.push(10);
console.log(stack1.getBuffer()) // [ 10 ]

Available Methods


MethodDescription
getBufferreturns a shallow copy of the Stack array
isEmptyreturn true if empty
pushadds item to the Stack
popremove item from the Stack
peekreturns the top item from Stack without popping it
sizereturns the length of the Stack
clearresets the Stack to empty
access(index)returns the item on index from Stack
search(item)returns the index of given item in the Stack

Contributing


You are very much appreciated to add new functionalities to this module. Please add all the required test cases for the functionality.

You may create a pull request and wait to get reviewed, merged.

๐Ÿš€ Happy coding!