Skip to content

mapKeys

Map over the keys of an object

100 bytes

Usage

Given an object and a toKey callback function, returns a new object with all the keys mapped through the toKey function. The callback is given both the key and value for each entry.

import * as _ from 'radashi'
const ra = {
mode: 'god',
power: 'sun',
}
_.mapKeys(ra, key => key.toUpperCase()) // => { MODE, POWER }
_.mapKeys(ra, (key, value) => value) // => { god: 'god', power: 'power' }