https://github.com/avoidwork/tiny-stack
Stack micro library
https://github.com/avoidwork/tiny-stack
Last synced: 6 months ago
JSON representation
Stack micro library
- Host: GitHub
- URL: https://github.com/avoidwork/tiny-stack
- Owner: avoidwork
- License: bsd-3-clause
- Created: 2014-04-29T10:14:56.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-11-11T01:50:34.000Z (about 2 years ago)
- Last Synced: 2024-04-14T12:10:13.915Z (almost 2 years ago)
- Language: JavaScript
- Homepage: http://avoidwork.github.io/tiny-stack
- Size: 106 KB
- Stars: 11
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Tiny Stack
Stack for Client or Server.
[](http://travis-ci.org/avoidwork/tiny-stack)
## API
#### clear
Clears the stack
#### length
Gets the length/size of the stack
#### peek
Gets the top item of the stack
#### pop
Gets & removes the top item of the stack
#### push
Adds an item to the top the stack
#### empty
Tests if this stack is empty
#### search
Returns the 1-based position where an object is on this stack
## Example
```
const stack = require("tiny-stack"),
mystack = stack(),
jane = {name: "Jane Doe"},
john = {name: "John Doe"};
mystack.length(); // 0
mystack.empty(); // true
mystack.push(john);
mystack.push(jane);
mystack.length(); // 2
mystack.search(jane); // 1
mystack.search(john); // 2
mystack.search({}); // -1
mystack.empty(); // false
mystack.peek(); // {name: "Jane Doe"}
mystack.pop();
mystack.length(); // 1
mystack.peek(); // {name: "John Doe"}
mystack.clear();
mystack.length(); // 0
```
## License
Copyright (c) 2018 Jason Mulligan
Licensed under the BSD-3-Clause license.