Skip to content

Instantly share code, notes, and snippets.

@searls
Created February 1, 2012 15:48
Show Gist options
  • Select an option

  • Save searls/1717645 to your computer and use it in GitHub Desktop.

Select an option

Save searls/1717645 to your computer and use it in GitHub Desktop.
difference = (left, right) ->
leftDifference = {}
rightDifference = {}
result = [leftDifference,rightDifference]
_(left).each (leftVal,key) ->
rightVal = right[key]
if rightVal != leftVal
leftDifference[key] = leftVal
rightDifference[key] = rightVal
result
describe "panda", ->
Given -> @FOO =
a: "b"
c: "d"
e: "f"
Given -> @BAR =
a: "b"
c: "d"
e: "g"
When -> @result = difference(@FOO,@BAR)
Then -> expect(@result).toEqual([{e:"f"},{e:"g"}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment