Skip to content

Instantly share code, notes, and snippets.

@JedWatson
JedWatson / async.js
Last active January 3, 2016 14:19 — forked from getify/gist:8459026
Comparison between (my) old callback-structured code, @getify's asynquence refactor, and my async refactor
var doQuery = function() {
// passing an object to async.parallel will cause it to collect their results
// and provide them to the callback in an object with the same keys.
async.parallel({
// functions are passed a callback with the standard argument pattern of fn(err, result)
count: count.exec,
query: query.exec
}, function(err, results) {
@JedWatson
JedWatson / async.js
Last active January 3, 2016 18:29 — forked from getify/async.js
Another refactor of a refactor, this time w/o all original comments but w/ proposals. Not currently possible with asynquence, but maybe? *nudge*
var transform = function(contents, doneTransform) {
var authExpiry = 60 * 60 * 1000,
authId = uuid.v4(),
authKey = 'file:auth:' + authId;
redis.client.set(authKey, JSON.stringify({
userId: req.user.id
}));
redis.client.expire(authKey, authExpiry);