object-array-converter

## Install

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
object-array-converter
201.0.16 years ago8 years agoMinified + gzip package size for object-array-converter in KB

Readme

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