object-to-array
v2.0.1
Published
Convert object to array, where each item is an array of key & value
Downloads
88,524
Readme
object-to-array
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