2.0.1 • Published 7 years ago

object-to-array v2.0.1

Weekly downloads
34
License
MIT
Repository
github
Last release
7 years ago

object-to-array Build Status

Convert object to array, where each item is an array of key & value. Useful for creating ES6 Map from a usual object.

Installation

$ npm install --save object-to-array

Usage

const objectToArray = require('object-to-array');

const obj = {
  a: 1,
  b: 2
};

const arr = objectToArray(obj);
//=> [
//=>   ['a', 1],
//=>   ['b', 2]
//=> ]

const map = new Map(arr);
map.get('a');
//=> 1

Related

License

MIT © Vadim Demedes