Created
October 25, 2016 23:23
-
-
Save mk-pmb/86eba3084ebec6530248acf4b89bb0dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jslint indent: 2, maxlen: 80, continue: false, unparam: false, node: true */ | |
/* -*- tab-width: 2 -*- */ | |
'use strict'; | |
var async = require('async'), a, b, c, d, db; | |
db = { | |
get: function (num, hnd) { return hnd(null, num * 3); }, | |
}; | |
function randomInt(min, max) { return (min || max); } | |
async.map([[a, 100], [b, 200], [c, 305], [d, 600]], function (inputData, next) { | |
var database = inputData[0], max = inputData[1]; | |
function onDbReply(dbReplyErr, dbReplyData) { | |
if (dbReplyErr) { | |
console.error('W:', dbReplyErr); | |
return next(dbReplyErr); | |
} | |
console.log('I: DB get:', dbReplyData); | |
return next(null); // null in the error slot = report success | |
} | |
db.get(randomInt(0, max), onDbReply); | |
console.log('W: unused variable: database =', database); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment