<commit_before>module.exports={
  'string': [readString, writeString, 64],
  'byte_array': [readByteArray, writeByteArray, 1024]
};

var tryCatch=require('protodef').utils.tryCatch;
var addErrorField=require('protodef').utils.addErrorField;


function readString(buffer, offset) {

  var value = buffer.toString('ascii', offset, offset + 64);
  value=value.trim();
  return {
    value: value,
    size: 64
  };
}

function writeString(value, buffer, offset) {
  for(var i=value.length-1;i<64;i++)
    value+=" ";
  buffer.write(value, offset, 64, 'ascii');
  return offset + 64;
}

function readByteArray(buffer, offset) {
  var results = {
    value: [],
    size: 1024
  };
  var count=1024;
  for(var i = 0; i < count; i++) {
    var readResults;
    tryCatch(() => {
      readResults = this.read(buffer, offset, "byte");
    }, (e) => {
      addErrorField(e, i);
      throw e;
    });
    results.size += readResults.size;
    offset += readResults.size;
    results.value.push(readResults.value);
  }
  return results;
}

function writeByteArray(value, buffer, offset, typeArgs, rootNode) {
    for(var index in value) {
    tryCatch(() => {
      offset = this.write(value[index], buffer, offset, typeArgs.type, rootNode);
    }, (e) => {
      addErrorField(e, index);
      throw e;
    });
  }
  return offset;
}<commit_msg>fix the byte_array writer<commit_after>module.exports={
  'string': [readString, writeString, 64],
  'byte_array': [readByteArray, writeByteArray, 1024]
};

var tryCatch=require('protodef').utils.tryCatch;
var addErrorField=require('protodef').utils.addErrorField;


function readString(buffer, offset) {

  var value = buffer.toString('ascii', offset, offset + 64);
  value=value.trim();
  return {
    value: value,
    size: 64
  };
}

function writeString(value, buffer, offset) {
  for(var i=value.length-1;i<64;i++)
    value+=" ";
  buffer.write(value, offset, 64, 'ascii');
  return offset + 64;
}

function readByteArray(buffer, offset) {
  var results = {
    value: [],
    size: 1024
  };
  var count=1024;
  for(var i = 0; i < count; i++) {
    var readResults;
    tryCatch(() => {
      readResults = this.read(buffer, offset, "byte");
    }, (e) => {
      addErrorField(e, i);
      throw e;
    });
    results.size += readResults.size;
    offset += readResults.size;
    results.value.push(readResults.value);
  }
  return results;
}

function writeByteArray(value, buffer, offset) {
    for(var index in value) {
    tryCatch(() => {
      offset = this.write(value[index], buffer, offset, "byte");
    }, (e) => {
      addErrorField(e, index);
      throw e;
    });
  }
  return offset;
}
{'fraction_non_alphanumeric': 0.16232540581351454, 'fraction_numerical': 0.01963004907512269, 'mean_word_length': 3.4019933554817277, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '4708930', 'n_tokens_mistral': 953, 'n_tokens_neox': 899, 'n_words': 202}