createTransform.js 1002 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.default = createTransform;
  4. function createTransform( // @NOTE inbound: transform state coming from redux on its way to being serialized and stored
  5. inbound, // @NOTE outbound: transform state coming from storage, on its way to be rehydrated into redux
  6. outbound) {
  7. var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  8. var whitelist = config.whitelist || null;
  9. var blacklist = config.blacklist || null;
  10. function whitelistBlacklistCheck(key) {
  11. if (whitelist && whitelist.indexOf(key) === -1) return true;
  12. if (blacklist && blacklist.indexOf(key) !== -1) return true;
  13. return false;
  14. }
  15. return {
  16. in: function _in(state, key, fullState) {
  17. return !whitelistBlacklistCheck(key) && inbound ? inbound(state, key, fullState) : state;
  18. },
  19. out: function out(state, key, fullState) {
  20. return !whitelistBlacklistCheck(key) && outbound ? outbound(state, key, fullState) : state;
  21. }
  22. };
  23. }