2018-01-23 15:30:22 +08:00
|
|
|
/**
|
|
|
|
* convert an object into its 2D array equivalent to be turned
|
|
|
|
* into an ES6 map
|
|
|
|
*
|
|
|
|
* @param {object} obj - any object type that works with Object.keys()
|
2018-05-08 20:31:51 +08:00
|
|
|
* @returns {Map<TODO, TODO>} an ES6 Map of KV pairs
|
2018-01-23 15:30:22 +08:00
|
|
|
*/
|
|
|
|
module.exports = function objectToMap(obj) {
|
2018-04-06 01:44:15 +08:00
|
|
|
return new Map(
|
2018-04-09 01:17:01 +08:00
|
|
|
Object.keys(obj).map(key => {
|
|
|
|
/** @type {[string, string]} */
|
|
|
|
const pair = [key, obj[key]];
|
|
|
|
return pair;
|
|
|
|
})
|
2018-04-06 01:44:15 +08:00
|
|
|
);
|
2018-01-23 15:30:22 +08:00
|
|
|
};
|