mapEntries
Map the keys and values of an object
127 bytes
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).
import * as _ from 'radashi'
const ra = { name: 'Ra', power: 'sun', rank: 100, culture: 'egypt',}
_.mapEntries(ra, (key, value) => [key.toUpperCase(), `${value}`]) // => { NAME: 'Ra', POWER: 'sun', RANK: '100', CULTURE: 'egypt' }