<commit_before>/* global chrome, confirm */

var utils = require('./utils');

function Storage (updateFiles) {
  var EDITOR_SIZE_CACHE_KEY = 'editor-size-cache';

  this.rename = function (originalName, newName) {
    var content = this.get(originalName);
    this.set(newName, content);
    this.remove(originalName);
  };

  this.remove = function (name) {
    window.localStorage.removeItem(name);
  };

  this.setEditorSize = function (size) {
    this.set(EDITOR_SIZE_CACHE_KEY, size);
  };

  this.getEditorSize = function () {
    return this.get(EDITOR_SIZE_CACHE_KEY);
  };

  this.getFileContent = function (key) {
    return this.get(utils.fileKey(key));
  };

  this.exists = function (key) {
    return !!this.get(key);
  };

  this.set = function (key, content) {
    window.localStorage.setItem(key, content);
  };

  this.get = function (key) {
    return window.localStorage.getItem(key);
  };

  this.keys = function () {
    return Object.keys(window.localStorage);
  };

  this.loadFile = function (filename, content) {
    if (this.exists(filename) && this.get(filename) !== content) {
      var count = '';
      while (this.exists(filename + count)) count = count - 1;<commit_msg>Fix storage issues on some browsers<commit_after>/* global chrome, confirm */

var utils = require('./utils');

function Storage (updateFiles) {
  var EDITOR_SIZE_CACHE_KEY = 'editor-size-cache';

  this.rename = function (originalName, newName) {
    var content = this.get(originalName);
    this.set(newName, content);
    this.remove(originalName);
  };

  this.remove = function (name) {
    window.localStorage.removeItem(name);
  };

  this.setEditorSize = function (size) {
    this.set(EDITOR_SIZE_CACHE_KEY, size);
  };

  this.getEditorSize = function () {
    return this.get(EDITOR_SIZE_CACHE_KEY);
  };

  this.getFileContent = function (key) {
    return this.get(utils.fileKey(key));
  };

  this.exists = function (key) {
    return !!this.get(key);
  };

  this.set = function (key, content) {
    window.localStorage.setItem(key, content);
  };

  this.get = function (key) {
    return window.localStorage.getItem(key);
  };

  this.keys = function () {
    // NOTE: this is a workaround for some browsers
    return Object.keys(window.localStorage).filter(function (item) { return item !== null && item !== undefined; });
  };

  this.loadFile = function (filename, content) {
    if (this.exists(filename) && this.get(filename) !== content) {
      var count = '';
      while (this.exists(filename + count)) count = count - 1;
{'fraction_non_alphanumeric': 0.14851097178683387, 'fraction_numerical': 0.0007836990595611285, 'mean_word_length': 3.4868189806678385, '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': '1311564', 'n_tokens_mistral': 828, 'n_tokens_neox': 805, 'n_words': 172}