<commit_before>/**
 * MyBrowserStorage
 * replicates the MyPersistentStorage API
 *
 * makes it easy to promote state
 * from _session_ to _local_ to _remotely stored_
 */
angular.module(PKG.name + '.services')

  .factory('myLocalStorage', function (MyBrowserStorage) {
    return new MyBrowserStorage('local');
  })

  .factory('mySessionStorage', function (MyBrowserStorage) {
    return new MyBrowserStorage('session');
  })

  .factory('MyBrowserStorage', function MyBrowserStorageFactory($q, $localStorage, $sessionStorage, myHelpers) {

    function MyBrowserStorage (type) {
      this.data = type==='local' ? $localStorage : $sessionStorage;
    }

    /**
     * set a value
     * @param {string} key, can have a path like "foo.bar.baz"
     * @param {mixed} value
     * @return {promise} resolved with the response from server
     */
    MyBrowserStorage.prototype.set = function (key, value) {
      return $q.when(myHelpers.deepSet(this.data, key, value));
    };

    /**
     * retrieve a value
     * @param {string} key
     * @return {promise} resolved with the value
     */
    MyBrowserStorage.prototype.get = function (key) {
      return $q.when(myHelpers.deepGet(this.data, key));
    };

    return MyBrowserStorage;
  });<commit_msg>prefix localstorage keys with app name<commit_after>/**
 * MyBrowserStorage
 * replicates the MyPersistentStorage API
 *
 * makes it easy to promote state
 * from _session_ to _local_ to _remotely stored_
 */
angular.module(PKG.name + '.services')

  .factory('myLocalStorage', function (MyBrowserStorage) {
    return new MyBrowserStorage('local');
  })

  .factory('mySessionStorage', function (MyBrowserStorage) {
    return new MyBrowserStorage('session');
  })

  .factory('MyBrowserStorage', function MyBrowserStorageFactory($q, $localStorage, $sessionStorage, myHelpers) {

    function MyBrowserStorage (type) {
      this.type = type;
      this.data = type==='local' ? $localStorage : $sessionStorage;
    }

    /**
     * set a value
     * @param {string} key, can have a path like "foo.bar.baz"
     * @param {mixed} value
     * @return {promise} resolved with the response from server
     */
    MyBrowserStorage.prototype.set = function (key, value) {
      if(this.type === 'local') {
        key = <KEY> + key;
      }
      return $q.when(myHelpers.deepSet(this.data, key, value));
    };

    /**
     * retrieve a value
     * @param {string} key
     * @return {promise} resolved with the value
     */
    MyBrowserStorage.prototype.get = function (key) {
      if(this.type === 'local') {
        key = <KEY> + key;
      }
      return $q.when(myHelpers.deepGet(this.data, key));
    };

    return MyBrowserStorage;
  });
{'fraction_non_alphanumeric': 0.1302102545186278, 'fraction_numerical': 0.0, 'mean_word_length': 3.146788990825688, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5735115', 'n_tokens_mistral': 821, 'n_tokens_neox': 804, 'n_words': 211}