Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/greybax/stack-data
Simple stack imlementation on ES6
https://github.com/greybax/stack-data
algorithm algorithm-and-data-structure algorithm-and-datastructure algorithms-datastructures data-stack data-structure data-structures datastructure datastructures es6 es6-javascript js js-data stack stack-based stack-data stacks stacks-project structured-data structures
Last synced: 3 days ago
JSON representation
Simple stack imlementation on ES6
- Host: GitHub
- URL: https://github.com/greybax/stack-data
- Owner: greybax
- Created: 2016-02-17T00:12:51.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-04-19T00:59:17.000Z (over 5 years ago)
- Last Synced: 2024-11-07T18:54:14.787Z (10 days ago)
- Topics: algorithm, algorithm-and-data-structure, algorithm-and-datastructure, algorithms-datastructures, data-stack, data-structure, data-structures, datastructure, datastructures, es6, es6-javascript, js, js-data, stack, stack-based, stack-data, stacks, stacks-project, structured-data, structures
- Language: JavaScript
- Size: 9.77 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# stack-data
[![Greenkeeper badge](https://badges.greenkeeper.io/greybax/stack-data.svg)](https://greenkeeper.io/)
[![NPM version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Coveralls Status][coveralls-image]][coveralls-url]
[![Dependency Status][depstat-image]][depstat-url]
[![DevDependency Status][depstat-dev-image]][depstat-dev-url]> Simple stack implementation on ES6
## Install
npm install --save stack-data
## Usage
### 2 ways for adding element in stack:
* in constructor ```new Stack(1,"2",3,[4, 5],6);```
* via ```push(elem)``` methodAlso supports chaining mechanism like:
```js
new Stack()
.push(1)
.push(2)
.push(3)
.push(4)
// creates object with 4 elements 1,2,3,4
``````js
// Examples of using stack-data//Added stack elements in constructor
let preInitStack = new Stack(1,"2",3,[4, 5],6);
preInitStack.size; //5//Added elements classically via push()
let stack = new Stack();
stack.size; //0
stack.push(1).push("2");
stack.size; //2
stack.pop(); //"2"
stack.size; //1
stack.peek(); //1
stack.size; //1
```## API
### push(elem)
```push``` - Pushes element into stack. Throws an ```StackException``` when parameter is empty.
#### elem
*Required*
Type: `Object````elem``` - object which will be putted into stack
### pop()
```pop``` - Takes top element from the stack. Throws an ```StackException``` when the stack is empty.
### peek()
```peek``` - Peeks at the top element of the stack. Throws an ```StackException``` when the stack is empty.
### size
```size``` - Returns the size of the stack.
## License
MIT © Aleksandr Filatov
[npm-url]: https://npmjs.org/package/stack-data
[npm-image]: https://img.shields.io/npm/v/stack-data.svg?style=flat-square[travis-url]: https://travis-ci.org/greybax/stack-data
[travis-image]: https://img.shields.io/travis/greybax/stack-data/master.svg?style=flat-square[coveralls-url]: https://coveralls.io/r/greybax/stack-data
[coveralls-image]: https://img.shields.io/coveralls/greybax/stack-data/master.svg?style=flat-square[depstat-url]: https://david-dm.org/greybax/stack-data
[depstat-image]: https://david-dm.org/greybax/stack-data.svg?style=flat-square[depstat-dev-url]: https://david-dm.org/greybax/stack-data#info=devDependencies
[depstat-dev-image]: https://david-dm.org/greybax/stack-data/dev-status.svg?style=flat-square