Class: Stack

stb/stack~ Stack

new Stack(dataopt)

Simple observable stack implementation.

Parameters:
Name Type Attributes Default Description
data Object <optional>
{}

init attributes

Source:
Example
var stack1 = new Stack(),
    stack2 = new Stack([1, 2, 3]);

Extends

  • Emitter

Members

(readonly) current :Object

Current top stack element.

Type:
  • Object
Source:

(readonly) data :Array.<Object>

List of all stack elements.

Type:
  • Array.<Object>
Source:

Methods

pop() → {*}

Remove current top element from the stack.

Source:
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

Source:
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

Source:

push

Add new element to the stack event.

Type:
  • Object
Properties:
Name Type Description
prev *

previous top element

curr *

current top element

Source: