export function ComboStack() {
    this.contents = []
}

ComboStack.prototype.push = function(value) {
  // pushes item to stack
  this.contents.push(value)
}

// values is an array
ComboStack.prototype.pull = function(values) {
  var index, valuesArray;
  var returnArray = []
  // search for values and pull it out of the stack, and also pull it out of
  // values
  // SEARCH STARTING FROM END - THE MOST RECENT ONE FIRST
  // convert values
  valuesArray = Object.prototype.toString.call(values) === '[object Array]' ?
    values : [values]

  // if it's multiple values, then you should return an array.

  // if it's a single value you still return an array.
  for(var i=this.contents.length; i--;) {
    if (index = valuesArray.indexOf(this.contents[i]) !== -1) {
      returnArray = returnArray.concat(this.contents.splice(i, 1))
      // remove it from the valuesArray as well so you don't remove duplicates
      valuesArray.splice(index, 1)
    }
  }
  return returnArray;
}

ComboStack.prototype.isEmpty = function() {
  return this.contents.length === 0;
}

// recursive method used to check the last item of an array
ComboStack._peek = function(arr) {
  lastItem = arr[arr.length - 1]
  if (Object.prototype.toString.call(lastItem) === '[object Array]') {
    return ComboStack._peek(lastItem)
  } else {
    return lastItem
  }
}

// take a look at the deepest, most recent item that was pushed
ComboStack.prototype.peek = function() {
  return this.contents[this.contents.length - 1]
  // return ComboStack._peek(this.contents[this.contents.length - 1]);
}

ComboStack.prototype.empty = function() {
  this.contents = [];
}


@@ -167,32 +167,93 @@
 ues is an array%0A
+// pull will return the values that were successfully pulled%0A
 ComboStack.proto
@@ -279,16 +279,39 @@
 n(values
+, returnSuccessful=true
 ) %7B%0A  va
@@ -342,205 +342,53 @@
 var 
-returnArray = %5B%5D%0A  // search for values and pull it out of the stack, and also pull it out of%0A  // values%0A  // SEARCH STARTING FROM END - THE MOST RECENT ONE FIRST%0A  // convert values%0A  valuesArray
+leftover = %5B%5D%0A    , removed = %5B%5D%0A    , values
  = O
@@ -448,16 +448,20 @@
 ray%5D' ?%0A
+    
     valu
@@ -484,146 +484,218 @@
  // 
-if it's multiple values, then you should return an array.%0A%0A  // if it's a single value you still return an array.
+can't use buckets because associative arrays don't support integer keys%0A  // for every value, check for the last index of the key in the contents%0A  // have to iterate up because values
 %0A  for
+ 
 (var i=
-this.content
+0; i %3C value
 s.le
@@ -705,22 +705,22 @@
 h; i
---;
+++
 ) %7B%0A
+%0A
     if
- 
+(
 (ind
@@ -728,52 +728,53 @@
 x = 
-valuesArray.indexOf(this.content
+this.contents.lastIndexOf(value
 s%5Bi%5D)
+)
  !== -1
+ 
 ) %7B%0A
@@ -783,33 +783,68 @@
     
-returnArray = returnArray
+// if in contents, remove and add it%0A      removed = removed
 .con
@@ -869,16 +869,20 @@
 splice(i
+ndex
 , 1))%0A  
@@ -887,116 +887,105 @@
     
-  // remove it from the valuesArray as well so you don't remove duplicates%0A      valuesArray.splice(index, 1
+%7D else %7B%0A      // if not in contents, just push it to the leftovers%0A      leftover.push(values%5Bi%5D
 )%0A  
@@ -992,16 +992,17 @@
   %7D%0A  %7D%0A
+%0A
   return
@@ -1008,21 +1008,47 @@
 n return
-Array
+Successful ? removed : leftover
 ;%0A%7D%0A%0ACom

fix pull combostack to support multiple values