npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

object-to-array

2.0.1

@vdemedes

npmHomeRepoSnykSocket
Downloads:7
$ npm install object-to-array
DailyWeeklyMonthlyYearly

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

  • object-to-map

License

MIT © Vadim Demedes