Radash
  1. Object
  2. mapEntries

Basic usage

Iterates the entries of an object, calling the given toEntry callback function to generate new entries. It’s a _.mapValues and _.mapKeys in one. The toEntry callback function should return an array with two items [key, value] (a.k.a the new entry). If the function returns undefined, the entry will be ignored

import { mapEntries } from 'radash'

const ra = {
  name: 'Ra',
  power: 'sun',
  rank: 100,
  culture: 'egypt'
}

mapEntries(ra, (key, value) => key === 'culture' ? undefined : [key.toUpperCase(), `${value}`]) 
// => { NAME: 'Ra', POWER: 'sun', RANK: '100' }