node_modules/vuex-persist/dist/umd/index.js
/**
       * Create a {@link VuexPersistence} object.
       * Use the <code>plugin</code> function of this class as a
       * Vuex plugin.
       * @param {PersistOptions} options
       */
Create a  VuexPersistence object.
Use the plugin function of this class as a
Vuex plugin.
Create a VuexPersistence object . Use the plugin function of this class as a Vuex plugin .
function VuexPersistence(options) {
          var _this = this;
          this._mutex = new SimplePromiseQueue();
          this.subscriber = function (store) {
              return function (handler) { return store.subscribe(handler); };
          };
          if (typeof options === 'undefined')
              options = {};
          this.key = ((options.key != null) ? options.key : 'vuex');
          this.subscribed = false;
          this.supportCircular = options.supportCircular || false;
          if (this.supportCircular) {
              CircularJSON = require('circular-json');
          }
          {
              {
                  this.storage = options.storage || window.localStorage;
              }
          }
          this.reducer = ((options.reducer != null)
              ? options.reducer
              : ((options.modules == null)
                  ? (function (state) { return state; })
                  : (function (state) {
                      return options.modules.reduce(function (a, i) {
                          var _a;
                          return merge(a, (_a = {}, _a[i] = state[i], _a));
                      }, { });
                  })));
          this.filter = options.filter || (function (mutation) { return true; });
          this.strictMode = options.strictMode || false;
          this.RESTORE_MUTATION = function RESTORE_MUTATION(state, savedState) {
              var mergedState = merge(state, savedState || {});
              for (var _i = 0, _a = Object.keys(mergedState); _i < _a.length; _i++) {
                  var propertyName = _a[_i];
                  this._vm.$set(state, propertyName, mergedState[propertyName]);
              }
          };
          this.asyncStorage = options.asyncStorage || false;
          var storageConfig = this.storage && (this.storage)._config;
          this.asyncStorage = this.asyncStorage || (storageConfig && storageConfig.name) === 'localforage';
          if (this.asyncStorage) {
              this.restoreState = ((options.restoreState != null)
                  ? options.restoreState
                  : (function (key, storage) {
                      return (storage).getItem(key)
                          .then(function (value) {
                          return typeof value === 'string' 
                              ? (_this.supportCircular
                                  ? CircularJSON.parse(value || '{}')
                                  : JSON.parse(value || '{}'))
                              : (value || {});
                      });
                  }));
              this.saveState = ((options.saveState != null)
                  ? options.saveState
                  : (function (key, state, storage) {
                      return (storage).setItem(key, 
                      (((storage && storage._config && storage._config.name) === 'localforage')
                          ? merge({}, state || {})
                          : (_this.supportCircular
                              ? CircularJSON.stringify(state)
                              : JSON.stringify(state))));
                  }));
              this.plugin = function (store) {
                  (_this.restoreState(_this.key, _this.storage)).then(function (savedState) {
                      if (_this.strictMode) {
                          store.commit('RESTORE_MUTATION', savedState);
                      }
                      else {
                          store.replaceState(merge(store.state, savedState || {}));
                      }
                      _this.subscriber(store)(function (mutation, state) {
                          if (_this.filter(mutation)) {
                              _this._mutex.enqueue(_this.saveState(_this.key, _this.reducer(state), _this.storage));
                          }
                      });
                      _this.subscribed = true;
                  });
              };
          }
          else {
              this.restoreState = ((options.restoreState != null)
                  ? options.restoreState
                  : (function (key, storage) {
                      var value = (storage).getItem(key);
                      if (typeof value === 'string') { 
                          return (_this.supportCircular
                              ? CircularJSON.parse(value || '{}')
                              : JSON.parse(value || '{}'));
                      }
                      else {
                          return (value || {});
                      }
                  }));
              this.saveState = ((options.saveState != null)
                  ? options.saveState
                  : (function (key, state, storage) {
                      return (storage).setItem(key, 
                      (_this.supportCircular
                          ? CircularJSON.stringify(state)
                          : JSON.stringify(state)));
                  }));
              this.plugin = function (store) {
                  var savedState = _this.restoreState(_this.key, _this.storage);
                  if (_this.strictMode) {
                      store.commit('RESTORE_MUTATION', savedState);
                  }
                  else {
                      store.replaceState(merge(store.state, savedState || {}));
                  }
                  _this.subscriber(store)(function (mutation, state) {
                      if (_this.filter(mutation)) {
                          _this.saveState(_this.key, _this.reducer(state), _this.storage);
                      }
                  });
                  _this.subscribed = true;
              };
          }
      }
