Skip to content

Commit

Permalink
Short circuit if array is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
klzns committed Jan 30, 2017
1 parent 43d908f commit e02f8b4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/checkout.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ class Checkout

# Sends a request to remove items from the OrderForm.
removeItems: (items, expectedOrderFormSections = @_allOrderFormSections) =>
if items and items.length is 0
return @getOrderForm(expectedOrderFormSections)

itemsToRemove = []
for item, i in items
itemsToRemove.push({
Expand All @@ -237,6 +240,9 @@ class Checkout
removeAllItems: (expectedOrderFormSections = @_allOrderFormSections) =>
@getOrderForm(['items']).then (orderForm) =>
items = orderForm.items
if items and items.length is 0
return orderForm

itemsToRemove = []
for item, i in items
itemsToRemove.push({
Expand Down

0 comments on commit e02f8b4

Please sign in to comment.