|
1 | 1 | # EZStackJS |
2 | | -A very easy and lightweight JavaScript library for working with stack data structure. |
| 2 | + |
| 3 | +EZStackJS is a lightweight and easy-to-use JavaScript library designed for working with stack data structures. With EZStackJS, you can effortlessly manage and manipulate stack in your JavaScript applications. |
| 4 | + |
| 5 | +## License |
| 6 | + |
| 7 | +EZStackJS is licensed under the [MIT License](LICENSE). |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **Simplicity**: EZStackJS provides a straightforward interface for creating, modifying, and traversing stack. |
| 12 | +- **Lightweight**: With minimal dependencies and efficient implementation, EZStackJS offers high performance while keeping your project's footprint small. |
| 13 | +- **Flexibility**: EZStackJS is highly adaptable and can be easily integrated into various JavaScript projects, from small scripts to large-scale applications. |
| 14 | + |
| 15 | +Whether you're a beginner learning about data structures or an experienced developer needing a reliable tool for managing stack, EZStackJS is here to simplify your workflow and empower your projects. |
| 16 | + |
| 17 | +## Installation |
| 18 | + |
| 19 | +To start using EZStackJS in your project, simply install it via npm: |
| 20 | + |
| 21 | +```bash |
| 22 | +npm install ezstackjs |
| 23 | +``` |
| 24 | + |
| 25 | +```js |
| 26 | +// Import the Stack class from EZStackJS |
| 27 | +const { Stack } = require('EZStackJS'); |
| 28 | + |
| 29 | +// Create a new stack |
| 30 | +const stack = new Stack(); |
| 31 | +``` |
| 32 | + |
| 33 | +## Method Documentation |
| 34 | + |
| 35 | +EZStackJS provides a variety of methods for creating, modifying, and interacting with stack. Below is an overview of the available methods along with their descriptions and usage examples: |
| 36 | + |
| 37 | +### `.push(item)` |
| 38 | + |
| 39 | +This method inserts the data into the stack |
| 40 | + |
| 41 | +#### Parameters: |
| 42 | + |
| 43 | +- `item`: The item you want to insert to the stack. |
| 44 | + |
| 45 | +### `.peek()` |
| 46 | + |
| 47 | +The method return the last data in the stack (does not remove it). |
| 48 | + |
| 49 | +### Returns: |
| 50 | +- `Any` |
| 51 | + - Your last item in the stack. |
| 52 | + |
| 53 | +### `.pop()` |
| 54 | + |
| 55 | +This method return the last data and remove it. |
| 56 | + |
| 57 | +#### Returns: |
| 58 | +- `Any` |
| 59 | + - Your last item in the stack. |
| 60 | + |
| 61 | +### `.size()` |
| 62 | + |
| 63 | +This method return the number of items in the stack. |
| 64 | + |
| 65 | +#### Returns: |
| 66 | +- `Number(int)` |
| 67 | + - The size of your stack. |
| 68 | + |
| 69 | +### `.isEmpty()` |
| 70 | + |
| 71 | +This method indicates whether the stack is empty or not. |
| 72 | + |
| 73 | +#### Returns: |
| 74 | + |
| 75 | +- `Boolean` |
| 76 | + - `true`: Stack is empty. |
| 77 | + - `false`: Stack is not empty. |
| 78 | + |
| 79 | +### `.toArray()` |
| 80 | + |
| 81 | +This method pours all the data of the stack into an array and returns it. |
| 82 | + |
| 83 | +#### Returns: |
| 84 | + |
| 85 | +- `Array`. |
| 86 | + - An array of all elements in the stack. |
| 87 | + |
| 88 | +### `.toReverseArray()` |
| 89 | + |
| 90 | +This method puts all elements of the stack in reverse order in the array and returns it. |
| 91 | + |
| 92 | +#### Returns: |
| 93 | + |
| 94 | +- `Array`. |
| 95 | + - An array of all elements in the reverse array. |
| 96 | + |
| 97 | +Explore the various methods to effectively manage and manipulate stack using EZStackJS in your JavaScript applications. |
| 98 | + |
| 99 | + |
| 100 | +## Advanced Topic: Time Complexity Analysis |
| 101 | + |
| 102 | +Understanding the time complexity of each method can help you optimize your code and make informed decisions when working with large datasets in EZStackJS. |
| 103 | + |
| 104 | +Below is an analysis of the time complexity for each method in the EZStackJS library: |
| 105 | + |
| 106 | +### Time Complexity `.push()`: |
| 107 | +- O(1) |
| 108 | + |
| 109 | +### Time Complexity `.peek()`: |
| 110 | +- O(1) |
| 111 | + |
| 112 | +### Time Complexity `.pop()`: |
| 113 | +- O(1) |
| 114 | + |
| 115 | +### Time Complexity `.size()`: |
| 116 | +- O(1) |
| 117 | + |
| 118 | +### Time Complexity `.isEmpty()`: |
| 119 | +- O(1) |
| 120 | + |
| 121 | +### Time Complexity `.toArray()`: |
| 122 | +- O(n) |
| 123 | + |
| 124 | +### Time Complexity `.toReverseArray()`: |
| 125 | +- O(n) |
0 commit comments