cstephen / hashtag-count

Count hashtag occurrences over time using Twitter's Streaming API.
MIT License
7 stars 4 forks source link

intervalCb results grow forever #9

Open sean256 opened 5 years ago

sean256 commented 5 years ago

I noticed you are always appending new keys to the same {} for results. This can grow to an unruly size and pretty quickly if left alone for awhile.

May I suggest you only return the results for the single interval? Leave it up to us users to reconcile if we need to.

If anyone else is wanting a quick solve here is what I did

const intervalCb = (err, results) => {
        if (err) {
            console.log(err);
        } else {
            console.log(results);
            // delete the key in the object. It's passed by reference so we can clean it up here.
            const key = Object.keys(results)[0];
            delete results[key];
        }
    },