You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
2.5 KiB
37 lines
2.5 KiB
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } |
|
|
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
|
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } |
|
|
|
/* |
|
autoMergeLevel1: |
|
- merges 1 level of substate |
|
- skips substate if already modified |
|
*/ |
|
export default function autoMergeLevel1(inboundState, originalState, reducedState, _ref) { |
|
var debug = _ref.debug; |
|
|
|
var newState = _objectSpread({}, reducedState); // only rehydrate if inboundState exists and is an object |
|
|
|
|
|
if (inboundState && _typeof(inboundState) === 'object') { |
|
Object.keys(inboundState).forEach(function (key) { |
|
// ignore _persist data |
|
if (key === '_persist') return; // if reducer modifies substate, skip auto rehydration |
|
|
|
if (originalState[key] !== reducedState[key]) { |
|
if (process.env.NODE_ENV !== 'production' && debug) console.log('redux-persist/stateReconciler: sub state for key `%s` modified, skipping.', key); |
|
return; |
|
} // otherwise hard set the new value |
|
|
|
|
|
newState[key] = inboundState[key]; |
|
}); |
|
} |
|
|
|
if (process.env.NODE_ENV !== 'production' && debug && inboundState && _typeof(inboundState) === 'object') console.log("redux-persist/stateReconciler: rehydrated keys '".concat(Object.keys(inboundState).join(', '), "'")); |
|
return newState; |
|
} |