2.0.0 • Published 8 years ago

swappable-proxy v2.0.0

Weekly downloads
3
License
GPL-2.0
Repository
github
Last release
8 years ago

swappable-proxy

Example:

A.js:
const SwappableProxy = require("swappable-proxy"),
      B              = require("./b");

function A() {
  let proxy = new SwappableProxy(this);

  function doSwap() {
    proxy.swap(new B());
  }
  this.doSwap = doSwap;

  function sayHi() {
    console.log("My name is A");
  }
  this.sayHi = sayHi;

  return proxy.instance;
}

module.exports = A;
B.js:
function B() {
  function sayHi() {
    console.log("This is B");
  }
  this.sayHi = sayHi;
}

module.exports = B;
index.js:
let obj = new A();
obj.sayHi(); // My name is A
obj.doSwap();
obj.sayHi(); // This is B
2.0.0

8 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago