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

create-reducer-tree

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-reducer-tree - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

22

dist/create-reducer-tree.js

@@ -31,15 +31,18 @@ "use strict";

exports.fetchActionsForTree = fetchActionsForTree;
var states = [];
function generateInitialState(tree) {
function removeActionsAndReducers(state) {
for (var i in state) {
if (i === "actions" || i === "reducer" || i === "initialState") {
delete state[i];
function handleStateChunk(state) {
var newState = {};
var keys = fetchKeysInItem(state);
keys.forEach(function (key) {
if (key !== "initialState" && key !== "actions" && key !== "reducer") {
newState[key] = handleStateChunk(state[key]);
}
removeActionsAndReducers(state[i]);
}
if (key === "initialState") {
Object.assign(newState, state[key]);
}
});
return newState;
}
var state = JSON.parse(JSON.stringify(tree));
removeActionsAndReducers(state);
states.push(state);
var newState = handleStateChunk(state);
return state;

@@ -52,3 +55,2 @@ }

var initialState = reducerTree.initialState || generateInitialState(reducerTree);
console.log(initialState);
return function (state, action) {

@@ -55,0 +57,0 @@ if (state === void 0) { state = clone(initialState); }

{
"name": "create-reducer-tree",
"version": "0.0.3",
"version": "0.0.4",
"description": "A tool to create a redux reducer composition tree",

@@ -5,0 +5,0 @@ "main": "dist/create-reducer-tree.js",

@@ -31,16 +31,19 @@ declare function require(string: string): any;

}
let states = [];
export function generateInitialState(tree: any): any {
function removeActionsAndReducers(state) {
for (var i in state) {
if (i === "actions" || i === "reducer" || i === "initialState") {
delete state[i];
function handleStateChunk(state: any) {
let newState = {};
let keys = fetchKeysInItem(state);
keys.forEach(key => {
if (key !== "initialState" && key !== "actions" && key !== "reducer") {
newState[key] = handleStateChunk(state[key]);
}
removeActionsAndReducers(state[i]);
}
if (key === "initialState") {
Object.assign(newState, state[key]);
}
});
return newState;
}
let state = JSON.parse(JSON.stringify(tree));
removeActionsAndReducers(state);
states.push(state);
let newState = handleStateChunk(state);
return state;

@@ -53,3 +56,2 @@ }

let initialState = reducerTree.initialState || generateInitialState(reducerTree);
console.log(initialState)
return function (state: any = clone(initialState), action: {type: string, payload: any}) {

@@ -56,0 +58,0 @@ if (actions.indexOf(action.type) > -1) {

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