object-to-array

2.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i object-to-array

Weekly Downloads

20

Version

2.0.1

License

MIT

Last publish

Collaborators

  • vdemedes