       $location.search(search)
 
     ##### Update basket state based on route changes #####
-
-    INTEGER_REGEXP = /^\d+$/m
     resolveProducts = ->
       productMapper = (newProducts, amount, name)->
         amount = _.parseInt(amount)

    products = []
    buyer = null

    changeAmount = (entry, amount)->
      name = entry.product.name
      currentAmount = parseInt($location.search()[name])
      unless currentAmount + amount < 1
        newAmount = currentAmount + amount
        $location.search(name, newAmount).replace()

    emptyBasketAndRemoveBuyer = (showBasket=true)->
      searchObj = $location.search()
      delete searchObj.buyer

      delete searchObj[entry.product.name] for entry in products
      products.splice(0, products.length)

      searchObj.basket = showBasket
      $location.search(searchObj).replace()

    entryAmountReducer = (sum, entry)-> sum+entry.amount

        newProducts.push entry

      products = _.chain($location.search())
        .pick(isProductSearchValue)
        .transform(productMapper, [])
        .value()

