Skip to content

Instantly share code, notes, and snippets.

@liondancer
Created January 28, 2017 07:17
Show Gist options
  • Save liondancer/a9bd7b191369791142c2622c9bc5021f to your computer and use it in GitHub Desktop.
Save liondancer/a9bd7b191369791142c2622c9bc5021f to your computer and use it in GitHub Desktop.
.then(
while (minheap.heapList.length) {
let heapNode = minheap.popMin();
let currTimestamp = heapNode['ts'];
printer.print(heapNode.data);
let nextMinTimestamp = minheap.getPeakTimestamp();
while (currTimestamp <= nextMinTimestamp) {
logSources[heapNode['source']].popAsync().then(log => {
if (log) {
let logtime = log.date.getTime();
if (logtime <= nextMinTimestamp) {
printer.print(log);
currTimestamp = logtime;
} else {
minheap.insert({
ts: logtime,
source: heapNode["source"],
data: log
});
break;
}
}
});
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment