Skip to content

Instantly share code, notes, and snippets.

@ivikash
Created March 28, 2018 22:45
Show Gist options
  • Save ivikash/37802d6397d198624c50b014d3091bff to your computer and use it in GitHub Desktop.
Save ivikash/37802d6397d198624c50b014d3091bff to your computer and use it in GitHub Desktop.
var flatten = arr =>
arr.reduce(
(acc, val) => acc.concat(Array.isArray(val) ? flatten(val) : val),
[],
);
var o = [];
var p = new Proxy(o, {
set(obj, id, value) {
obj[id] = flatten(value);
return obj;
},
});
p.arr = arr;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment