Created
March 28, 2018 22:45
-
-
Save ivikash/37802d6397d198624c50b014d3091bff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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