recursion-proxy
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

Recursion Proxy Implementation (ES6+)

Example

import RecursionProxy from 'recursion-proxy';

const source = {a: { b: { c: { d: 5 } } } };

const proxy = new RecursionProxy(source, {
  get(target, prop, receiver, propPath) {
    console.log("get prop:", propPath);
    return Reflect.get(target, prop, receiver);
  },
  set(target, p, value, r, propPath, reactiveWrapper) {
    console.log("set prop:", propPath);
    return Reflect.set(
      target, 
      p, 
      reactiveWrapper(value),  // Wrap to Recursion Proxy Object
      r
    );
  }
});

let a = proxy.a.b.c.d;
// Console Output: get prop: ["a", "b", "c", "d"]

proxy.b = {};
// Console Output: set prop: ["b"]

console.log(proxy.b) // Proxy {}

proxy.b.b
// Console Output: get prop: ["b", "b"]

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i recursion-proxy

      Weekly Downloads

      0

      Version

      0.1.5

      License

      MIT

      Unpacked Size

      5.64 kB

      Total Files

      4

      Last publish

      Collaborators

      • _hydrogen