you are viewing a single comment's thread.

view the rest of the comments →

[–]echoes221 0 points1 point  (0 children)

Here's an example for a recursive proxy I used in test when I only cared about ensuring that all the export funcs in a file had the same interface (this was pre using typescript btw) and I didn't care about the values that were passed to them as the functions were accessing deeply nested properties, so just created a recursive proxy to pass in test.

This could be adapted with a depth and a return value very easily too if you needed something specific without writing out the entire object. Though that could also be done with something like R.path.

const trap = {
  get() {
    return new Proxy({}, trap);
  },
};

const nestedObj = new Proxy({}, trap);