<commit_before>(function (w) {
  'use strict';

  /**
   * Constructor function for the blob reader.
   *
   * @public
   * @constructor
   * @param {Blob} blob The blob object, which should be read
   */
  function BlobReader(blob) {
    if (!(this instanceof BlobReader)) {
      return new BlobReader(blob);
    }
    this.blob = blob;
    this.position = 0;
    this.queue = [];
    this._pendingTask = false;
  }

  BlobReader.ARRAY_BUFFER = 'ArrayBuffer';
  BlobReader.BINARY_STRING = 'BinaryString';
  BlobReader.TEXT = 'Text';
  BlobReader.DATA_URL = 'DataURL';

  BlobReader.prototype._invokeNext = function () {
    var current = this.queue.shift();
    if (!current) {
      return;
    }
    if (this.position + current.count > this.blob.size) {
      throw new Error('Limit reached. Trying to read ' +
          (this.position + current.count) + ' bytes out of ' +
          this.blob.size + '.');
    }
    var reader = new FileReader();
    this._pendingTask = true;
    reader.onload = function (e) {
      var data = e.target.result;
      this._pendingTask = false;
      this._invokeNext();
      current.cb(data);
    }.bind(this);
    reader.onerror = function () {
      throw new Error('Error while reading the blob');
    };
    if (current.type) {
      reader['readAs' + current.type]();
    } else {
      reader.readAsBinaryString();
    }
    this.position += current.count;
  };

  /**
   * Read definite amount of bytes by the blob
   *
   * @public
   * @param {Number} count The count of bytes, which should be read
   * @param {Function} cb The callback, which should be
   *  invoked once the bytes are read
   * @return {BlobReader} Returns `this`
   */
  BlobReader.prototype.read = function (count, type, cb) {
    if (typeof count === 'function') {
      cb = count;
      type = undefined;
      count = this.blob.size;
    }
    if (typeof type === 'function') {
      cb = type;
      type = undefined;
    }
    this.queue.push({
      count: count,
      cb: cb,
      type: type
    });
    if (!this._pendingTask) {
      this._invokeNext();
    }
    return this;
  };

  /**
   * Read defined amount of bytes as text
   *
   * @public
   * @param {Number} count Number of bytes to be read
   * @param {Function} cb Calback to be invoked
   * @return {BlobReader} Return the target object instance
   */
  BlobReader.prototype.readText = function (count, cb) {
    return this.read(count, BlobReader.TEXT, cb);
  };

  /**
   * Read defined amount of bytes as array buffer
   *
   * @public
   * @param {Number} count Number of bytes to be read
   * @param {Function} cb Calback to be invoked
   * @return {BlobReader} Return the target object instance
   */
  BlobReader.prototype.readArrayBuffer = function (count, cb) {
    return this.read(count, BlobReader.ARRAY_BUFFER, cb);
  };

  /**
   * Read defined amount of bytes as binary string
   *
   * @public
   * @param {Number} count Number of bytes to be read
   * @param {Function} cb Calback to be invoked
   * @return {BlobReader} Return the target object instance
   */
  BlobReader.prototype.readBinaryString = function (count, cb) {
    return this.read(count, BlobReader.BINARY_STRING, cb);
  };

  /**
   * Read defined amount of bytes as data url
   *
   * @public
   * @param {Number} count Number of bytes to be read
   * @param {Function} cb Calback to be invoked
   * @return {BlobReader} Return the target object instance
   */
  BlobReader.prototype.readDataURL = function (count, cb) {
    return this.read(count, BlobReader.DATA_URL, cb);
  };

  /**
   * Read defined amount of bytes as text
   *
   * @private
   * @param {Number} count Number of bytes to be read
   * @param {Function} cb Calback to be invoked
   * @param {Function} type Constructor function which indicates
   *  the type which should be used as wrapper of the returned data
   * @return {BlobReader} Return the target object instance
   */
  BlobReader.prototype._readWrapped = function (count, cb, type) {
    var callback = function (data) {
      data = new type(data);
      cb(data);
    };
    return this.readArrayBuffer(count, callback);
  };<commit_msg>Update index.js<commit_after>(function (w) {
  'use strict';

  /**
   * Constructor function for the blob reader.
   *
   * @public
   * @constructor
   * @param {Blob} blob The blob object, which should be read
   */
  function BlobReader(blob) {
    if (!(this instanceof BlobReader)) {
      return new BlobReader(blob);
    }
    this.blob = blob;
    this.position = 0;
    this.queue = [];
    this._pendingTask = false;
  }

  BlobReader.ARRAY_BUFFER = 'ArrayBuffer';
  BlobReader.BINARY_STRING = 'BinaryString';
  BlobReader.TEXT = 'Text';
  BlobReader.DATA_URL = 'DataURL';

  BlobReader.prototype._invokeNext = function () {
    var current = this.queue.shift();
    if (!current) {
      return;
    }
    if (this.position + current.count > this.blob.size) {
      throw new Error('Limit reached. Trying to read ' +
          (this.position + current.count) + ' bytes out of ' +
          this.blob.size + '.');
    }
    var reader = new FileReader();
    this._pendingTask = true;
    reader.onload = function (e) {
      var data = e.target.result;
      this._pendingTask = false;
      current.cb(data);
      this._invokeNext();
    }.bind(this);
    reader.onerror = function () {
      throw new Error('Error while reading the blob');
    };
    if (!current.type) {
      current.type = BlobReader.BINARY_STRING;
    }
    reader['readAs' + current.type](
        this.blob.slice(this.position, this.position + current.count)
    );
    this.position += current.count;
  };

  /**
   * Read definite amount of bytes by the blob
   *
   * @public
   * @param {Number} count The count of bytes, which should be read
   * @param {Function} cb The callback, which should be
   *  invoked once the bytes are read
   * @return {BlobReader} Returns `this`
   */
  BlobReader.prototype.read = function (count, type, cb) {
    if (count === undefined) {
      count = this.blob.size;
    }
    if (typeof count === 'function') {
      cb = count;
      type = undefined;
      count = this.blob.size;
    }
    if (typeof type === 'function') {
      cb = type;
      type = undefined;
    }
    this.queue.push({
      count: count,
      cb: cb,
      type: type
    });
    if (!this._pendingTask) {
      this._invokeNext();
    }
    return this;
  };

  /**
   * Read defined amount of bytes as text
   *
   * @public
   * @param {Number} count Number of bytes to be read
   * @param {Function} cb Calback to be invoked
   * @return {BlobReader} Return the target object instance
   */
  BlobReader.prototype.readText = function (count, cb) {
    return this.read(count, BlobReader.TEXT, cb);
  };

  /**
   * Read defined amount of bytes as array buffer
   *
   * @public
   * @param {Number} count Number of bytes to be read
   * @param {Function} cb Calback to be invoked
   * @return {BlobReader} Return the target object instance
   */
  BlobReader.prototype.readArrayBuffer = function (count, cb) {
    return this.read(count, BlobReader.ARRAY_BUFFER, cb);
  };

  /**
   * Read defined amount of bytes as binary string
   *
   * @public
   * @param {Number} count Number of bytes to be read
   * @param {Function} cb Calback to be invoked
   * @return {BlobReader} Return the target object instance
   */
  BlobReader.prototype.readBinaryString = function (count, cb) {
    return this.read(count, BlobReader.BINARY_STRING, cb);
  };

  /**
   * Read defined amount of bytes as data url
   *
   * @public
   * @param {Number} count Number of bytes to be read
   * @param {Function} cb Calback to be invoked
   * @return {BlobReader} Return the target object instance
   */
  BlobReader.prototype.readDataURL = function (count, cb) {
    return this.read(count, BlobReader.DATA_URL, cb);
  };

  /**
   * Read defined amount of bytes as text
   *
   * @private
   * @param {Number} count Number of bytes to be read
   * @param {Function} cb Calback to be invoked
   * @param {Function} type Constructor function which indicates
   *  the type which should be used as wrapper of the returned data
   * @return {BlobReader} Return the target object instance
   */
  BlobReader.prototype._readWrapped = function (count, cb, type) {
    if (typeof count === 'function') {
      cb = count;
      count = undefined;
    }
    var callback = function (data) {
      data = new type(data);
      cb(data);
    };
    return this.readArrayBuffer(count, callback);
  };
{'fraction_non_alphanumeric': 0.11791569086651053, 'fraction_numerical': 0.000234192037470726, 'mean_word_length': 2.6298342541436464, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4572762', 'n_tokens_mistral': 2609, 'n_tokens_neox': 2564, 'n_words': 823}