<commit_before>var NUMBERS = ['int32', 'int64', 'uint32', 'uint64', 'sint32', 'sint64', 'bool', 'enum', 'float', 'double'];
var varint = require('varint');

var encodeDouble = function(num) {
	var buf = new Buffer(8);
	buf.writeDoubleBE(num, 0);
	return buf;
};

var encodeBoolean = function(val) {
	return new Buffer(varint.encode(val ? 1 : 0));
};

var encodeField = function(field, type) {
	return new Buffer(varint.encode(field << 3 | type));
};

var encodeVarint = function(num) {
	return new Buffer(varint.encode(num));
};

var push = function(pool, val) {
	pool.push(val);
	return val.length;
};

var compile = function(main, messages) {
	var subtype = function(main) {
		return Object.keys(main.fields)
			.map(function(key) {
				var field = main.fields[key];
				var tag = parseInt(main.fields[key].tag, 10);

				var ondouble = function(obj, pool) {
					return push(pool, encodeField(tag, 5)) + push(pool, encodeDouble(obj[key]));
				};

				var onboolean = function(obj, pool) {
					return push(pool, encodeBoolean(obj[key]));
				};

				var onvarint = function(obj, pool) {
					return push(pool, encodeField(tag, 0)) + push(pool, obj[key]);
				};

				var onbytes = function(obj, pool) {
					var val = obj[key];
					return push(pool, encodeField(tag, 2)) + push(pool, encodeVarint(val.length)) + push(pool, val);
				};

				var onstring = function(obj, pool) {
					var val = new Buffer(obj[key]);
					return push(pool, encodeField(tag, 2)) + push(pool, encodeVarint(val.length)) + push(pool, val);
				};

				var onsubtype = function(type) {
					var enc = subtype(type);

					return function(obj, pool) {
						var offset = push(pool, encodeField(tag, 2));
						var i = pool.push(null)-1;
						var len = enc(obj, pool);
						pool[i] = encodeVarint(len);
						return offset + pool[i].length + len;
					};

				};

				switch (field.type) {
					case 'int32':
					case 'int64':
					case 'uint32':
					case 'uint64':
					case 'sint32':
					case 'sint64':<commit_msg>fix nesting issue<commit_after>var NUMBERS = ['int32', 'int64', 'uint32', 'uint64', 'sint32', 'sint64', 'bool', 'enum', 'float', 'double'];
var varint = require('varint');

var encodeDouble = function(num) {
	var buf = new Buffer(8);
	buf.writeDoubleBE(num, 0);
	return buf;
};

var encodeBoolean = function(val) {
	return new Buffer(varint.encode(val ? 1 : 0));
};

var encodeField = function(field, type) {
	return new Buffer(varint.encode(field << 3 | type));
};

var encodeVarint = function(num) {
	return new Buffer(varint.encode(num));
};

var push = function(pool, val) {
	pool.push(val);
	return val.length;
};

var compile = function(main, messages) {
	var subtype = function(main) {
		return Object.keys(main.fields)
			.map(function(key) {
				var field = main.fields[key];
				var tag = parseInt(main.fields[key].tag, 10);

				var ondouble = function(obj, pool) {
					return push(pool, encodeField(tag, 5)) + push(pool, encodeDouble(obj[key]));
				};

				var onboolean = function(obj, pool) {
					return push(pool, encodeBoolean(obj[key]));
				};

				var onvarint = function(obj, pool) {
					return push(pool, encodeField(tag, 0)) + push(pool, obj[key]);
				};

				var onbytes = function(obj, pool) {
					var val = obj[key];
					return push(pool, encodeField(tag, 2)) + push(pool, encodeVarint(val.length)) + push(pool, val);
				};

				var onstring = function(obj, pool) {
					var val = new Buffer(obj[key]);
					return push(pool, encodeField(tag, 2)) + push(pool, encodeVarint(val.length)) + push(pool, val);
				};

				var onsubtype = function(type) {
					var enc = subtype(type);

					return function(obj, pool) {
						var offset = push(pool, encodeField(tag, 2));
						var i = pool.push(null)-1;
						var len = enc(obj[key], pool);
						pool[i] = encodeVarint(len);
						return offset + pool[i].length + len;
					};

				};

				switch (field.type) {
					case 'int32':
					case 'int64':
					case 'uint32':
					case 'uint64':
					case 'sint32':
					case 'sint64':
{'fraction_non_alphanumeric': 0.1656273384884011, 'fraction_numerical': 0.01845846844599651, 'mean_word_length': 3.4114411441144115, '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': '6733873', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1364, 'n_words': 345}