Skip to content

Pivot arrays of objects by key into a single object with a superset of keys containing arrays of each record's values.

License

Notifications You must be signed in to change notification settings

brycebaril/node-array-pivot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

array-pivot

NPM

Pivot arrays of objects by key into a single object with a superset of keys containing arrays of each record's values. Similar to a pivot table in a spreadsheet.

var pivot = require("array-pivot")

var data = [
  {foo: 1311, bar: "cat", zzz: 124.31},
  {foo: 41,   bar: 11},
  {foo: 159,  bar: 41, aaa: 12, zzz: 55}
]

console.log(pivot(data))

/*
 {foo: [1311, 41, 159],
  bar: ["cat", 11, 41],
  zzz: [124.31, 55],
  aaa: [12]}
*/

API

pivot(data)

LICENSE

MIT

About

Pivot arrays of objects by key into a single object with a superset of keys containing arrays of each record's values.

Resources

License

Stars

Watchers

Forks

Packages

No packages published