Open danShumway opened 9 years ago
Basic proposal script is up here: http://jsfiddle.net/danShumway/evrdgxjc/ - reminder that it won't work on Chrome.
This fixes the problem with instanceof
as well as demonstrates some test cases. Basically the way that it works is to generate an Infection object (distinct from what we normally return) that is attached to the prototype of a Host. The code is then returned a Proxy object linked to that Infection.
The result is that accessing either object will result in up-to-date information about the other object.
To adapt this to vAnalyze's use-case, I would likely attach additional code to the call
handler, as well as log additional information whenever anything is accessed via the proxy.
Problem: wrapped functions may not catch existing references to function.
Problem: Host properties need to continually refresh themselves / Host must continuously check for new properties.
Possible future solution: Implement 2-way synchronous data-synchronization using ES6 Proxies and by infecting the prototype chain with invisible objects.
instanceof
. Unsure of what would be required to get this back.