<commit_before>/* global localStorage, _ */

/* jshint ignore: start */
import util.underscore as _;
/* jshint ignore: end */

exports = {
  // retrieve data from storage
  get: function (key, obj) {
    'use strict';

    var val = localStorage.getItem(key);

    if (obj !== false) {
      val = JSON.parse(val || '{}');
    }

    return val;
  },

  // save data to storage
  set: function (key, val) {
    'use strict';

    if (_.isObject(val)) {
      val = JSON.stringify(val);
    }

    localStorage.setItem(key, val);
  },

  // push value to an array saved in the storage
  push: function (key, val) {
    'use strict';

    var data = this.get(key);

    if (_.isEmpty(data)) {
      data = [];
    }
    data.push(val);

    this.set(key, data);
  },

  // add value to an object saved in the storage
  add: function (key, id, val) {
    'use strict';

    var data = this.get(key);

    data[key](val);

    this.set(key, data);
  },

  // delete data from the storage
  del: function (id) {
    'use strict';

    localStorage.removeItem(id);
  },

  // clean all data from the storage
  clear: function () {
    'use strict';

    localStorage.clear();
  }
};<commit_msg>identify datatype of stored data<commit_after>/* global localStorage, _ */

/* jshint ignore: start */
import util.underscore as _;
/* jshint ignore: end */

exports = {
  // retrieve data from storage
  get: function (key) {
    'use strict';

    var val = localStorage.getItem(key);

    try {
      val = JSON.parse(val);
    } catch (e) {
    }

    return val;
  },

  // save data to storage
  set: function (key, val) {
    'use strict';

    if (_.isObject(val)) {
      val = JSON.stringify(val);
    }

    localStorage.setItem(key, val);
  },

  // push value to an array saved in the storage
  push: function (key, val) {
    'use strict';

    var data = this.get(key);

    if (_.isEmpty(data)) {
      data = [];
    }
    data.push(val);

    this.set(key, data);
  },

  // add value to an object saved in the storage
  add: function (key, id, val) {
    'use strict';

    var data = this.get(key);

    if (_.isEmpty(data)) {
      data = {};
    }

    data[key](val);

    this.set(key, data);
  },

  // delete data from the storage
  del: function (id) {
    'use strict';

    localStorage.removeItem(id);
  },

  // clean all data from the storage
  clear: function () {
    'use strict';

    localStorage.clear();
  }
};
{'fraction_non_alphanumeric': 0.15147783251231528, 'fraction_numerical': 0.0, 'mean_word_length': 2.2580213903743314, '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': '4067912', 'n_tokens_mistral': 846, 'n_tokens_neox': 808, 'n_words': 240}