flatiron/utile — pull request #19 by englercj (2012-10-02 15:41:31+00:00)
Title: Add proxy method

I find myself using a proxy method a lot to maintain context on an event. I like to have event handlers has a object method, but still maintain `this`. Adding a proxy method make it simple to do, here is an example:

```javascript
var net = require('net'),
utile = require('utile');

var Obj = function() {
//instead of:
// var self = this;
// self.socket = net.connect({port:8124}, function() { self._onConnect.apply(self, arguments); });

//just use:
this.socket = net.connect({port: 8124}, utile.proxy(this._onConnect, this));
};

Obj.prototype._onConnect = function() {
//'this' is the Obj instance as it should be, even
//when it is called as the callback for connect
};
```

The code for this pull request was based on the [`jQuery.proxy()`](http://api.jquery.com/jQuery.proxy/) method ([source here](http://james.padolsey.com/jquery/#v=git&fn=jQuery.proxy))