New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

redux-storage

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-storage - npm Package Compare versions

Comparing version 1.2.4 to 1.3.0

47

lib/createMiddleware.js

@@ -15,18 +15,51 @@ 'use strict';

function warnAboutConfusingFiltering(blacklist, whitelist) {
for (var _iterator = blacklist, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var item = _ref;
if (whitelist.indexOf(item) === -1) {
continue;
}
console.warn( // eslint-disable-line no-console
'[redux-storage] Action ' + item + ' is on BOTH black- and whitelist.' + ' This is most likely a mistake!');
}
}
exports['default'] = function (engine) {
var actionBlacklist = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1];
var actionWhitelist = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2];
// Also don't save if we process our own actions
var actionsToIgnore = [].concat(_toConsumableArray(actionBlacklist), [_constants.LOAD, _constants.SAVE]);
var blacklistedActions = [].concat(_toConsumableArray(actionBlacklist), [_constants.LOAD, _constants.SAVE]);
return function (_ref) {
var dispatch = _ref.dispatch;
var getState = _ref.getState;
if (process.env.NODE_ENV !== 'production') {
warnAboutConfusingFiltering(actionBlacklist, actionWhitelist);
}
return function (_ref2) {
var dispatch = _ref2.dispatch;
var getState = _ref2.getState;
return function (next) {
return function (action) {
next(action);
var result = next(action);
var isOnBlacklist = blacklistedActions.indexOf(action.type) !== -1;
var isOnWhitelist = actionWhitelist.length === 0 ? true // Don't filter if the whitelist is empty
: actionWhitelist.indexOf(action.type) !== -1;
// Skip blacklisted actions
if (actionsToIgnore.indexOf(action.type) === -1) {
if (!isOnBlacklist && isOnWhitelist) {
(function () {

@@ -40,2 +73,4 @@ var saveState = getState();

}
return result;
};

@@ -42,0 +77,0 @@ };

6

package.json
{
"name": "redux-storage",
"version": "1.2.4",
"version": "1.3.0",
"description": "Persistence layer for redux with flexible backends",

@@ -38,4 +38,4 @@ "main": "lib/index.js",

"chai-string": "1.1.3",
"eslint": "1.5.1",
"eslint-config-airbnb": "0.0.8",
"eslint": "1.6.0",
"eslint-config-airbnb": "0.1.0",
"eslint-plugin-react": "3.5.1",

@@ -42,0 +42,0 @@ "mocha": "2.3.3",

@@ -25,3 +25,3 @@ [redux-storage][]

* [immutablejs][]: load parts of the state tree as [Immutable][] objects
* Blacklist actions from issuing a save operation
* Black- and whitelist actions from issuing a save operation

@@ -151,2 +151,13 @@ ## Installation

If you want to whitelist all actions that are allowed to issue a `engine.save`,
just specify them as third argument.
```js
import storage from 'redux-storage'
import { SHOULD_SAVE } from './constants';
const middleware = storage.createMiddleware(engine, [], [ SHOULD_SAVE ]);
```
### Decorators

@@ -153,0 +164,0 @@

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