1.0.0 ā€¢ Published 3 years ago

@iamlizu/stack v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

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!