<commit_before>var Nano = function(device, connection) {
	this.device = device;
	this.connection = connection;
	this._in_buffer = [];
	this._out_buffer = [];
	this._send_queue = 0;
	this._BUFFER_SIZE = 32;
};

Nano.prototype.push_data = function(data) {
	if (this._out_buffer.length >= this._BUFFER_SIZE)
		return false;
	var pkgs = [];
	var cnt = Math.ceil(data.byteLength / 33);
	for (var idx = 1; idx < cnt + 1; idx++) {
		pkgs.push(mm_encode(
			P_WORK, idx, cnt, data.slice((idx - 1) * 32, idx * 32)
		));
	}
	this._out_buffer.push(pkgs);
	return true;
};

Nano.prototype.detect = function(callback) {
	var nano = this;
	this._send(mm_encode(
		P_DETECT, 0x01, 0x01,
		new ArrayBuffer(32)
	));
	this._receive(function(pkg) {
		var data = mm_decode(pkg);

		// TODO: what if it is not a P_ACKDETECT package?
		if (data.type === P_ACKDETECT) {
			nano.log("log1", "Version: %s", data.version);
			nano.version = data.version;
			callback();
		}
	});
};

Nano.prototype.run = function(queue_size) {
	var nano = this;
	this.detect(function() {
		if (check_version(nano.version)) {
			nano._stop = false;
			nano._receive_loop();
			nano._decode_loop();
			nano._send_loop(5);
		}
	});
};

Nano.prototype.stop = function() {
	this._stop = true;
	this.log("info", "Stopped.");
};

Nano.prototype.disconnect = function() {
	var nano = this;
	chrome.hid.disconnect(nano.connection.connectionId, function() {
		this.log("info", "Disconnected.");
	});
};

Nano.prototype.log = function(level) {
	var args = Array.prototype.slice.call(arguments);
	var i;
	switch (level) {
		case 'error':<commit_msg>APP: Fix typo<commit_after>var Nano = function(device, connection) {
	this.device = device;
	this.connection = connection;
	this._in_buffer = [];
	this._out_buffer = [];
	this._send_queue = 0;
	this._BUFFER_SIZE = 32;
};

Nano.prototype.push_data = function(data) {
	if (this._out_buffer.length >= this._BUFFER_SIZE)
		return false;
	var pkgs = [];
	var cnt = Math.ceil(data.byteLength / 33);
	for (var idx = 1; idx < cnt + 1; idx++) {
		pkgs.push(mm_encode(
			P_WORK, idx, cnt, data.slice((idx - 1) * 32, idx * 32)
		));
	}
	this._out_buffer.push(pkgs);
	return true;
};

Nano.prototype.detect = function(callback) {
	var nano = this;
	this._send(mm_encode(
		P_DETECT, 0x01, 0x01,
		new ArrayBuffer(32)
	));
	this._receive(function(pkg) {
		var data = mm_decode(pkg);

		// TODO: what if it is not a P_ACKDETECT package?
		if (data.type === P_ACKDETECT) {
			nano.log("log1", "Version: %s", data.version);
			nano.version = data.version;
			callback();
		}
	});
};

Nano.prototype.run = function(queue_size) {
	var nano = this;
	this.detect(function() {
		if (check_version(nano.version)) {
			nano._stop = false;
			nano._receive_loop();
			nano._decode_loop();
			nano._send_loop(5);
		}
	});
};

Nano.prototype.stop = function() {
	this._stop = true;
	this.log("info", "Stopped.");
};

Nano.prototype.disconnect = function() {
	var nano = this;
	chrome.hid.disconnect(nano.connection.connectionId, function() {
		nano.log("info", "Disconnected.");
	});
};

Nano.prototype.log = function(level) {
	var args = Array.prototype.slice.call(arguments);
	var i;
	switch (level) {
		case 'error':
{'fraction_non_alphanumeric': 0.17095357590966123, 'fraction_numerical': 0.013801756587202008, 'mean_word_length': 3.883614088820827, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2168083', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1215, 'n_words': 241}