from-object
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

from-object

Convert an object of objects into an array of objects. Order is not guaranteed.

Usage

import { fromObject } from 'from-object'
 
const example = {
  jim: {
    name: 'Jim',
    age: 20,
  },
  tim: {
    name: 'Tim',
    age: 22,
  },
}
 
fromObject(example, 'id') // id is optional: set an identifier, could be anything

Should output:

[
  {
    id: 'jim', // this will not be here if you don't pass the second argument
    name: 'Jim',
    age: 20,
  },
  {
    id: 'tim', // this will not be here if you don't pass the second argument
    name: 'Tim',
    age: 22,
  },
]

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i from-object

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

5.62 kB

Total Files

13

Last publish

Collaborators

  • zaguini