raganwald/method-combinators — pull request #12 by ludicast (2012-11-20 01:03:02+00:00)
Title: added sed

The sed combinator transforms a parameter at whatever index you input. Useful in situations analogous to Rails route helpers. `user_path(user)` is sometimes fed a user and sometimes fed a user id. In cases where it is fed a user's id, sed can transform that id into an actual user as the function parameter (or vice-versa). This prevents the function from needing to contain an `if` or `switch` statement that explicitly does the transformation.

So it world be like this

```coffeescript
findUser = (sed (user)->
if _.isObject(user)
user
else
@lookupUserById user
)()
class RouteHelpers
userPath: findUser (user)->
```