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

redux-entities

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-entities - npm Package Compare versions

Comparing version 0.0.4 to 1.0.0

test/index.js

56

lib/index.js
'use strict';
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.entitiesReducer = entitiesReducer;
exports.combineEntitiesReducers = combineEntitiesReducers;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _isFunction = require('lodash/isFunction');
var _lodashLangIsFunction = require('lodash/lang/isFunction');
var _isFunction2 = _interopRequireDefault(_isFunction);
var _lodashLangIsFunction2 = _interopRequireDefault(_lodashLangIsFunction);
var _mapValues = require('lodash/mapValues');
var _lodashObjectMapValues = require('lodash/object/mapValues');
var _mapValues2 = _interopRequireDefault(_mapValues);
var _lodashObjectMapValues2 = _interopRequireDefault(_lodashObjectMapValues);
var _get = require('lodash/get');
var _get2 = _interopRequireDefault(_get);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function selectEntities(action, name) {
if (action.payload && action.payload.entities && action.payload.entities[name]) {
return action.payload.entities[name];
}
var entities = (0, _get2.default)(action, 'payload.entities.' + name);
if (entities) {
return entities;
}
}
function entitiesReducer(reducer, entitiesName) {
return function (state, action) {
var newState = state;
var entities = _lodashLangIsFunction2['default'](entitiesName) ? entitiesName(action) : selectEntities(action, entitiesName);
return function (state, action) {
var newState = state;
var entities = (0, _isFunction2.default)(entitiesName) ? entitiesName(action) : selectEntities(action, entitiesName);
if (entities) {
newState = Object.assign({}, newState, entities);
}
if (entities) {
newState = Object.assign({}, newState, entities);
}
return reducer(newState, action);
};
return reducer(newState, action);
};
}
function combineEntitiesReducers(reducers) {
var entitiesReducers = _lodashObjectMapValues2['default'](reducers, entitiesReducer);
return function (state, action) {
if (state === undefined) state = {};
return _lodashObjectMapValues2['default'](entitiesReducers, function (reducer, key) {
return reducer(state[key], action);
});
};
var entitiesReducers = (0, _mapValues2.default)(reducers, entitiesReducer);
return function () {
var state = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var action = arguments[1];
return (0, _mapValues2.default)(entitiesReducers, function (reducer, key) {
return reducer(state[key], action);
});
};
}
{
"name": "redux-entities",
"version": "0.0.4",
"description": "Higher-order reducer for store entities received from gaearon's normalizr and makes it easy to handle them.",
"version": "1.0.0",
"description": "Higher-order reducer for store entities received from normalizr and makes it easy to handle them.",
"main": "lib/index.js",
"scripts": {
"test": "eslint ./src/*.js",
"test": "mocha --compilers js:babel-core/register --recursive",
"eslint": "eslint ./src/*.js",
"build": "babel src --out-dir lib",

@@ -30,12 +31,16 @@ "clean": "rimraf lib",

"devDependencies": {
"babel": "^5.8.29",
"babel-eslint": "^4.1.3",
"eslint": "^1.7.3",
"eslint-config-airbnb": "^0.1.0",
"eslint-plugin-react": "^3.6.3",
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-eslint": "^6.1.2",
"babel-preset-es2015": "^6.14.0",
"babel-preset-stage-1": "^6.13.0",
"babel-register": "^6.14.0",
"chai": "^3.5.0",
"eslint": "^3.4.0",
"mocha": "^3.0.2",
"rimraf": "^2.4.3"
},
"dependencies": {
"lodash": "^3.10.1"
"lodash": "^4.11.2"
}
}

@@ -6,3 +6,3 @@ # Redux Entities

Higher-order reducer for store entities received from gaearon's [normalizr](https://github.com/gaearon/normalizr) and makes it easy to handle them.
Higher-order reducer for store entities received from [normalizr](https://github.com/paularmstrong/normalizr) and makes it easy to handle them.

@@ -23,3 +23,3 @@ ### Installation

import { entitiesReducer } from 'redux-entities';
import omit from 'lodash/object/omit';
import omit from 'lodash/omit';

@@ -26,0 +26,0 @@ function contacts(state = {}, action) {

Sorry, the diff of this file is not supported yet

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