mapValues
Map over the keys of an object
99 bytes
Usage
Given an object and a toValue callback function, returns a new object with all the values
mapped through the toValue function. The callback is given both the value and key for each entry.
import * as import _
_ from 'radashi'
const const ra: { mode: string; power: string;}
ra = { mode: string
mode: 'god', power: string
power: 'sun',}
import _
_.mapValues<{ mode: string; power: string;}, string>(obj: { mode: string; power: string;}, mapFunc: (value: string, key: "mode" | "power") => string): { mode: string; power: string;}export mapValues
Map over all the keys to create a new object.
mapValues(const ra: { mode: string; power: string;}
ra, value: string
value => value: string
value.String.toUpperCase(): string
Converts all the alphabetic characters in a string to uppercase.
toUpperCase()) // => { mode: 'GOD', power: 'SUN' }import _
_.mapValues<{ mode: string; power: string;}, "mode" | "power">(obj: { mode: string; power: string;}, mapFunc: (value: string, key: "mode" | "power") => "mode" | "power"): { mode: "mode" | "power"; power: "mode" | "power";}export mapValues
Map over all the keys to create a new object.
mapValues(const ra: { mode: string; power: string;}
ra, (value: string
value, key: "mode" | "power"
key) => key: "mode" | "power"
key) // => { mode: 'mode', power: 'power' }