reduce-entries

1.0.2 • Public • Published

reduce-entries

CircleCI

Basically, the opposite of d3's .entries(). Takes an array of objects with key and value keys and reduces it into a single object.

import reduceEntries from 'reduce-entries'

const entries = [
  { key: 'foo', value: 'bar' },
  { key: 'dude', value: 'yo' }
]

const single = entries.reduce(reduceEntries())
console.log(single) // { foo: 'bar', dude: 'yo' }

Optionally, it can take a string to be used as the value key.

import reduceEntries from 'reduce-entries'

const entries = [{ key: 'foo', bar: 'baz' }]

const single = entries.reduce(reduceEntries('bar'))
console.log(single) // { foo: 'baz' }

Readme

Keywords

Package Sidebar

Install

npm i reduce-entries

Weekly Downloads

5

Version

1.0.2

License

CC-BY-4.0

Last publish

Collaborators

  • jeremiak