src/index.js
function rotateLeft (node) {
  var rightNode = node.right;
  node.right    = rightNode.left;

  if (rightNode.left) rightNode.left.parent = node;

  rightNode.parent = node.parent;
  if (rightNode.parent) {
    if (rightNode.parent.left === node) {
      rightNode.parent.left = rightNode;
    } else {
      rightNode.parent.right = rightNode;
    }
  }

  node.parent    = rightNode;
  rightNode.left = node;

  node.balanceFactor += 1;
  if (rightNode.balanceFactor < 0) {
    node.balanceFactor -= rightNode.balanceFactor;
  }

  rightNode.balanceFactor += 1;
  if (node.balanceFactor > 0) {
    rightNode.balanceFactor += node.balanceFactor;
  }
  return rightNode;
}
function rotateLeft (node) {
  var rightNode = node.right;
  node.right    = rightNode.left;

  if (rightNode.left) rightNode.left.parent = node;

  rightNode.parent = node.parent;
  if (rightNode.parent) {
    if (rightNode.parent.left === node) {
      rightNode.parent.left = rightNode;
    } else {
      rightNode.parent.right = rightNode;
    }
  }

  node.parent    = rightNode;
  rightNode.left = node;

  node.balanceFactor += 1;
  if (rightNode.balanceFactor < 0) {
    node.balanceFactor -= rightNode.balanceFactor;
  }

  rightNode.balanceFactor += 1;
  if (node.balanceFactor > 0) {
    rightNode.balanceFactor += node.balanceFactor;
  }
  return rightNode;
}
function rotateLeft ( node ) { var rightNode = node . right ; node . right = rightNode . left ; if ( rightNode . left ) rightNode . left . parent = node ; rightNode . parent = node . parent ; if ( rightNode . parent ) { if ( rightNode . parent . left === node ) { rightNode . parent . left = rightNode ; } else { rightNode . parent . right = rightNode ; } } node . parent = rightNode ; rightNode . left = node ; node . balanceFactor += 1 ; if ( rightNode . balanceFactor < 0 ) { node . balanceFactor -= rightNode . balanceFactor ; } rightNode . balanceFactor += 1 ; if ( node . balanceFactor > 0 ) { rightNode . balanceFactor += node . balanceFactor ; } return rightNode ; }
Single left rotation
@param  {Node} node
@return {Node}
Single left rotation