<commit_before>'use strict';
// Load modules
var Assert = require('assert');

// Declare internals
var internals = {
  store: []
};

internals.store.lookUp = function (obj, method) {
  var i = this.length;
  var lookup;
  while (i-- && !lookup) {
    var item = this[i];

    if (item.obj === obj && item.method === method) {
      lookup = item;
    }
  }
  return {
    result: lookup,
    index: i
  };
};

exports.replace = function (obj, method, fn) {
  Assert.ok(obj, 'obj must be defined');
  Assert.strictEqual(typeof obj, 'object', 'obj must be an object');
  Assert.strictEqual(typeof obj[method], 'function', 'method must be a valid function of obj');
  Assert.strictEqual(typeof fn, 'function', 'fn must be a function object');

  var stand = {
    obj: obj,
    method: method
  };
  var find = internals.store.lookUp(obj, method);
  Assert.equal(find.result, undefined, 'there is already a replace for "obj"[' + method + ']');
  internals.store.push(stand);

  var result = {
    original: obj[method].bind(obj),
    restore: function () {
      var find = internals.store.lookUp(this._stand.obj, this._stand.method);
      internals.store.splice(find.index, 1);
    },
    _stand: stand<commit_msg>PR updates 1.<commit_after>'use strict';
// Load modules
var Assert = require('assert');

// Declare internals
var internals = {
  store: []
};

internals.store.lookUp = function (obj, method) {
  var i = this.length;
  var lookup;
  while (i-- && !lookup) {
    var item = this[i];

    if (item.obj === obj && item.method === method) {
      lookup = item;
    }
  }
  return {
    result: lookup,
    index: i
  };
};

exports.replace = function (obj, method, fn) {
  Assert.ok(obj, 'obj must be defined');
  Assert.strictEqual(typeof obj, 'object', 'obj must be an object');
  Assert.strictEqual(typeof obj[method], 'function', 'method must be a valid function of obj');
  Assert.strictEqual(typeof fn, 'function', 'fn must be a function object');

  var stand = {
    obj: obj,
    method: method
  };
  var find = internals.store.lookUp(obj, method);
  Assert.strictEqual(find.result, undefined, 'there is already a replace for "obj"[' + method + ']');
  internals.store.push(stand);

  var result = {
    original: obj[method].bind(obj),
    restore: function () {
      var find = internals.store.lookUp(this._stand.obj, this._stand.method);
      internals.store.splice(find.index, 1);
    },
    _stand: stand
{'fraction_non_alphanumeric': 0.15419407894736842, 'fraction_numerical': 0.0012335526315789473, 'mean_word_length': 3.268421052631579, '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': '3770557', 'n_tokens_mistral': 793, 'n_tokens_neox': 783, 'n_words': 225}