objectToMap.js 346 B

123456789101112131415
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. */
  4. "use strict";
  5. /**
  6. * Convert an object into an ES6 map
  7. *
  8. * @param {object} obj any object type that works with Object.entries()
  9. * @returns {Map<string, any>} an ES6 Map of KV pairs
  10. */
  11. module.exports = function objectToMap(obj) {
  12. return new Map(Object.entries(obj));
  13. };