Skip to content

Instantly share code, notes, and snippets.

@noahlt
Created July 23, 2019 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noahlt/94773e51fe21849d1c12110efb386222 to your computer and use it in GitHub Desktop.
Save noahlt/94773e51fe21849d1c12110efb386222 to your computer and use it in GitHub Desktop.
Make a method to map a Map to an Object
Object.fromMap = function(m, f) {
var r = {};
f = f || ((x, y) => [x, y]);
for (let [k, v] of m) {
[k, v] = f(k, v);
r[k] = v;
}
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment