{"size": 684, "ext": "js", "max_stars_repo_path": "querybuffer.js", "max_stars_repo_name": "sirsquidness/steam-discover", "max_stars_repo_stars_event_min_datetime": "2016-05-14T17:20:06.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-01T03:57:12.000Z", "max_issues_repo_path": "querybuffer.js", "max_issues_repo_name": "sirsquidness/steam-discover", "max_issues_repo_issues_event_min_datetime": "2016-06-21T11:27:27.000Z", "max_issues_repo_issues_event_max_datetime": "2016-12-27T03:34:16.000Z", "max_forks_repo_path": "querybuffer.js", "max_forks_repo_name": "OpenSourceLAN/steam-discover", "max_forks_repo_forks_event_min_datetime": "2016-06-30T10:18:12.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-08T00:34:07.000Z"}
{"max_stars_count": 34, "max_issues_count": 2, "max_forks_count": 8, "avg_line_length": 20.7272727273, "max_line_length": 113, "alphanum_fraction": 0.6388888889}
"use strict";


class querybuffer {

  constructor(millisecondsBetweenResults, callback) {
    this.timeInterval = millisecondsBetweenResults;
    this.items = [];
    this.callback = callback;

    if (typeof this.timeInterval !== "number" || this.timeInterval <= 0 || typeof this.callback !== "function") {
       throw "invalid arguments";
    }
    var t = this;
    this.interval = setInterval(() => {t.interval_event(); }, this.timeInterval);
  }

  interval_event() {

    var items = this.items;
    this.items = [];
    this.callback(items);
  }

  addItem(item) {
    this.items.push(item);
  }

  disable() { clearTimeout(this.interval); }
}

module.exports = querybuffer;
