Hi,

I'm trying to create a simple object decorator in JavaScript. Since I'm only interested in decorating a couple of methods, I don't want to copy the whole interface of the object to the decorator manually. Ideally, I would like the decorator to blindly forward all its method calls to the object it decorates EXCEPT those few methods I need to alter.

Here's an example:

Code:
// The original interface

MyObject.doSomething1(); // I want to alter this one...
MyObject.doSomething2(); // ... and this one, too
MyObject.doSomethingElse1(); // I don't care about this one...
MyObject.doSomethingElse2(); // ... nor this one or any other

// The decorator

var deco = new Decorator(new MyObject());
deco.doSomething1(); // This calls the decorator's doSomething1()
deco.doSomething2(); // This calls the decorator's doSomething2()

deco.doSomethingElse1(); // This should call the original object's doSomethingElse1()
deco.doSomethingElse2(); // This should call the original object's doSomethingElse2()
Something similar to __call() in PHP would be very useful here.

Is there a way to do what I want?