Converts a map to a simple object, transforming from type T to K as it does so. If no transforms are needed, use toObject.
T
K
const map = new Map();map.set(`name`, `Alice`);map.set(`pet`, `dog`);const o = mapToObjectTransform(map, v => { ...v, registered: true});// Yields: { name: `Alice`, pet: `dog`, registered: true } Copy
const map = new Map();map.set(`name`, `Alice`);map.set(`pet`, `dog`);const o = mapToObjectTransform(map, v => { ...v, registered: true});// Yields: { name: `Alice`, pet: `dog`, registered: true }
If the goal is to create a new map with transformed values, use transformMap.
Value type of input map
Value type of destination map
Converts a map to a simple object, transforming from type
T
toK
as it does so. If no transforms are needed, use toObject.If the goal is to create a new map with transformed values, use transformMap.