lib/private/trampoline.js
function trampoline(queue) {
  index = [0];
  stack = [queue];

  var queueIndex, queueLength;

  var stackIndex = 1; // 1-indexed!
  var stackLength = stack.length;
  var topOfStack = true;
  while (stackIndex) {
    queue = stack[stackIndex - 1];
    queueIndex = index[stackIndex - 1];
    if (queueIndex === -1) {
      queueIndex = index[stackIndex - 1] = 0;
    }
    queueLength = queue.length;

    while (queueIndex < queueLength && topOfStack) {
      queue[queueIndex].resolve(
          queue[queueIndex + 1],
          queue[queueIndex + 2],
          queue[queueIndex + 3]);

      queueIndex += 4;
      stackLength = stack.length;
      topOfStack = stackLength === stackIndex;
    }

    if (!topOfStack) {
      index[stackIndex - 1] = queueIndex;
      stackIndex = stackLength;
      topOfStack = true;
    } else {
      index.pop();
      stack.pop();
      stackIndex--;
    }
  }
  stack = index = null;
}
function trampoline(queue) {
  index = [0];
  stack = [queue];

  var queueIndex, queueLength;

  var stackIndex = 1; // 1-indexed!
  var stackLength = stack.length;
  var topOfStack = true;
  while (stackIndex) {
    queue = stack[stackIndex - 1];
    queueIndex = index[stackIndex - 1];
    if (queueIndex === -1) {
      queueIndex = index[stackIndex - 1] = 0;
    }
    queueLength = queue.length;

    while (queueIndex < queueLength && topOfStack) {
      queue[queueIndex].resolve(
          queue[queueIndex + 1],
          queue[queueIndex + 2],
          queue[queueIndex + 3]);

      queueIndex += 4;
      stackLength = stack.length;
      topOfStack = stackLength === stackIndex;
    }

    if (!topOfStack) {
      index[stackIndex - 1] = queueIndex;
      stackIndex = stackLength;
      topOfStack = true;
    } else {
      index.pop();
      stack.pop();
      stackIndex--;
    }
  }
  stack = index = null;
}
function trampoline ( queue ) { index = [ 0 ] ; stack = [ queue ] ; var queueIndex , queueLength ; var stackIndex = 1 ; // 1-indexed! var stackLength = stack . length ; var topOfStack = true ; while ( stackIndex ) { queue = stack [ stackIndex - 1 ] ; queueIndex = index [ stackIndex - 1 ] ; if ( queueIndex === - 1 ) { queueIndex = index [ stackIndex - 1 ] = 0 ; } queueLength = queue . length ; while ( queueIndex < queueLength && topOfStack ) { queue [ queueIndex ] . resolve ( queue [ queueIndex + 1 ] , queue [ queueIndex + 2 ] , queue [ queueIndex + 3 ] ) ; queueIndex += 4 ; stackLength = stack . length ; topOfStack = stackLength === stackIndex ; } if ( ! topOfStack ) { index [ stackIndex - 1 ] = queueIndex ; stackIndex = stackLength ; topOfStack = true ; } else { index . pop ( ) ; stack . pop ( ) ; stackIndex -- ; } } stack = index = null ; }
Starts a trampoline to process the queue.
Starts a trampoline to process the queue .