Skip to content

Instantly share code, notes, and snippets.

@artemsky
Created April 6, 2017 15:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
es6 Map to Json
const mapToObject = (map) => {
const out = Object.create(null);
map.forEach((value, key) => {
if (value instanceof Map) {
out[key] = mapToObject(value);
}
else {
out[key] = value
}
});
return out;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment