documentcloud/underscore-contrib — pull request #95 by jamesmacaulay (2013-11-09 16:47:44+00:00)
Title: New functions: _.functionalize & _.methodize rotate `this` in and out of args

The purpose of these functions is to help a little in bridging the gap between the worlds of functional and OO.

`_.functionalize` takes a "method-style" function (one which uses `this`) and returns a new function which uses only its argument list. The first argument of the returned function gets used as the receiver (`this`) of the original function.

`_.methodize` is the inverse operation, taking an arguments-oriented function which doesn't rely on `this` and returning a function which is suitable for use as an object method (where `this` is passed as the first argument to the original function).

Both of these functions can be understood as rotating `this` in and out of the argument list (from the left-hand side).