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

berkeleys-redux-utils

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

berkeleys-redux-utils - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

10

CHANGELOG.md

@@ -0,1 +1,11 @@

<a name="3.1.1"></a>
## [3.1.1](https://github.com/BerkeleyTrue/berkeleys-redux-utils/compare/v3.1.0...v3.1.1) (2017-09-08)
### Bug Fixes
* **combineReducers:** Should not mutate state ([3a72d65](https://github.com/BerkeleyTrue/berkeleys-redux-utils/commit/3a72d65))
<a name="3.1.0"></a>

@@ -2,0 +12,0 @@ # [3.1.0](https://github.com/BerkeleyTrue/berkeleys-redux-utils/compare/v3.0.1...v3.1.0) (2017-09-08)

34

lib/reduce-reducers.js

@@ -7,23 +7,2 @@ "use strict";

exports.default = createFinalReducer;
var createGetNS = function createGetNS(isNS, ns) {
return isNS ? function () {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return state[ns];
} : function (state) {
return state;
};
};
var createSetNS = function createSetNS(isNS, ns) {
return isNS ? function () {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var value = arguments[1];
state[ns] = value;
return state;
} : function (state, value) {
return value;
};
};
function createFinalReducer(isNS, reducers) {

@@ -36,5 +15,5 @@ return function () {

var combinedOrComposed = reducers.reduce(function (oldState, reducer) {
var prevState = createGetNS(isNS, reducer)(oldState);
var nextState = createSetNS(isNS, reducer)(oldState, reducer(prevState, action));
var combinedOrComposed = reducers.reduce(function (iteratedState, reducer) {
var prevState = isNS ? state[reducer] : iteratedState;
var nextState = reducer(prevState, action);

@@ -44,6 +23,7 @@ hasChanged = hasChanged || prevState !== nextState;

if (isNS) {
return oldState;
iteratedState[reducer] = nextState;
return hasChanged ? iteratedState : state;
}
return hasChanged ? nextState : oldState;
}, state);
return hasChanged ? nextState : iteratedState;
}, isNS ? {} : state);

@@ -50,0 +30,0 @@ return hasChanged ? combinedOrComposed : state;

{
"name": "berkeleys-redux-utils",
"version": "3.1.0",
"version": "3.1.1",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "scripts": {

@@ -1,12 +0,1 @@

const createGetNS = (isNS, ns) =>
isNS ? (state = {}) => state[ns] : state => state;
const createSetNS = (isNS, ns) =>
isNS ?
(state = {}, value) => {
state[ns] = value;
return state;
} :
(state, value) => value;
export default function createFinalReducer(isNS, reducers) {

@@ -16,8 +5,5 @@ return (state = {}, action) => {

const combinedOrComposed = reducers.reduce((oldState, reducer) => {
const prevState = createGetNS(isNS, reducer)(oldState);
const nextState = createSetNS(isNS, reducer)(
oldState,
reducer(prevState, action),
);
const combinedOrComposed = reducers.reduce((iteratedState, reducer) => {
const prevState = isNS ? state[reducer] : iteratedState;
const nextState = reducer(prevState, action);

@@ -27,6 +13,7 @@ hasChanged = hasChanged || prevState !== nextState;

if (isNS) {
return oldState;
iteratedState[reducer] = nextState;
return hasChanged ? iteratedState : state;
}
return hasChanged ? nextState : oldState;
}, state);
return hasChanged ? nextState : iteratedState;
}, isNS ? {} : state);

@@ -33,0 +20,0 @@ return hasChanged ? combinedOrComposed : state;

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