Skip to content

Instantly share code, notes, and snippets.

@kyriesent
Last active December 12, 2015 12:39
Show Gist options
  • Save kyriesent/4773641 to your computer and use it in GitHub Desktop.
Save kyriesent/4773641 to your computer and use it in GitHub Desktop.
diffArray = (a, b, done) ->
u = {};
diff =
a: []
b: []
async.forEach b, (x, cb) ->
u[x] = true
cb()
, (err) ->
async.forEach a, (x, cb) ->
if (!u[x])
diff.a.push x
else
delete u[x]
cb()
, (err) ->
diff.b = for item, b of u
item
done null, diff #a: items unique to a; b: items unique to be; u: union set of a and b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment