Skip to content

Instantly share code, notes, and snippets.

View NiceYellowEgg's full-sized avatar

NiceYellowEgg

View GitHub Profile
@joyrexus
joyrexus / README.md
Created April 9, 2014 02:58
Pivot an array of objects by key

Accumulate values by key from an array of objects (key/value mappings):

records = [
  { a: 10, b: 20, c: 30 }, 
  { a: 11, b: 21 }, 
  { a: 12, b: 22, c: 32, d: 42 }
]

pivoted = pivot(records)