How do I automate wrapping methods?
<p>I would like to automatically wrap all methods in an object with a function.
For now, I only know how to do it one by one:</p>

<p>jsfiddle: <a href="http://jsfiddle.net/4VuE7/" rel="nofollow">http://jsfiddle.net/4VuE7/</a></p>

<p>code:</p>

<pre><code>&lt;div style=white-space:pre&gt;
&lt;i&gt;foo bar lorem ipsum&lt;/i&gt;
&lt;i&gt;foo bar lorem ipsum&lt;/i&gt;
&lt;i&gt;foo bar lorem ipsum&lt;/i&gt;
&lt;i&gt;foo bar lorem ipsum&lt;/i&gt;
&lt;i&gt;foo bar lorem ipsum&lt;/i&gt;
&lt;i&gt;foo bar lorem ipsum&lt;/i&gt;
&lt;/div&gt;​
&lt;script&gt;

//method that only works on elements:
Element.prototype.css = function(a,i,n){for(n in''+a===a||a)this.style[n]=a[n];return i||n?(this.style[a]=i,this):getComputedStyle(this)[a]};

//put a wrapper around it that makes it work with nodelists
NodeList.prototype.css = function(a,i){for(var n in this)this[n].css(a,i)};

//put a wrapper around it so it works with a selector in a string
String.prototype.css = function(a,i){document.querySelectorAll(this).css(a,i)}​;

//use the method:

"div&gt;i".css("color","red")​;​

&lt;/script&gt;
</code></pre>

<p>I would like to do this automatically for every method in the object. (a single function wraps every method automatically)</p>

<p>disclaimer: Don't mess around with the dom unless you really know what you are doing! (You probably don't!) This example is for demonstration purposes only.</p>
