JavaScript has no built-in heap, so write one. Implement a Heap class whose constructor takes a comparator and an optional array of starting items.
new Heap(compare, items = []): compare(a, b) follows the Array.prototype.sort contract. A negative result means a must come out before bpush(item) adds an item, pop() removes and returns the item that comes out first, peek() returns it without removing, size() returns the countpop() and peek() on an empty heap return undefined- The starting
items array must not be reordered or changed. Build the heap from a copy, and aim for O(n) for that step push and pop must be O(log n)