Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-persist-transform-filter

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-persist-transform-filter - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

53

dist/index.js

@@ -6,2 +6,5 @@ 'use strict';

});
exports.default = createFilter;
exports.createWhitelistFilter = createWhitelistFilter;
exports.createBlacklistFilter = createBlacklistFilter;
exports.persistFilter = persistFilter;

@@ -19,9 +22,15 @@

var _lodash5 = require('lodash.unset');
var _lodash6 = _interopRequireDefault(_lodash5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function (reducerName, inboundPaths, outboundPaths) {
function createFilter(reducerName, inboundPaths, outboundPaths) {
var transformType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'whitelist';
return (0, _reduxPersist.createTransform)(
// inbound
function (inboundState, key) {
return inboundPaths ? persistFilter(inboundState, inboundPaths) : inboundState;
return inboundPaths ? persistFilter(inboundState, inboundPaths, transformType) : inboundState;
},

@@ -31,8 +40,17 @@

function (outboundState, key) {
return outboundPaths ? persistFilter(outboundState, outboundPaths) : outboundState;
}, { whitelist: [reducerName] });
return outboundPaths ? persistFilter(outboundState, outboundPaths, transformType) : outboundState;
}, { 'whitelist': [reducerName] });
};
function createWhitelistFilter(reducerName, inboundPaths, outboundPaths) {
return createFilter(reducerName, inboundPaths, outboundPaths, 'whitelist');
}
function createBlacklistFilter(reducerName, inboundPaths, outboundPaths) {
return createFilter(reducerName, inboundPaths, outboundPaths, 'blacklist');
}
function persistFilter(state) {
var paths = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1];
var paths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var transformType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'whitelist';

@@ -46,11 +64,24 @@ var subset = {};

paths.forEach(function (path) {
var value = (0, _lodash2.default)(state, path);
if (transformType === 'whitelist') {
paths.forEach(function (path) {
var value = (0, _lodash2.default)(state, path);
if (typeof value !== 'undefined') {
(0, _lodash4.default)(subset, path, value);
}
});
if (typeof value !== 'undefined') {
(0, _lodash4.default)(subset, path, value);
}
});
} else if (transformType === 'blacklist') {
subset = Object.assign({}, state);
paths.forEach(function (path) {
var value = (0, _lodash2.default)(state, path);
if (typeof value !== 'undefined') {
(0, _lodash6.default)(subset, path);
}
});
} else {
subset = state;
}
return subset;
}
{
"name": "redux-persist-transform-filter",
"version": "0.0.8",
"version": "0.0.9",
"description": "Filter transformator for redux-persist",

@@ -9,3 +9,3 @@ "main": "dist/index.js",

"build": "mkdir -p dist && babel index.js -o dist/index.js",
"release": "npm test && npm build && release-it"
"release": "npm test && npm run build && release-it"
},

@@ -12,0 +12,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc