<commit_before>'use strict';

var SlowBuffer = require('buffer').SlowBuffer;
var Buffer = require('buffer').Buffer;

// requires node 3.1
var events = require('events');
var util = require('util');

var buffertools = {};

var unaryAction = function(f) {
  return function() {
    var target = this;
    if (target instanceof Buffer) {} else if (arguments[0] instanceof Buffer) {
      target = arguments[0];
      Array.prototype.shift.apply(arguments);
    } else {
      throw new Error('Argument should be a buffer object.');
    }
    return f.apply(target, arguments);
  };
};

var binaryAction = function(f) {
  return function() {
    var target = this;

    // first argument
    if (target instanceof Buffer) {} else if (arguments[0] instanceof Buffer) {
      target = arguments[0];
      Array.prototype.shift.apply(arguments);
    } else {
      throw Error('Argument should be a buffer object.');
    }

    // second argument
    var next = arguments[0];
    if (typeof next == 'string' || next instanceof String || next instanceof Buffer) {
      return f.apply(target, arguments);
    }
    throw new Error('Second argument must be a string or a buffer.');
  };
};

buffertools.clear = unaryAction(function() {
  for (var i = 0; i < this.length; i++) {
    this[i] = 0;
  }
  return this;
});

buffertools.equals = binaryAction(function(data) {
  return buffertools.compare(this, data) === 0;
});

buffertools.compare = binaryAction(function(data) {
  var buffer = this;<commit_msg>fill working<commit_after>'use strict';

var SlowBuffer = require('buffer').SlowBuffer;
var Buffer = require('buffer').Buffer;

// requires node 3.1
var events = require('events');
var util = require('util');

var buffertools = {};

var unaryAction = function(f) {
  return function() {
    var target = this;
    if (target instanceof Buffer) {} else if (arguments[0] instanceof Buffer) {
      target = arguments[0];
      Array.prototype.shift.apply(arguments);
    } else {
      throw new Error('Argument should be a buffer object.');
    }
    return f.apply(target, arguments);
  };
};

var binaryAction = function(f) {
  return function() {
    var target = this;

    // first argument
    if (target instanceof Buffer) {} else if (arguments[0] instanceof Buffer) {
      target = arguments[0];
      Array.prototype.shift.apply(arguments);
    } else {
      throw Error('Argument should be a buffer object.');
    }

    // second argument
    var next = arguments[0];
    if (typeof next == 'string' || next instanceof String || next instanceof Buffer) {
      return f.apply(target, arguments);
    }
    throw new Error('Second argument must be a string or a buffer.');
  };
};

buffertools.clear = unaryAction(function() {
  for (var i = 0; i < this.length; i++) {
    this[i] = 0;
  }
  return this;
});

buffertools.fill = unaryAction(function(data) {
  var step = typeof data.length === 'undefined'? 1:data.length;
  for (var i = 0; i < this.length; i+=step) {
    for (var k = 0; k<step; k++) {
      this[i+k] = typeof data.length === 'undefined'? data: 
        (typeof data[k] === 'string'?data[k].charCodeAt(0):data[k]);
    }
  }
  return this;
});

buffertools.equals = binaryAction(function(data) {
  return buffertools.compare(this, data) === 0;
});

buffertools.compare = binaryAction(function(data) {
  var buffer = this;
{'fraction_non_alphanumeric': 0.1454599761051374, 'fraction_numerical': 0.007168458781362007, 'mean_word_length': 3.3046272493573263, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7435872', 'n_tokens_mistral': 1012, 'n_tokens_neox': 1006, 'n_words': 299}