<commit_before>var CPU = require("./cpu");
var Keyboard = require("./keyboard");
var PPU = require("./ppu");
var PAPU = require("./papu");
var ROM = require("./rom");

var NES = function(opts) {
  this.opts = {
    onFrame: function() {},
    onAudio: function() {},
    onStatusUpdate: function() {},

    preferredFrameRate: 60,

    emulateSound: true,
    sampleRate: 44100 // Sound sample rate in hz
  };
  if (typeof opts !== "undefined") {
    var key;
    for (key in this.opts) {
      if (typeof opts[key] !== "undefined") {
        this.opts[key] = opts[key];
      }
    }
  }

  this.frameTime = 1000 / this.opts.preferredFrameRate;

  this.ui = {
    writeFrame: this.opts.onFrame,
    writeAudio: this.opts.onAudio,
    updateStatus: this.opts.onStatusUpdate
  };
  this.cpu = new CPU(this);
  this.ppu = new PPU(this);
  this.papu = new PAPU(this);
  this.mmap = null; // set in loadROM()
  this.keyboard = new Keyboard();

  this.ui.updateStatus("Ready to load a ROM.");
};<commit_msg>Bind frame function so it can be used as callback<commit_after>var CPU = require("./cpu");
var Keyboard = require("./keyboard");
var PPU = require("./ppu");
var PAPU = require("./papu");
var ROM = require("./rom");

var NES = function(opts) {
  this.opts = {
    onFrame: function() {},
    onAudio: function() {},
    onStatusUpdate: function() {},

    preferredFrameRate: 60,

    emulateSound: true,
    sampleRate: 44100 // Sound sample rate in hz
  };
  if (typeof opts !== "undefined") {
    var key;
    for (key in this.opts) {
      if (typeof opts[key] !== "undefined") {
        this.opts[key] = opts[key];
      }
    }
  }

  this.frameTime = 1000 / this.opts.preferredFrameRate;

  this.ui = {
    writeFrame: this.opts.onFrame,
    writeAudio: this.opts.onAudio,
    updateStatus: this.opts.onStatusUpdate
  };
  this.cpu = new CPU(this);
  this.ppu = new PPU(this);
  this.papu = new PAPU(this);
  this.mmap = null; // set in loadROM()
  this.keyboard = new Keyboard();

  this.ui.updateStatus("Ready to load a ROM.");

  this.frame = this.frame.bind(this);
}
{'fraction_non_alphanumeric': 0.16554379210779596, 'fraction_numerical': 0.010587102983638113, 'mean_word_length': 2.9449715370018974, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2162254', 'n_tokens_mistral': 749, 'n_tokens_neox': 715, 'n_words': 179}