Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iamlizu/stack
A simple library, JavaScript implementation of Stack data structure, using Array.
https://github.com/iamlizu/stack
data-structures stack
Last synced: about 1 month ago
JSON representation
A simple library, JavaScript implementation of Stack data structure, using Array.
- Host: GitHub
- URL: https://github.com/iamlizu/stack
- Owner: IamLizu
- Created: 2021-09-29T09:03:39.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-09-29T10:40:35.000Z (over 3 years ago)
- Last Synced: 2024-04-25T21:21:39.225Z (9 months ago)
- Topics: data-structures, stack
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@iamlizu/stack
- Size: 34.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# stack
Javascript implementation of [Stack data structure](), using [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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
---
| 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 |### 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!