You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
405 B

4 years ago
  1. /**
  2. * convert an object into its 2D array equivalent to be turned
  3. * into an ES6 map
  4. *
  5. * @param {object} obj any object type that works with Object.keys()
  6. * @returns {Map<TODO, TODO>} an ES6 Map of KV pairs
  7. */
  8. module.exports = function objectToMap(obj) {
  9. return new Map(
  10. Object.keys(obj).map(key => {
  11. /** @type {[string, string]} */
  12. const pair = [key, obj[key]];
  13. return pair;
  14. })
  15. );
  16. };