"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = mapToObject;


/**
 * Cast a `Map` to a plain object. 
 * Keys are being casted by invoking `toString` on each key.
 * @name mapToObject
 * @param {Map} map to cast
 * @returns {*} plain object
 * @example
 * ```js
 *  mapToObject(new Map([['key', 'val'], ['foo', 'bar']]));
 *  // => { key: 'val', foo: 'bar' }
 * ```
 */
function mapToObject(map) {
  var object = {};
  map.forEach(function (val, key) {
    object[key.toString()] = val;
  });
  return object;
}