new Stack(dataopt)
Simple observable stack implementation.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
data |
Object |
<optional> |
{} | init attributes |
Example
var stack1 = new Stack(),
stack2 = new Stack([1, 2, 3]);
Extends
- Emitter
Members
(readonly) current :Object
Current top stack element.
Type:
- Object
(readonly) data :Array.<Object>
List of all stack elements.
Type:
- Array.<Object>
Methods
pop() → {*}
Remove current top element from the stack.
Fires:
Returns:
removed element
- Type
- *
Example
var item = stack.pop();
push(data)
Add new element to the stack.
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | new element |
Fires:
Example
stack.push(123);
stack.push('abc');
stack.push({foo: 'bar'});
Events
pop
Remove current top element from the stack event.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
prev |
* | previous top element |
curr |
* | current top element |
push
Add new element to the stack event.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
prev |
* | previous top element |
curr |
* | current top element |