{"size": 839, "ext": "js", "max_stars_repo_path": "lib/reader.js", "max_stars_repo_name": "co3moz/ko-klg-reader", "max_stars_repo_stars_event_min_datetime": "2018-07-30T18:44:26.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-07T07:59:26.000Z", "max_issues_repo_path": "lib/reader.js", "max_issues_repo_name": "co3moz/ko-klg-reader", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/reader.js", "max_forks_repo_name": "co3moz/ko-klg-reader", "max_forks_repo_forks_event_min_datetime": "2019-11-08T01:28:53.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-05T11:45:01.000Z"}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 20.4634146341, "max_line_length": 71, "alphanum_fraction": 0.5196662694}
const fse = require('fs-extra');

module.exports = async function (file, out) {
  const fd = await fse.open(file, 'r');

  while (true) {
    let num = Buffer.allocUnsafe(4);

    if ((await fse.read(fd, num, 0, 4)).bytesRead != 4) break;

    num = num.readInt32LE(0);

    if (num > 0x8000) {
      throw new Exception('String is too long to decompile: ' + num);
    }

    let data = Buffer.allocUnsafe(num);

    if ((await fse.read(fd, data, 0, num)).bytesRead != num) break;

    let v = 0x816;

    for (let i = 0; i < num; i++) {
      let a = data[i];

      let z = (v & 0xff00) >>> 8;
      let b = (z ^ a) & 0xFF;
      v = (((((a + v) & 0xffff) * 0x6081) & 0xffff) + 0x1608) & 0xffff;

      data[i] = b;
    }

    if (out) {
      out(data);
    } else {
      process.stdout.write(data);
    }
  }

  await fse.close(fd);
}