Skip to content

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.

@seehttps://radashi.js.org/reference/object/mapValues

@example

const a = { a: 1, b: 2, c: 3 }
mapValues(a, (value, key) => value * 2)
// => { a: 2, b: 4, c: 6 }

@version12.1.0

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.

@seehttps://radashi.js.org/reference/object/mapValues

@example

const a = { a: 1, b: 2, c: 3 }
mapValues(a, (value, key) => value * 2)
// => { a: 2, b: 4, c: 6 }

@version12.1.0

mapValues
(
const ra: {
mode: string;
power: string;
}
ra
, (
value: string
value
,
key: "mode" | "power"
key
) =>
key: "mode" | "power"
key
) // => { mode: 'mode', power: 'power' }