I'm doing JavaScript in node.js.
I'm trying wrap an object not yet constructed, allowing calls to any object function and set/get any object attribute through the wrapper, letting the wrapper pass calls/sets/gets to the object if bound in the wrapper or throw an exception if the object is not yet bound in the wrapper. I want to be ignorant to the object. I'm seeking a general purpose mechanism allowing me to wrap any object in this fashion.
I could construct a wrapper structure holding the object
wrapper = {
object: SomeObject
};
and address the object through wrapper dereference
wrapper.object.someFunction();
but I want to be transparent and use the following syntax instead:
wrapper.someFunction();
I have looked into the Proxy features of ECMAScript 6 but constantly came short on the apply() function trap. Is there a problem with JavaScript V8 and Node.js not being ECMAScript 6 compliant.
Any ideas?