function VuexPersistence ( options ) { var _this = this ; this . _mutex = new SimplePromiseQueue ( ) ; this . subscriber = function ( store ) { return function ( handler ) { return store . subscribe ( handler ) ; } ; } ; if ( typeof options === 'undefined' ) options = { } ; this . key = ( ( options . key != null ) ? options . key : 'vuex' ) ; this . subscribed = false ; this . supportCircular = options . supportCircular || false ; if ( this . supportCircular ) { CircularJSON = require ( 'circular-json' ) ; } { { this . storage = options . storage || window . localStorage ; } } this . reducer = ( ( options . reducer != null ) ? options . reducer : ( ( options . modules == null ) ? ( function ( state ) { return state ; } ) : ( function ( state ) { return options . modules . reduce ( function ( a , i ) { var _a ; return merge ( a , ( _a = { } , _a [ i ] = state [ i ] , _a ) ) ; } , { } ) ; } ) ) ) ; this . filter = options . filter || ( function ( mutation ) { return true ; } ) ; this . strictMode = options . strictMode || false ; this . RESTORE_MUTATION = function RESTORE_MUTATION ( state , savedState ) { var mergedState = merge ( state , savedState || { } ) ; for ( var _i = 0 , _a = Object . keys ( mergedState ) ; _i < _a . length ; _i ++ ) { var propertyName = _a [ _i ] ; this . _vm . $set ( state , propertyName , mergedState [ propertyName ] ) ; } } ; this . asyncStorage = options . asyncStorage || false ; var storageConfig = this . storage && ( this . storage ) . _config ; this . asyncStorage = this . asyncStorage || ( storageConfig && storageConfig . name ) === 'localforage' ; if ( this . asyncStorage ) { this . restoreState = ( ( options . restoreState != null ) ? options . restoreState : ( function ( key , storage ) { return ( storage ) . getItem ( key ) . then ( function ( value ) { return typeof value === 'string' ? ( _this . supportCircular ? CircularJSON . parse ( value || '{}' ) : JSON . parse ( value || '{}' ) ) : ( value || { } ) ; } ) ; } ) ) ; this . saveState = ( ( options . saveState != null ) ? options . saveState : ( function ( key , state , storage ) { return ( storage ) . setItem ( key , ( ( ( storage && storage . _config && storage . _config . name ) === 'localforage' ) ? merge ( { } , state || { } ) : ( _this . supportCircular ? CircularJSON . stringify ( state ) : JSON . stringify ( state ) ) ) ) ; } ) ) ; this . plugin = function ( store ) { ( _this . restoreState ( _this . key , _this . storage ) ) . then ( function ( savedState ) { if ( _this . strictMode ) { store . commit ( 'RESTORE_MUTATION' , savedState ) ; } else { store . replaceState ( merge ( store . state , savedState || { } ) ) ; } _this . subscriber ( store ) ( function ( mutation , state ) { if ( _this . filter ( mutation ) ) { _this . _mutex . enqueue ( _this . saveState ( _this . key , _this . reducer ( state ) , _this . storage ) ) ; } } ) ; _this . subscribed = true ; } ) ; } ; } else { this . restoreState = ( ( options . restoreState != null ) ? options . restoreState : ( function ( key , storage ) { var value = ( storage ) . getItem ( key ) ; if ( typeof value === 'string' ) { return ( _this . supportCircular ? CircularJSON . parse ( value || '{}' ) : JSON . parse ( value || '{}' ) ) ; } else { return ( value || { } ) ; } } ) ) ; this . saveState = ( ( options . saveState != null ) ? options . saveState : ( function ( key , state , storage ) { return ( storage ) . setItem ( key , ( _this . supportCircular ? CircularJSON . stringify ( state ) : JSON . stringify ( state ) ) ) ; } ) ) ; this . plugin = function ( store ) { var savedState = _this . restoreState ( _this . key , _this . storage ) ; if ( _this . strictMode ) { store . commit ( 'RESTORE_MUTATION' , savedState ) ; } else { store . replaceState ( merge ( store . state , savedState || { } ) ) ; } _this . subscriber ( store ) ( function ( mutation , state ) { if ( _this . filter ( mutation ) ) { _this . saveState ( _this . key , _this . reducer ( state ) , _this . storage ) ; } } ) ; _this . subscribed = true ; } ; } }
Create a {@link VuexPersistence} object.
Create a { @link VuexPersistence } object .
// tslint:disable-next-line:variable-name
 /**
           * Creates a subscriber on the store. automatically is used
           * when this is used a vuex plugin. Not for manual usage.
           * @param store
           */ // @ts-ignore
 // @ts-ignore
 // If UMD module, then we will only be having localStorage
 /**
           * How this works is -
           *  1. If there is options.reducer function, we use that, if not;
           *  2. We check options.modules;
           *    1. If there is no options.modules array, we use entire state in reducer
           *    2. Otherwise, we create a reducer that merges all those state modules that are
           *        defined in the options.modules[] array
           * @type {((state: S) => {}) | ((state: S) => S) | ((state: any) => {})}
           */ /* start empty accumulator*/ /**
               * Async {@link #VuexPersistence.restoreState} implementation
               * @type {((key: string, storage?: Storage) =>
               *      (Promise<S> | S)) | ((key: string, storage: AsyncStorage) => Promise<any>)}
               */ // If string, parse, or else, just return
 /**
               * Async {@link #VuexPersistence.saveState} implementation
               * @type {((key: string, state: {}, storage?: Storage) =>
               *    (Promise<void> | void)) | ((key: string, state: {}, storage?: Storage) => Promise<void>)}
               */ // Second argument is state _object_ if localforage, stringified otherwise
 /**
               * Async version of plugin
               * @param {Store<S>} store
               */ /**
                       * If in strict mode, do only via mutation
                       */ /**
               * Sync {@link #VuexPersistence.restoreState} implementation
               * @type {((key: string, storage?: Storage) =>
               *    (Promise<S> | S)) | ((key: string, storage: Storage) => (any | string | {}))}
               */ // If string, parse, or else, just return
 /**
               * Sync {@link #VuexPersistence.saveState} implementation
               * @type {((key: string, state: {}, storage?: Storage) =>
               *     (Promise<void> | void)) | ((key: string, state: {}, storage?: Storage) => Promise<void>)}
               */ // Second argument is state _object_ if localforage, stringified otherwise
 /**
               * Sync version of plugin
               * @param {Store<S>} store
               */