<commit_before>/*
  Fake localStorage and sessionStorage.

  Separates each renderer's localStorage.

  Credit: https://github.com/pivotal/jasmine/issues/299
*/

var localStorageData = JSON.stringify(localStorage),
    sessionStorageData = JSON.stringify(sessionStorage);

var storeFactory = function(jsonData) {
  var store = {};
  if(jsonData) {
    store = JSON.parse(jsonData);
  }

  return {
    getItem: function(key) {
      return store[key];
    },
    setItem: function(key, value) {
      store[key] = value.toString();
    },
    clear: function() {
      store = {};
    },
    removeItem: function(key){
      store[key] = undefined;
    }
  };
};

Object.defineProperty(window, 'localStorage', { value: storeFactory(localStorageData) });
Object.defineProperty(window, 'sessionStorage', { value: storeFactory(sessionStorageData) });


/*
  Deterministic Math.random

  Credit: https://gist.github.com/mathiasbynens/5670917
*/

Math.random = (function() {
  var seed = 0x2F6E2B1;
  return function() {
    // <NAME>’ 32 bit integer hash function
    seed = ((seed + 0x7ED55D16) + (seed << 12))  & 0xFFFFFFFF;
    seed = ((seed ^ 0xC761C23C) ^ (seed >>> 19)) & 0xFFFFFFFF;
    seed = ((seed + 0x165667B1) + (seed << 5))   & 0xFFFFFFFF;
    seed = ((seed + 0xD3A2646C) ^ (seed << 9))   & 0xFFFFFFFF;
    seed = ((seed + 0xFD7046C5) + (seed << 3))   & 0xFFFFFFFF;
    seed = ((seed ^ 0xB55A4F09) ^ (seed >>> 16)) & 0xFFFFFFFF;
    return (seed & 0xFFFFFFF) / 0x10000000;
  };
}());


/*
  Mock requestAnimationFrame so that the callbacks can get fired even when the page
  is rendered inside an iframe in the background page
*/

window.requestAnimationFrame = window.webkitRequestAnimationFrame = function(callback){
  setTimeout(callback, 0);
};<commit_msg>localStorage and sessionStorage in seessMock now acts more like normal localStorage<commit_after>/*
  Fake localStorage and sessionStorage.

  Separates each renderer's localStorage.

  Credit: https://github.com/pivotal/jasmine/issues/299
*/

var localStorageData = JSON.stringify(localStorage),
    sessionStorageData = JSON.stringify(sessionStorage);

var storeFactory = function(jsonData) {
  var store;

  if(jsonData){
    store = JSON.parse(jsonData);
  }else{
    store = {};
  }

  store.getItem = function(key) {
    return this[key];
  };
  store.setItem = function(key, value) {
    this[key] = value.toString();
  };
  store.clear = function() {
    var key;
    for(key in this){
      if(this.hasOwnProperty(key) && key !== 'setItem' && key !== 'getItem' &&
         key !== 'clear' && key !== 'removeItem'){
        this[key] = undefined;
      }
    }
  };
  store.removeItem = function(key){
    this[key] = undefined;
  };

  return store;
};

Object.defineProperty(window, 'localStorage', { value: storeFactory(localStorageData) });
Object.defineProperty(window, 'sessionStorage', { value: storeFactory(sessionStorageData) });


/*
  Deterministic Math.random

  Credit: https://gist.github.com/mathiasbynens/5670917
*/

Math.random = (function() {
  var seed = 0x2F6E2B1;
  return function() {
    // <NAME>’ 32 bit integer hash function
    seed = ((seed + 0x7ED55D16) + (seed << 12))  & 0xFFFFFFFF;
    seed = ((seed ^ 0xC761C23C) ^ (seed >>> 19)) & 0xFFFFFFFF;
    seed = ((seed + 0x165667B1) + (seed << 5))   & 0xFFFFFFFF;
    seed = ((seed + 0xD3A2646C) ^ (seed << 9))   & 0xFFFFFFFF;
    seed = ((seed + 0xFD7046C5) + (seed << 3))   & 0xFFFFFFFF;
    seed = ((seed ^ 0xB55A4F09) ^ (seed >>> 16)) & 0xFFFFFFFF;
    return (seed & 0xFFFFFFF) / 0x10000000;
  };
}());


/*
  Mock requestAnimationFrame so that the callbacks can get fired even when the page
  is rendered inside an iframe in the background page
*/

window.requestAnimationFrame = window.webkitRequestAnimationFrame = function(callback){
  setTimeout(callback, 0);
};
{'fraction_non_alphanumeric': 0.14640522875816994, 'fraction_numerical': 0.042352941176470586, 'mean_word_length': 3.5601907032181166, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 16, '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': '1179298', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1256, 'n_words': 294}