caolan/async — pull request #388 by vbuterin (2013-10-05 09:29:11+00:00)
Title: Added getter and setter

Some example applications:

A somewhat lengthy e-commerce example:
```javascript
function createPayment(buyerName, sellerName, itemId, cb) {
var scope = {}
async.series([
function(cb2) {
User.findOne({ name: buyerName }, async.setter(scope, 'buyer', cb2))
}, function(cb2) {
User.findOne({ name: sellerName }, async.setter(scope, 'seller', cb2))
}, function(cb2) {
Item.findOne({ user: scope.seller, itemId: itemId }, async.setter(scope, 'item', cb2))
}, function(cb2) {
calculatePrice(scope.buyer, scope.item, async.setter(scope, 'price', cb2))
}, function(cb2) {
generatePaymentRequestData(buyer, scope.seller, scope.price, async.setter(scope, 'request', cb2))
}, function(cb2) {
PaymentRequest.insert(scope.request, cb)
}
]);
}
```
With async.waterfall, all of the intermediate data would need to be threaded through the entire computation. Here, everything stays as series of clean one-liners that looks almost like imperative code.

```javascript
function getRequestedAmount(reqId, cb) {
async.waterfall([
function(cb2) { PaymentRequest.findOne({ reqId: reqId }, cb2),
async.getter('price')
],cb);
}
```

And so forth.