danShumway / vAnalyze.js

A middleware script that seeks to allow functions in local javascript to be automatically wrapped in custom code wrappers. These can then be used to aid profiling/error checking/code understanding.
GNU General Public License v2.0
4 stars 1 forks source link

Depreciate Object.infect for method that must be passed object? #16

Open danShumway opened 9 years ago

danShumway commented 9 years ago
var x = null;
x.infect(); //cannot call method of null object

This breaks the promise that infections can be run safely on any Javascript variable, and is true for both undefined and null. One solution would be to call infect through a more straightforward means.

var x = null;
Object.infect(x); //no error.

This is basically the only chance to do a change like this - once an API is completely finalized, I won't really be able to break compatibility in the same way, so this is worth considering for that reason alone.

Pros:

Cons:

Possible resolutions: