Skip to content

Instantly share code, notes, and snippets.

@colwilson
Created October 19, 2011 13:10
Show Gist options
  • Save colwilson/1298238 to your computer and use it in GitHub Desktop.
Save colwilson/1298238 to your computer and use it in GitHub Desktop.
# define the reduce function
# this function is called for every emit emitted
# from the map function above
# in this example we'll count all the fruit by
# type and also keep a tally for the baskets
reduceFunc = (key, values) ->
count = 0
baskets = 0
values.forEach (value) ->
count += value.count
baskets += value.baskets
return {
fruit: key,
count: count,
baskets: baskets
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment