Socket
Socket
Sign inDemoInstall

redux-state-branch

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-state-branch - npm Package Compare versions

Comparing version 0.0.17 to 0.0.18

40

dist/index.d.ts
export declare const makeType: (prefix: string, suffix?: string | undefined) => string;
export declare const ensureArray: (items: any) => any[];
export interface MapT {
[key: string]: any;
}
export declare type ItemT<T> = T & {

@@ -19,5 +22,3 @@ id: string;

items: ItemsT<T>;
meta: {
[key: string]: any;
};
meta: MapT;
}

@@ -37,3 +38,4 @@ export interface IState {

protected constant: ConstantsT<any>;
constructor(constants: ConstantsT<any>);
protected defaultItem: any;
constructor(constants: ConstantsT<any>, defaultItem: any);
replace(items: ItemsT<T>, devToolsSuffix?: string): {

@@ -49,3 +51,3 @@ type: string;

type: string;
items: any[];
items: any;
};

@@ -56,9 +58,5 @@ update(items: ItemsT<T>, devToolsSuffix?: string): {

};
setMeta(meta: {
[key: string]: any;
}, devToolsSuffix?: string): {
setMeta(meta: MapT, devToolsSuffix?: string): {
type: string;
meta: {
[key: string]: any;
};
meta: MapT;
};

@@ -71,12 +69,8 @@ reset(devToolsSuffix?: string): {

name: string;
actions?: new (constants: ConstantsT<C>) => A | Actions<T>;
actions?: new (constants: ConstantsT<C>, defaultItem: MapT) => A | Actions<T>;
selectors?: new (name: string) => S | Selectors<T, B>;
constants?: C;
utils?: U;
defaultItem?: {
[key: string]: any;
};
defaultState?: {
[key: string]: any;
};
defaultItem?: MapT;
defaultState?: MapT;
reducer?: (state: IState, action: IAction<T>) => IState;

@@ -90,12 +84,8 @@ }

select: S | Selectors<T, B>;
defaultItem: {
[key: string]: any;
};
defaultState: {
[key: string]: any;
};
defaultItem: MapT;
defaultState: MapT;
protected extendedReducer: (state: IState, action: IAction<T>) => IState;
constructor({ name, actions: ActionsConstructor, selectors: SelectorsConstructor, constants, utils, defaultItem, defaultState, reducer }: IStateBranchOpts<T, A, S, C, U, B>);
reducer(state: IState | undefined, action: IAction<T>): IState;
reducer(state: IState | undefined, action: IAction<T>): MapT;
}
export {};

@@ -40,4 +40,5 @@ "use strict";

var Actions = /** @class */ (function () {
function Actions(constants) {
function Actions(constants, defaultItem) {
this.constant = constants;
this.defaultItem = defaultItem;
}

@@ -60,5 +61,15 @@ Actions.prototype.replace = function (items, devToolsSuffix) {

Actions.prototype.create = function (items, devToolsSuffix) {
var _this = this;
var newCreateItems = exports.ensureArray(items || {}).reduce(function (acc, item) {
if (item.id === undefined) {
item.id = "-" + Math.random()
.toString(16)
.slice(2);
}
acc[item.id] = __assign({}, _this.defaultItem, item);
return acc;
}, {});
return {
type: exports.makeType(this.constant.CREATE, devToolsSuffix),
items: exports.ensureArray(items || {})
items: newCreateItems
};

@@ -93,11 +104,10 @@ };

this.util = utils;
this.action = new ActionsConstructor(this.constant);
this.select = new SelectorsConstructor(this.name);
this.defaultItem = defaultItem;
this.reducer = this.reducer.bind(this);
this.defaultItem = defaultItem;
this.defaultState = defaultState;
this.extendedReducer = reducer;
this.action = new ActionsConstructor(this.constant, this.defaultItem);
this.select = new SelectorsConstructor(this.name);
}
StateBranch.prototype.reducer = function (state, action) {
var _this = this;
if (state === void 0) { state = this.defaultState; }

@@ -108,14 +118,3 @@ var items = exports.ensureArray(action.items);

case this.constant.CREATE:
var newCreateItems = items.reduce(function (acc, item) {
if (item.id === undefined) {
if (action.type === _this.constant.CREATE) {
item.id = "-" + Math.random()
.toString(16)
.slice(2);
}
}
acc[item.id] = __assign({}, _this.defaultItem, item);
return acc;
}, {});
return __assign({}, state, { items: __assign({}, state.items, newCreateItems) });
return __assign({}, state, { items: __assign({}, state.items, items) });
case this.constant.UPDATE:

@@ -122,0 +121,0 @@ var newUpdateItems = items.reduce(function (acc, item) {

// @flow
declare module 'redux-state-branch' {
declare type MapT = {
[key: string]: any
};
declare type ItemT<T> = T & {

@@ -20,5 +24,3 @@ id: string

items: ItemsT<T>;
meta: {
[key: string]: any
};
meta: MapT;
}

@@ -72,11 +74,7 @@ declare export interface IState {

setMeta(
meta: {
[key: string]: any
},
meta: MapT,
suffix?: string
): {
type: string,
meta: {
[key: string]: any
}
meta: MapT
};

@@ -95,8 +93,4 @@ reset(

utils?: U;
defaultItem?: {
[key: string]: any
};
defaultState?: {
[key: string]: any
};
defaultItem?: MapT;
defaultState?: MapT;
reducer?: (state: IState, action: IAction<T>) => IState;

@@ -110,8 +104,4 @@ }

select: S;
defaultItem: {
[key: string]: any
};
defaultState: {
[key: string]: any
};
defaultItem: MapT;
defaultState: MapT;
extendedReducer: (state: IState, action: IAction<T>) => IState;

@@ -118,0 +108,0 @@ constructor(opts: IStateBranchOpts<T, A, S, C, U, B>): this;

{
"name": "redux-state-branch",
"version": "0.0.17",
"version": "0.0.18",
"private": false,

@@ -5,0 +5,0 @@ "description": "A redux wrapper for sane people.",

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