Skip to content

Instantly share code, notes, and snippets.

@hillar
Created February 7, 2014 15:52
Show Gist options
  • Save hillar/8865400 to your computer and use it in GitHub Desktop.
Save hillar/8865400 to your computer and use it in GitHub Desktop.
var async = require('async.js');
var data = {}
data.time = 12345678;
data.tags = [1,2,3];
function post (data) {
var results = {};
results.start = new Date().getTime();
var updateSession = function(callback) {
console.log('updateSession')
results.saved = true;
console.dir(results);
callback(null,results);
}
var findTag = function(callback){
console.log('findTag');
console.dir(item);
callback(null,(item*10)+'asd');
}
var findTags = function(callback) {
console.log('findTags');
console.dir(results);
async.mapSeries(data.tags,findTag,function(e,r){
results.tags = r;
console.log('f tags last:'+e,' :'+r);
callback(null);
});
}
var findSessionID = function(callback){
console.log('findSessionID');
results.sessionID = '12qdqwd12312eadfadf';
console.dir(results);
callback(null);
}
var isIndiceName = function(callback){
console.log('isIndiceName');
results.isIndiceName = new Date(data.time*1000);
console.dir(results);
callback(null);
}
async.waterfall([isIndiceName,findSessionID,findTags,updateSession],function(e,r){
console.log('final');
console.dir(e);
console.dir(r);
results.end = new Date().getTime();
console.dir(results.end - results.start);
})
}
post(data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment