<commit_before>var _BN = require('bn.js');

var BN = function BN(n, base) {
  if (!(this instanceof BN)) {
    return new BN(n, base);
  }
  _BN.apply(this, arguments);
};

BN.prototype = _BN.prototype;

var reversebuf = function(buf) {
  var buf2 = new Buffer(buf.length);
  for (var i = 0; i < buf.length; i++) {
    buf2[i] = buf[buf.length-1-i];
  }
  return buf2;
};

BN.prototype.toJSON = function() {
  return this.toString();
};

BN.prototype.fromJSON = function(str) {
  var bn = BN(str);
  bn.copy(this);
  return this;
};

BN.prototype.fromNumber = function(n) {
  var bn = BN(n);
  bn.copy(this);
  return this;
};

BN.prototype.toNumber = function() {
  return parseInt(this['toString'](10), 10);
};

BN.prototype.fromString = function(str) {
  var bn = BN(str);
  bn.copy(this);
  return this;
};

BN.fromBuffer = function(buf, opts) {
  if (typeof opts !== 'undefined' && opts.endian === 'little') {
    buf = reversebuf(buf);
  }
  var hex = buf.toString('hex');
  var bn = new BN(hex, 16);
  return bn;
};

BN.prototype.fromBuffer = function(buf, opts) {
  var bn = BN.fromBuffer(buf, opts);
  bn.copy(this);

  return this;
};

BN.prototype.toBuffer = function(opts) {
  var buf;
  if (opts && opts.size) {
    var hex = this.toString(16, 2);
    var natlen = hex.length/2;
    buf = new Buffer(hex, 'hex');

    if (natlen == opts.size)
      buf = buf;

    else if (natlen > opts.size) {
      buf = buf.slice(natlen - buf.length, buf.length);
    }

    else if (natlen < opts.size) {
      var rbuf = new Buffer(opts.size);
      for (var i = 0; i < buf.length; i++)
        rbuf[rbuf.length-1-i] = buf[buf.length-1-i];
      for (var i = 0; i < opts.size - natlen; i++)
        rbuf[i] = 0;
      buf = rbuf;
    }
  }
  else {
    var hex = this.toString(16, 2);
    buf = new Buffer(hex, 'hex');
  }

  if (typeof opts !== 'undefined' && opts.endian === 'little') {
    buf = reversebuf(buf);
  }

  return buf;
};

// signed magnitude buffer
// most significant bit represents sign (0 = positive, -1 = negative)
BN.prototype.fromSM = function(buf, opts) {
  if (buf.length === 0)
    this.fromBuffer(new Buffer([0]));

  var endian = 'big';
  if (opts)
    endian = opts.endian;

  if (endian == 'little')
    buf = reversebuf(buf);

  if (buf[0] & 0x80) {
    buf[0] = buf[0] & 0x7f;
    this.fromBuffer(buf);
    this.neg().copy(this);
  } else {
    this.fromBuffer(buf);
  }
  return this;
};

BN.prototype.toSM = function(opts) {
  var endian = 'big';
  if (opts)
    endian = opts.endian;

  if (this.cmp(0) == -1) {
    var buf = this.neg().toBuffer();
    if (buf[0] & 0x80)
      buf = Buffer.concat([new Buffer([0x80]), buf]);
    else
      buf[0] = buf[0] | 0x80;
  } else {
    var buf = this.toBuffer();
    if (buf[0] & 0x80)
      buf = Buffer.concat([new Buffer([0x00]), buf]);
  }

  if (buf.length === 1 & buf[0] === 0)
    return new Buffer([]);
<commit_msg>cosmetic<commit_after>var _BN = require('bn.js');

var BN = function BN(n, base) {
  if (!(this instanceof BN)) {
    return new BN(n, base);
  }
  _BN.apply(this, arguments);
};

BN.prototype = _BN.prototype;

var reversebuf = function(buf) {
  var buf2 = new Buffer(buf.length);
  for (var i = 0; i < buf.length; i++) {
    buf2[i] = buf[buf.length-1-i];
  }
  return buf2;
};

BN.prototype.toJSON = function() {
  return this.toString();
};

BN.prototype.fromJSON = function(str) {
  var bn = BN(str);
  bn.copy(this);
  return this;
};

BN.prototype.fromNumber = function(n) {
  var bn = BN(n);
  bn.copy(this);
  return this;
};

BN.prototype.toNumber = function() {
  return parseInt(this['toString'](10), 10);
};

BN.prototype.fromString = function(str) {
  var bn = BN(str);
  bn.copy(this);
  return this;
};

BN.fromBuffer = function(buf, opts) {
  if (typeof opts !== 'undefined' && opts.endian === 'little') {
    buf = reversebuf(buf);
  }
  var hex = buf.toString('hex');
  var bn = new BN(hex, 16);
  return bn;
};

BN.prototype.fromBuffer = function(buf, opts) {
  var bn = BN.fromBuffer(buf, opts);
  bn.copy(this);

  return this;
};

BN.prototype.toBuffer = function(opts) {
  var buf;
  if (opts && opts.size) {
    var hex = this.toString(16, 2);
    var natlen = hex.length/2;
    buf = new Buffer(hex, 'hex');

    if (natlen == opts.size)
      buf = buf;

    else if (natlen > opts.size) {
      buf = buf.slice(natlen - buf.length, buf.length);
    }

    else if (natlen < opts.size) {
      var rbuf = new Buffer(opts.size);
      for (var i = 0; i < buf.length; i++)
        rbuf[rbuf.length-1-i] = buf[buf.length-1-i];
      for (var i = 0; i < opts.size - natlen; i++)
        rbuf[i] = 0;
      buf = rbuf;
    }
  }
  else {
    var hex = this.toString(16, 2);
    buf = new Buffer(hex, 'hex');
  }

  if (typeof opts !== 'undefined' && opts.endian === 'little') {
    buf = reversebuf(buf);
  }

  return buf;
};

// signed magnitude buffer
// most significant bit represents sign (0 = positive, -1 = negative)
BN.prototype.fromSM = function(buf, opts) {
  if (buf.length === 0)
    this.fromBuffer(new Buffer([0]));

  var endian = 'big';
  if (opts)
    endian = opts.endian;

  if (endian == 'little')
    buf = reversebuf(buf);

  if (buf[0] & 0x80) {
    buf[0] = buf[0] & 0x7f;
    this.fromBuffer(buf);
    this.neg().copy(this);
  } else {
    this.fromBuffer(buf);
  }
  return this;
};

BN.prototype.toSM = function(opts) {
  var endian = 'big';
  if (opts)
    endian = opts.endian;

  var buf;
  if (this.cmp(0) == -1) {
    buf = this.neg().toBuffer();
    if (buf[0] & 0x80)
      buf = Buffer.concat([new Buffer([0x80]), buf]);
    else
      buf[0] = buf[0] | 0x80;
  } else {
    buf = this.toBuffer();
    if (buf[0] & 0x80)
      buf = Buffer.concat([new Buffer([0x00]), buf]);
  }

  if (buf.length === 1 & buf[0] === 0)
    buf = new Buffer([]);

{'fraction_non_alphanumeric': 0.18426037540898915, 'fraction_numerical': 0.020320303082486654, 'mean_word_length': 2.723076923076923, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '4167017', 'n_tokens_mistral': 2324, 'n_tokens_neox': 2218, 'n_words': 540}