<commit_before>/*eslint
  camelcase:0
  curly:0,
  eqeqeq:0,
  no-proto:0,
  no-redeclare:0,
  no-return-assign:0,
  no-unused-expressions:0,
  no-unused-vars:0
  */
/*jshint ignore:start */
/*eslint-disable */
global.DEFINE_MODULE('buffer', (function () {
  'use strict'
  /*eslint-enable */

  const exports = {};

  var SlowBuffer = require('internal').SlowBuffer;

  // Copyright Joyent, Inc. and other Node contributors.
  //
  // Permission is hereby granted, free of charge, to any person obtaining a
  // copy of this software and associated documentation files (the
  // "Software"), to deal in the Software without restriction, including
  // without limitation the rights to use, copy, modify, merge, publish,
  // distribute, sublicense, and/or sell copies of the Software, and to permit
  // persons to whom the Software is furnished to do so, subject to the
  // following conditions:
  //
  // The above copyright notice and this permission notice shall be included
  // in all copies or substantial portions of the Software.
  //
  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  // USE OR OTHER DEALINGS IN THE SOFTWARE.

  exports.INSPECT_MAX_BYTES = 50;

  // Make SlowBuffer inherit from Buffer.
  // This is an exception to the rule that __proto__ is not allowed in core.
  SlowBuffer.prototype.__proto__ = Buffer.prototype;

  function clamp (index, len, defaultValue) {
    if (typeof index !== 'number') return defaultValue;
    index = ~~index; // Coerce to integer.
    if (index >= len) return len;
    if (index >= 0) return index;
    index += len;
    if (index >= 0) return index;
    return 0;
  }

  function toHex (n) {
    if (n < 16) return '0' + n.toString(16);
    return n.toString(16);
  }

  SlowBuffer.prototype.toString = function (encoding, start, end) {
    encoding = String(encoding || 'utf8').toLowerCase();
    start = +start || 0;
    if (typeof end !== 'number') end = this.length;

    // Fastpath empty strings
    if (+end == start) {
      return '';
    }

    switch (encoding) {
      case 'hex':
        return this.hexSlice(start, end);

      case 'utf8':
      case 'utf-8':
        return this.utf8Slice(start, end);

      case 'ascii':
        return this.asciiSlice(start, end);

      case 'binary':
        return this.binarySlice(start, end);

      case 'base64':
        return this.base64Slice(start, end);

      case 'ucs2':
      case 'ucs-2':
      case 'utf16le':
      case 'utf-16le':
        return this.ucs2Slice(start, end);

      default:
        throw new TypeError('Unknown encoding: ' + encoding);
    }
  };

  SlowBuffer.prototype.write = function (string, offset, length, encoding) {
    // Support both (string, offset, length, encoding)
    // and the legacy (string, encoding, offset, length)
    if (isFinite(offset)) {
      if (!isFinite(length)) {
        encoding = length;
        length = undefined;
      }
    } else { // legacy
      var swap = encoding;
      encoding = offset;
      offset = length;
      length = swap;
    }

    offset = +offset || 0;
    var remaining = this.length - offset;
    if (!length) {
      length = remaining;
    } else {
      length = +length;
      if (length > remaining) {
        length = remaining;
      }
    }
    encoding = String(encoding || 'utf8').toLowerCase();

    switch (encoding) {
      case 'hex':
        return this.hexWrite(string, offset, length);

      case 'utf8':
      case 'utf-8':
        return this.utf8Write(string, offset, length);

      case 'ascii':
        return this.asciiWrite(string, offset, length);

      case 'binary':
        return this.binaryWrite(string, offset, length);

      case 'base64':
        return this.base64Write(string, offset, length);

      case 'ucs2':
      case 'ucs-2':
      case 'utf16le':
      case 'utf-16le':
        return this.ucs2Write(string, offset, length);

      default:
        throw new TypeError('Unknown encoding: ' + encoding);
    }
  };

  // slice(start, end)
  SlowBuffer.prototype.slice = function (start, end) {
    var len = this.length;
    start = clamp(start, len, 0);
    end = clamp(end, len, len);
    return new Buffer(this, end - start, start);
  };

  // Buffer
  function Buffer (subject, encoding, offset) {
    var handler = {
      get: function(target, name) {
        if (name === '__buffer__') { return true; } 
        if (typeof name === 'string' && name.match(/^\d+$/)) {
          return target.parent[name]; 
        }
        return target[name];
      },
      set: function(target, name, value) { 
        if (typeof name === 'string' && name.match(/^\d+$/)) {
          target.parent[name] = value;
        } else {
          target[name] = value;
        }
      } 
    };
    if (!(this instanceof Buffer)) {
      var b = new Buffer(subject, encoding, offset);
      return new Proxy(b, handler);
    }

    var type;

    // Are we slicing?
    if (typeof offset === 'number') {
      if (!Buffer.isBuffer(subject)) {
        throw new TypeError('First argument must be a Buffer when slicing');
      }

      this.length = +encoding > 0 ? Math.ceil(encoding) : 0;
      this.parent = subject.parent ? subject.parent : subject;
      this.offset = offset;
    } else {
      // Find the length
      switch (type = typeof subject) {
        case 'number':<commit_msg>Setter must return true on success<commit_after>/*eslint
  camelcase:0
  curly:0,
  eqeqeq:0,
  no-proto:0,
  no-redeclare:0,
  no-return-assign:0,
  no-unused-expressions:0,
  no-unused-vars:0
  */
/*jshint ignore:start */
/*eslint-disable */
global.DEFINE_MODULE('buffer', (function () {
  'use strict'
  /*eslint-enable */

  const exports = {};

  var SlowBuffer = require('internal').SlowBuffer;

  // Copyright Joyent, Inc. and other Node contributors.
  //
  // Permission is hereby granted, free of charge, to any person obtaining a
  // copy of this software and associated documentation files (the
  // "Software"), to deal in the Software without restriction, including
  // without limitation the rights to use, copy, modify, merge, publish,
  // distribute, sublicense, and/or sell copies of the Software, and to permit
  // persons to whom the Software is furnished to do so, subject to the
  // following conditions:
  //
  // The above copyright notice and this permission notice shall be included
  // in all copies or substantial portions of the Software.
  //
  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  // USE OR OTHER DEALINGS IN THE SOFTWARE.

  exports.INSPECT_MAX_BYTES = 50;

  // Make SlowBuffer inherit from Buffer.
  // This is an exception to the rule that __proto__ is not allowed in core.
  SlowBuffer.prototype.__proto__ = Buffer.prototype;

  function clamp (index, len, defaultValue) {
    if (typeof index !== 'number') return defaultValue;
    index = ~~index; // Coerce to integer.
    if (index >= len) return len;
    if (index >= 0) return index;
    index += len;
    if (index >= 0) return index;
    return 0;
  }

  function toHex (n) {
    if (n < 16) return '0' + n.toString(16);
    return n.toString(16);
  }

  SlowBuffer.prototype.toString = function (encoding, start, end) {
    encoding = String(encoding || 'utf8').toLowerCase();
    start = +start || 0;
    if (typeof end !== 'number') end = this.length;

    // Fastpath empty strings
    if (+end == start) {
      return '';
    }

    switch (encoding) {
      case 'hex':
        return this.hexSlice(start, end);

      case 'utf8':
      case 'utf-8':
        return this.utf8Slice(start, end);

      case 'ascii':
        return this.asciiSlice(start, end);

      case 'binary':
        return this.binarySlice(start, end);

      case 'base64':
        return this.base64Slice(start, end);

      case 'ucs2':
      case 'ucs-2':
      case 'utf16le':
      case 'utf-16le':
        return this.ucs2Slice(start, end);

      default:
        throw new TypeError('Unknown encoding: ' + encoding);
    }
  };

  SlowBuffer.prototype.write = function (string, offset, length, encoding) {
    // Support both (string, offset, length, encoding)
    // and the legacy (string, encoding, offset, length)
    if (isFinite(offset)) {
      if (!isFinite(length)) {
        encoding = length;
        length = undefined;
      }
    } else { // legacy
      var swap = encoding;
      encoding = offset;
      offset = length;
      length = swap;
    }

    offset = +offset || 0;
    var remaining = this.length - offset;
    if (!length) {
      length = remaining;
    } else {
      length = +length;
      if (length > remaining) {
        length = remaining;
      }
    }
    encoding = String(encoding || 'utf8').toLowerCase();

    switch (encoding) {
      case 'hex':
        return this.hexWrite(string, offset, length);

      case 'utf8':
      case 'utf-8':
        return this.utf8Write(string, offset, length);

      case 'ascii':
        return this.asciiWrite(string, offset, length);

      case 'binary':
        return this.binaryWrite(string, offset, length);

      case 'base64':
        return this.base64Write(string, offset, length);

      case 'ucs2':
      case 'ucs-2':
      case 'utf16le':
      case 'utf-16le':
        return this.ucs2Write(string, offset, length);

      default:
        throw new TypeError('Unknown encoding: ' + encoding);
    }
  };

  // slice(start, end)
  SlowBuffer.prototype.slice = function (start, end) {
    var len = this.length;
    start = clamp(start, len, 0);
    end = clamp(end, len, len);
    return new Buffer(this, end - start, start);
  };

  // Buffer
  function Buffer (subject, encoding, offset) {
    var handler = {
      get: function(target, name) {
        if (name === '__buffer__') { return true; } 
        if (typeof name === 'string' && name.match(/^\d+$/)) {
          return target.parent[name]; 
        }
        return target[name];
      },
      set: function(target, name, value) { 
        if (typeof name === 'string' && name.match(/^\d+$/)) {
          target.parent[name] = value;
        } else {
          target[name] = value;
        }
        return true;
      } 
    };
    if (!(this instanceof Buffer)) {
      var b = new Buffer(subject, encoding, offset);
      return new Proxy(b, handler);
    }

    var type;

    // Are we slicing?
    if (typeof offset === 'number') {
      if (!Buffer.isBuffer(subject)) {
        throw new TypeError('First argument must be a Buffer when slicing');
      }

      this.length = +encoding > 0 ? Math.ceil(encoding) : 0;
      this.parent = subject.parent ? subject.parent : subject;
      this.offset = offset;
    } else {
      // Find the length
      switch (type = typeof subject) {
        case 'number':
{'fraction_non_alphanumeric': 0.12367644506162125, 'fraction_numerical': 0.009546953653879534, 'mean_word_length': 2.4233511586452763, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '1869095', 'n_tokens_mistral': 3494, 'n_tokens_neox': 3338, 'n_words': 1126}