A simple library, JavaScript implementation of Stack data structure, using Array.
https://github.com/IamLizu/stack.git
Javascript implementation of Stack data structure>), using Array.
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 ]
| Method | Description |
|---|---|
| getBuffer | returns a shallow copy of the Stack array |
| isEmpty | return true if empty |
| push | adds item to the Stack |
| pop | remove item from the Stack |
| peek | returns the top item from Stack without popping it |
| size | returns the length of the Stack |
| clear | resets the Stack to empty |
| access(index) | returns the item on index from Stack |
| search(item) | returns the index of given item in the Stack |
You may create a pull request and wait to get reviewed, merged.
๐ Happy coding!