<commit_before>const SerialPort = require("serialport");

class GQGeiger {
	constructor(port, baud){
		this.geigerPort = new SerialPort(port, {baudrate: baud});
		this.queue = [];
		const tempThis = this;
		this.geigerPort.on('data', function(data) {
			const cD = tempThis.queue.shift();
			cD.internalCallback(cD.externalCallback, data);
		});
	}
	
	processCPM(callback, buffer){
		const cpm = buffer.readUInt16BE(0);
		callback(null, cpm);
	}
	getCPM(callback){
		const tempThis = this;
		this.geigerPort.write(new Buffer("<GETCPM>>", 'ascii'), function(err, results){
			if(err){
				callback(err, null);
				return;
			}
			tempThis.queue.push({internalCallback: tempThis.processCPM, externalCallback: callback});
		});
	}
}

module.exports = GQGeiger;<commit_msg>Moved serial writing to function<commit_after>const SerialPort = require("serialport");

class GQGeiger {
	constructor(port, baud){
		this.geigerPort = new SerialPort(port, {baudrate: baud});
		this.queue = [];
		const tempThis = this;
		this.geigerPort.on('data', function(data) {
			const cD = tempThis.queue.shift();
			cD.internalCallback(data, cD.externalCallback);
		});
	}
	
	reqData(command, processFunc, callback){
		const tempThis = this;
		this.geigerPort.write(new Buffer(command, 'ascii'), function(err, results){
			if(err){
				callback(err, null);
				return;
			}
			tempThis.queue.push({internalCallback: processFunc, externalCallback: callback});
		});
	}
	
	processCPM(buffer, callback) {
		const cpm = buffer.readUInt16BE(0);
		callback(null, cpm);
	}
	getCPM(callback){
		this.reqData("<GETCPM>>", this.processCPM, callback);
	}
	
	processSPH(buffer, callback){
		const sph = (buffer.readUInt16BE(0)/200)*0.000001;
		callback(null, sph);
	}
	getSPH(callback){
		this.reqData("<GETCPM>>", this.processSPH, callback);
	}
}

module.exports = GQGeiger;
{'fraction_non_alphanumeric': 0.15606307775965197, 'fraction_numerical': 0.010331702011963024, 'mean_word_length': 4.768025078369906, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 9, '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': '1125792', 'n_tokens_mistral': 720, 'n_tokens_neox': 640, 'n_words': 118}