jrpc.js
function deliverResponse(res) {
  var err = false;
  var result = null;

  if (this.active && 'id' in res && res['id'] in this.outTimers) {
    clearTimeout(this.outTimers[res['id']]);  // Passing true instead of a timeout is safe
    delete this.outTimers[res['id']];
  } else {
    // Silently ignoring second response to same request
    return;
  }

  if (res['id'] in this.inbox) {
    if ('error' in res) {
      err = res['error'];
    } else {
      result = res['result'];
    }
    setImmediate(this.inbox[res['id']], err, result);
    delete this.inbox[res['id']];
  }
  // Silently ignore timeout duplicate and malformed responses
}
function deliverResponse(res) {
  var err = false;
  var result = null;

  if (this.active && 'id' in res && res['id'] in this.outTimers) {
    clearTimeout(this.outTimers[res['id']]);  // Passing true instead of a timeout is safe
    delete this.outTimers[res['id']];
  } else {
    // Silently ignoring second response to same request
    return;
  }

  if (res['id'] in this.inbox) {
    if ('error' in res) {
      err = res['error'];
    } else {
      result = res['result'];
    }
    setImmediate(this.inbox[res['id']], err, result);
    delete this.inbox[res['id']];
  }
  // Silently ignore timeout duplicate and malformed responses
}
function deliverResponse ( res ) { var err = false ; var result = null ; if ( this . active && 'id' in res && res [ 'id' ] in this . outTimers ) { clearTimeout ( this . outTimers [ res [ 'id' ] ] ) ; // Passing true instead of a timeout is safe delete this . outTimers [ res [ 'id' ] ] ; } else { // Silently ignoring second response to same request return ; } if ( res [ 'id' ] in this . inbox ) { if ( 'error' in res ) { err = res [ 'error' ] ; } else { result = res [ 'result' ] ; } setImmediate ( this . inbox [ res [ 'id' ] ] , err , result ) ; delete this . inbox [ res [ 'id' ] ] ; } // Silently ignore timeout duplicate and malformed responses }
Callback invoked when remote results are ready

@callback JRPC~receiveCallback

@param {boolean} err    True if the result is an error or unavailable
@param {Object}  result The result from the remote method

@return {undefined} No return value
 
Deliver a received result

@param {Object}  res     The single result to parse

@return {undefined} No return value
Callback invoked when remote results are ready