This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@datastructures-js/stack) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@datastructures-js/stack
A wrapper around javascript array push/pop with a standard stack interface.
// empty stackconst stack =newStack();// from an arrayconst stack =newStack([10,3,8,40,1]);
using ".fromArray"
// empty stackconst stack = Stack.fromArray([]);// with elementsconst list =[10,3,8,40,1];const stack = Stack.fromArray(list);// If the list should not be mutated, use a copy of it.const stack = Stack.fromArray(list.slice());
.push(element)
push an element to the top of the stack.
params
name
type
element
any
runtime
O(1)
Example
stack.push('test');
.peek()
returns the top element in the stack.
return
object
runtime
O(1)
Example
console.log(stack.peek());// test
.pop()
removes and returns the top element of the stack.
return
object
runtime
O(1)
Example
console.log(stack.pop());// test
console.log(stack.peek());// null