Skip to content

Instantly share code, notes, and snippets.

@mk-pmb
Created October 25, 2016 23:23
Show Gist options
  • Save mk-pmb/86eba3084ebec6530248acf4b89bb0dc to your computer and use it in GitHub Desktop.
Save mk-pmb/86eba3084ebec6530248acf4b89bb0dc to your computer and use it in GitHub Desktop.
/*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