Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
updateHeap: function(key) {
var estimate = this.get(key);
if (this.heap.length == 0 || estimate >= this.heap[0].value) {
if (key in this.topK) {
var oldPair = this.topK[key];
oldPair.value = estimate;
Heap.heapify(this.heap);
} else {
if (fn.objSize(this.topK) < this.k) {
Heap.push(this.heap, {key: key, value: estimate});
this.topK[key] = {key: key, value: estimate};
this.topKSize++;
} else {
var newPair = {key: key, value: estimate};
var oldPair = Heap.pushpop(this.heap, newPair);
delete this.topK[oldPair[1]];
this.topK[key] = newPair;
}
}
}
},