<commit_before>.pragma library
'use strict';

var createMessageType = (function() {
  // Use "true" async callback using thread pool.
  var async = true;

  var MessageBase = (function() {
    var constructor = function(descriptor) {
      this._descriptor = descriptor;

      this.serialize = function(cb) {
        if (async || typeof cb == 'undefined') {
          return descriptor.v4().serialize(this._raw, cb);
        } else {
          try {
            cb(null, descriptor.v4().serialize(this._raw));
          } catch (err) {
            cb(err);
          }
        }
      };

      this.serializeTo = function(output, cb) {
        try {
          output.serialize(this.type, this, cb);
        } catch (err) {
          console.log('Serialize Error !');
          console.error(err);
          console.error(err.stack);
          cb && cb(err);
        }
      };

      this.toString = function() {
        return String(this._raw);
      }
    };
    Object.defineProperties(constructor, {
      FIELD: {value: 0},
      ONEOF: {value: 1},
    });
    return constructor;
  })();

  var createMessageType = function(type, descriptor) {
    type.prototype = new MessageBase(descriptor);
    type.prototype.type = type;

    type.descriptor = descriptor;

    type.parse = function(buffer, cb) {
      if (typeof cb == 'undefined') {
        return new type(descriptor.v4().parse(buffer));
      } else if (async) {
        return descriptor.v4().parse(buffer, function(err, raw) {
          cb(err, new type(raw));
        });
      } else {
        try {
          cb(null, new type(descriptor.v4().parse(buffer)));
        } catch (err) {
          cb(err);
        }
      }
    };

    type.parseFrom = function(input, cb) {
      try {
        input.parse(type, function(err, data) {
          if (err) {
            cb(err);
          } else {
            cb(null, data);
          }
        });
      } catch (err) {
        console.log('Parse Error !');
        console.error(err);
        console.error(err.stack);
        cb && cb(err);
      }
    };
  };

  return createMessageType;
})();<commit_msg>Cleanup message.js<commit_after>.pragma library
'use strict';

var createMessageType = (function() {
  // Use "true" async callback using thread pool.
  var async = true;

  var MessageBase = (function() {
    var Base = function(descriptor) {
      this._descriptor = descriptor;
    };

    Base.prototype.serialize = function(cb) {
      if (async || typeof cb == 'undefined') {
        return this._descriptor.v4().serialize(this._raw, cb);
      } else {
        try {
          cb(null, this._descriptor.v4().serialize(this._raw));
        } catch (err) {
          cb(err);
        }
      }
    };

    Base.prototype.serializeTo = function(output, cb) {
      try {
        output.serialize(this.constructor, this, cb);
      } catch (err) {
        console.log('Serialize Error !');
        console.error(err);
        console.error(err.stack);
        cb && cb(err);
      }
    };

    Base.prototype.toString = function() {
      return String(this._raw);
    };

    Object.defineProperties(Base, {
      FIELD: {value: 0},
      ONEOF: {value: 1},
    });
    return Base;
  })();

  var createMessageType = function(Message, descriptor) {
    Message.prototype = new MessageBase(descriptor);
    Message.prototype.constructor = Message;

    Message.descriptor = descriptor;

    Message.parse = function(buffer, cb) {
      if (typeof cb == 'undefined') {
        return new Message(descriptor.v4().parse(buffer));
      } else if (async) {
        return descriptor.v4().parse(buffer, function(err, raw) {
          cb(err, new Message(raw));
        });
      } else {
        try {
          cb(null, new Message(descriptor.v4().parse(buffer)));
        } catch (err) {
          cb(err);
        }
      }
    };

    Message.parseFrom = function(input, cb) {
      try {
        input.parse(Message, function(err, data) {
          if (err) {
            cb(err);
          } else {
            cb(null, data);
          }
        });
      } catch (err) {
        console.log('Parse Error !');
        console.error(err);
        console.error(err.stack);
        cb && cb(err);
      }
    };
  };

  return createMessageType;
})();
{'fraction_non_alphanumeric': 0.14632438739789966, 'fraction_numerical': 0.003267211201866978, 'mean_word_length': 1.8784419073203493, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4309215', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1242, 'n_words': 265}