espruino.js
function callProcessor(eventType, data, callback) {
    var p = processors[eventType];
    // no processors
    if (p===undefined || p.length==0) {
      if (callback!==undefined) callback(data);
      return;
    }
    // now go through all processors
    var n = 0;
    var cbCalled = false;
    var cb = function(inData) {
      if (cbCalled) throw new Error("Internal error in "+eventType+" processor. Callback is called TWICE.");
      cbCalled = true;
      if (n < p.length) {
        cbCalled = false;
        p[n++](inData, cb);
      } else {
        if (callback!==undefined) callback(inData);
      }
    };
    cb(data);
  }
function callProcessor(eventType, data, callback) {
    var p = processors[eventType];
    // no processors
    if (p===undefined || p.length==0) {
      if (callback!==undefined) callback(data);
      return;
    }
    // now go through all processors
    var n = 0;
    var cbCalled = false;
    var cb = function(inData) {
      if (cbCalled) throw new Error("Internal error in "+eventType+" processor. Callback is called TWICE.");
      cbCalled = true;
      if (n < p.length) {
        cbCalled = false;
        p[n++](inData, cb);
      } else {
        if (callback!==undefined) callback(inData);
      }
    };
    cb(data);
  }
function callProcessor ( eventType , data , callback ) { var p = processors [ eventType ] ; // no processors if ( p === undefined || p . length == 0 ) { if ( callback !== undefined ) callback ( data ) ; return ; } // now go through all processors var n = 0 ; var cbCalled = false ; var cb = function ( inData ) { if ( cbCalled ) throw new Error ( "Internal error in " + eventType + " processor. Callback is called TWICE." ) ; cbCalled = true ; if ( n < p . length ) { cbCalled = false ; p [ n ++ ] ( inData , cb ) ; } else { if ( callback !== undefined ) callback ( inData ) ; } } ; cb ( data ) ; }
Call a processor function
Call a processor function