1.0.0 • Published 8 years ago

simple-data-stack v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

SimpleStack

A module to create a very simple stack implementation.

SimpleStack~SimpleStack

Kind: inner class of SimpleStack

new SimpleStack()

Represents a stack.

ParamDescription
...argumentsOptional Initial elements in the stack.

simpleStack.toString()

Overrides Object.prototype.toString to throw errors.

Kind: instance method of SimpleStack
Throws:

  • Will throw an error in lieu of coercing stack into a string.
  • Will throw an error if the stack is empty.

SimpleStack~push(element)

Pushes an element onto the stack.

Kind: inner method of SimpleStack
Throws:

  • Will throw an error if an element is not supplied.
ParamDescription
elementAn element.

SimpleStack~peek() ⇒ Object

Returns the element at the top of the stack.

Kind: inner method of SimpleStack
Returns: Object - Element at the top of the stack
Throws:

  • Will throw an error if the stack is empty.

SimpleStack~pop() ⇒ Object

Pops (removes) the element at the top of the stack.

Kind: inner method of SimpleStack
Returns: Object - Popped element
Throws:

  • Will throw an error when the stack is empty.

SimpleStack~clear()

Clears the current stack.

Kind: inner method of SimpleStack

SimpleStack~length() ⇒ Number

Returns the length of the current stack.

Kind: inner method of SimpleStack
Returns: Number - Stack length

SimpleStack~clone() ⇒ Object

Returns a copy of the current stack.

Kind: inner method of SimpleStack
Returns: Object - Cloned new SimpleStack object