object-array-converter

1.0.1 • Public • Published

object-array-converter

Install

npm i --save object-array-converter

Usage

var convert = require('object-array-converter');

Convert an object's keys and values to an array of objects

var obj = { a: 'weee', b: 'wooo', c: 'pooop' };

convert.toArray(obj);

/*

Returns:

[
  { key: 'a', value: 'weee' },
  { key: 'b', value: 'wooo' },
  { key: 'c', value: 'pooop' }
]

*/

Convert an array of objects to an object

var arr = [
  { key: 'a', value: 'weee' },
  { key: 'b', value: 'wooo' },
  { key: 'c', value: 'pooop' }
];

convert.toObject(arr);

/*

Returns:

{ a: 'weee', b: 'wooo', c: 'pooop' }

*/

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    71
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    71
  • 1.0.0
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i object-array-converter

Weekly Downloads

59

Version

1.0.1

License

none

Last publish

Collaborators

  • sethvincent