services/visual_recognition/v3.js
function addTask(asyncTasks, msg, k, listParams, node) {
    asyncTasks.push(function(callback) {
      var buffer = msg.params[k];
      temp.open({
        suffix: '.' + fileType(buffer).ext
      }, function(err, info) {
        if (err) {
          node.status({
            fill: 'red',
            shape: 'ring',
            text: 'unable to open image stream'
          });
          node.error('Node has been unable to open the image stream', msg);
          return callback('open error on ' + k);
        }
        stream_buffer(info.path, msg.params[k], function() {
          let example_name = k;
          if (! (k.includes('positive') || k.includes('negative'))) {
            example_name = k.replace('examples', 'positive_examples');
          }
          listParams[example_name] = fs.createReadStream(info.path);
          callback(null, example_name);
        });
      });
    });
  }
function addTask(asyncTasks, msg, k, listParams, node) {
    asyncTasks.push(function(callback) {
      var buffer = msg.params[k];
      temp.open({
        suffix: '.' + fileType(buffer).ext
      }, function(err, info) {
        if (err) {
          node.status({
            fill: 'red',
            shape: 'ring',
            text: 'unable to open image stream'
          });
          node.error('Node has been unable to open the image stream', msg);
          return callback('open error on ' + k);
        }
        stream_buffer(info.path, msg.params[k], function() {
          let example_name = k;
          if (! (k.includes('positive') || k.includes('negative'))) {
            example_name = k.replace('examples', 'positive_examples');
          }
          listParams[example_name] = fs.createReadStream(info.path);
          callback(null, example_name);
        });
      });
    });
  }
function addTask ( asyncTasks , msg , k , listParams , node ) { asyncTasks . push ( function ( callback ) { var buffer = msg . params [ k ] ; temp . open ( { suffix : '.' + fileType ( buffer ) . ext } , function ( err , info ) { if ( err ) { node . status ( { fill : 'red' , shape : 'ring' , text : 'unable to open image stream' } ) ; node . error ( 'Node has been unable to open the image stream' , msg ) ; return callback ( 'open error on ' + k ) ; } stream_buffer ( info . path , msg . params [ k ] , function ( ) { let example_name = k ; if ( ! ( k . includes ( 'positive' ) || k . includes ( 'negative' ) ) ) { example_name = k . replace ( 'examples' , 'positive_examples' ) ; } listParams [ example_name ] = fs . createReadStream ( info . path ) ; callback ( null , example_name ) ; } ) ; } ) ; } ) ; }
This is where the two read stream tasks are built, individually asynTasks will be the two functions that will be invoked added one at a time, each time this function is invoked msg holds the parameters k is the key value for the files in msg. listParams is where the files will go so that they can be sent to the service. callback is the callback that async forces so that it can control the async functions that it is invoking.
This is where the two read stream tasks are built individually asynTasks will be the two functions that will be invoked added one at a time each time this function is invoked msg holds the parameters k is the key value for the files in msg . listParams is where the files will go so that they can be sent to the service . callback is the callback that async forces so that it can control the async functions that it is invoking .