3 ms·
I would write something like this: function handler(yes, no) { return function (err, data) { if (data) { yes(err, data);
by lea 15y ago
I would write something like this:
function handler(yes, no) {
return function (err, data) {
if (data) {
yes(err, data);
}
else {
no(err, data);
}
}
}
function get() {
function done(err, data) {
// do something with data
}
function db() {
asynchronousDb.query("SELECT * fomr something where id = 3244", done);
}
asynchronousCache.get("id:3244", handler(done, db));
}