<commit_before>packet = {
}

packet.polyfill = function() {
	for (var i in packets) {
		var pkt = packets[i];
		packet[pkt.shortname] = function(pkt) {
			return function(p) {
				if (typeof p != 'object') {
					p = {};
				}
				p.type = pkt.shortname;
				return packet.fromParams(p);
			};
		}(pkt);
	}
}

packet.fromBytes = function(b) {
	var newPacket = {preamble:{}, payload:{}};

	// First parse the preamble
	var runningPlace = 0;
	for (var i=0; i<preambleFields.length; i++) {
		var f = preambleFields[i];
		newPacket.preamble[f.name] = f.type.parse(b, runningPlace);
		runningPlace += f.type.size;
	}

	// Now parse the packet-specific bytes
	var pParser = packets[newPacket.preamble.packetType];
	if (typeof pParser == 'undefined') {
		console.log("Unknown packet type "+newPacket.preamble.packetType);
	} else {
		newPacket.packetTypeName = pParser.name;
		newPacket.packetTypeShortName = pParser.shortname;
		for (var i=0; i<pParser.fields.length; i++) {
			var f = pParser.fields[i];
			newPacket.payload[f.name] = f.type.parse(b, runningPlace);
			runningPlace += f.type.size;
		}
	}

	//console.log(newPacket);
	return newPacket;
};

packet.fromParams = function(p) {
	if (typeof p.type == 'undefined') {
		console.log("Unknown packet type requested");
		return;
	}

	var pParser;
	for (var i in packets) {<commit_msg>Don't log unknown packets (firmware updates spam the logs!)<commit_after>packet = {
}

packet.polyfill = function() {
	for (var i in packets) {
		var pkt = packets[i];
		packet[pkt.shortname] = function(pkt) {
			return function(p) {
				if (typeof p != 'object') {
					p = {};
				}
				p.type = pkt.shortname;
				return packet.fromParams(p);
			};
		}(pkt);
	}
}

packet.fromBytes = function(b) {
	var newPacket = {preamble:{}, payload:{}};

	// First parse the preamble
	var runningPlace = 0;
	for (var i=0; i<preambleFields.length; i++) {
		var f = preambleFields[i];
		newPacket.preamble[f.name] = f.type.parse(b, runningPlace);
		runningPlace += f.type.size;
	}

	// Now parse the packet-specific bytes
	var pParser = packets[newPacket.preamble.packetType];
	if (typeof pParser == 'undefined') {
		//console.log("Unknown packet type "+newPacket.preamble.packetType);
	} else {
		newPacket.packetTypeName = pParser.name;
		newPacket.packetTypeShortName = pParser.shortname;
		for (var i=0; i<pParser.fields.length; i++) {
			var f = pParser.fields[i];
			newPacket.payload[f.name] = f.type.parse(b, runningPlace);
			runningPlace += f.type.size;
		}
	}

	//console.log(newPacket);
	return newPacket;
};

packet.fromParams = function(p) {
	if (typeof p.type == 'undefined') {
		console.log("Unknown packet type requested");
		return;
	}

	var pParser;
	for (var i in packets) {
{'fraction_non_alphanumeric': 0.15673289183222958, 'fraction_numerical': 0.002207505518763797, 'mean_word_length': 3.696027633851468, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3330815', 'n_tokens_mistral': 1065, 'n_tokens_neox': 979, 'n_words': 220}