Skip to content

Instantly share code, notes, and snippets.

@marocchino
Created December 7, 2012 03:13
Show Gist options
  • Save marocchino/4230463 to your computer and use it in GitHub Desktop.
Save marocchino/4230463 to your computer and use it in GitHub Desktop.
modularize
var async = require('async');
var p =
[ function (cb) { redis.get('key1', cb); }
, function (cb) { couchdb.get('key2', cb); }
];
async.parallel(p, function (err, results) {
console.log(results[0]);
console.log(results[1]);
});
var async = require('async');
module.exports = function (key, cb) {
var p =
[ function (cb) { redis.get(key, cb); }
, function (cb) { couchdb.get(key, cb); }
];
async.parallel(p, function (err, results) {
cb(err, results);
});
};
var getter = require('2_getter');
var cb = function (err, results) {
console.log(results[0]);
console.log(results[1]);
};
getter("key1", cb);
getter("key2", cb);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment