Guest User

Untitled

a guest
Jul 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. function coo(x) {
  2. let sec = arguments[1]
  3. const y = x || {}
  4. if (y.arr) y.arr.push(sec)
  5. if (!y.arr){
  6. y.arr = sec ? [sec] : []
  7. }
  8.  
  9. return new Proxy(y, {
  10. get(a, b) {
  11.  
  12. a.arr.reduce((hash, x) => {
  13. if (!hash[x]){
  14. hash[x] = {}
  15. }
  16. return hash[x]
  17. }, a)
  18.  
  19. return coo(a, b)
  20. }
  21. })
  22. }
Add Comment
Please, Sign In to add comment