Converts a Map to a plain object, useful for serializing to JSON. To convert back to a map use fromObject.
Map
const map = new Map();map.set(`Sally`, { name: `Sally`, colour: `red` });map.set(`Bob`, { name: `Bob`, colour: `pink });const objects = Maps.toObject(map);// Yields: {// Sally: { name: `Sally`, colour: `red` },// Bob: { name: `Bob`, colour: `pink` }// } Copy
const map = new Map();map.set(`Sally`, { name: `Sally`, colour: `red` });map.set(`Bob`, { name: `Bob`, colour: `pink });const objects = Maps.toObject(map);// Yields: {// Sally: { name: `Sally`, colour: `red` },// Bob: { name: `Bob`, colour: `pink` }// }
Converts a
Map
to a plain object, useful for serializing to JSON. To convert back to a map use fromObject.Example