{"size": 908, "ext": "js", "max_stars_repo_path": "utils.js", "max_stars_repo_name": "tcardoso2/considering", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "utils.js", "max_issues_repo_name": "tcardoso2/considering", "max_issues_repo_issues_event_min_datetime": "2017-08-30T13:38:20.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-24T11:00:30.000Z", "max_forks_repo_path": "utils.js", "max_forks_repo_name": "tcardoso2/considering", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 21.1162790698, "max_line_length": 50, "alphanum_fraction": 0.5781938326}
"use strict"
function readLines(input, func) {
  let remaining = '';

  input.on('data', function(data) {
    remaining += data;
    var index = remaining.indexOf('\n');
    var last  = 0;
    while (index > -1) {
      var line = remaining.substring(last, index);
      last = index + 1;
      func(line);
      index = remaining.indexOf('\n', last);
    }

    remaining = remaining.substring(last);
  });

  input.on('end', function() {
    if (remaining.length > 0) {
      func(remaining);
    }
  });
}

function splitLines(input, func) {
  let result = [];
  if (input){
    let index = input.indexOf('\n');
    let last  = 0;
    while (index > -1) {
      result.push(input.substring(last, index))
      last = index + 1;
      index = input.indexOf('\n', last);
    }
    result.push(input.substring(last));
  }
  return result;  
}

exports.readLines = readLines;
exports.splitLines = splitLines;
