Skip to content

Instantly share code, notes, and snippets.

@bga
Created October 27, 2010 21:45
Show Gist options
  • Save bga/650081 to your computer and use it in GitHub Desktop.
Save bga/650081 to your computer and use it in GitHub Desktop.
Object.prototype.__defineGetter__ = function(name, _fn)
{
var self = this;
var _wrapper = function()
{
return _fn.call(self);
};
this[name] =
{
valueOf: _wrapper,
toString: _wrapper,
jbGetter_: 1 // mark
};
};
Object.prototype.__lookupGetter__ = function(name)
{
if(this.hasOwnProperty(name) && this[name].hasOwnProperty('jbGetter_'))
return this[name].valueOf;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment