index.js
function heapify(heap, i) {
  var l = getLeft(i);
  var r = getRight(i);
  var smallest = i;
  if (l < heap.list.length &&
      heap.compare(heap.list[l], heap.list[i]) < 0) {
    smallest = l;
  }
  if (r < heap.list.length &&
      heap.compare(heap.list[r], heap.list[smallest]) < 0) {
    smallest = r;
  }
  if (smallest !== i) {
    swap(heap.list, i, smallest);
    heapify(heap, smallest);
  }
}
function heapify(heap, i) {
  var l = getLeft(i);
  var r = getRight(i);
  var smallest = i;
  if (l < heap.list.length &&
      heap.compare(heap.list[l], heap.list[i]) < 0) {
    smallest = l;
  }
  if (r < heap.list.length &&
      heap.compare(heap.list[r], heap.list[smallest]) < 0) {
    smallest = r;
  }
  if (smallest !== i) {
    swap(heap.list, i, smallest);
    heapify(heap, smallest);
  }
}
function heapify ( heap , i ) { var l = getLeft ( i ) ; var r = getRight ( i ) ; var smallest = i ; if ( l < heap . list . length && heap . compare ( heap . list [ l ] , heap . list [ i ] ) < 0 ) { smallest = l ; } if ( r < heap . list . length && heap . compare ( heap . list [ r ] , heap . list [ smallest ] ) < 0 ) { smallest = r ; } if ( smallest !== i ) { swap ( heap . list , i , smallest ) ; heapify ( heap , smallest ) ; } }
Heapifies a node.

@private
@param {BinaryHeap} heap The heap containing the node to heapify.
@param {number} i The index of the node to heapify.
Heapifies a node .