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.38 to 0.0.39

40

dist/index.d.ts

@@ -47,12 +47,13 @@ interface AnyAction<T = any> {

export declare class Selectors<ItemT extends AnyItem, BranchStateT extends State<ItemT> = State<ItemT>> {
private methods;
protected branchName: string;
constructor(branchName: string);
/** Get all items */
all: <StateT>(state: StateT) => ItemT[];
all<StateT>(state: StateT): AnyItem[];
/** Get an item by id */
byId: <StateT>(state: StateT, id?: string | null) => ItemT | undefined;
byId<StateT>(state: StateT, id?: string | null): AnyItem | undefined;
/** Get an items that meet a filter condition */
where: <StateT>(state: StateT, condition: (item: ItemT) => boolean) => ItemT[];
where<StateT>(state: StateT, condition: (item: ItemT) => boolean): AnyItem[];
/** Get the top level meta content */
meta: <StateT>(state: StateT) => BranchStateT;
constructor(branchName: string);
meta<StateT>(state: StateT): State<any>;
}

@@ -100,37 +101,38 @@ /**

protected generateId: () => string;
private methods;
constructor(branchName: string, constants: Constants, defaultItem: Partial<ItemT>, generateId: () => string);
/** Create an item */
create: (items?: Partial<ItemT> | Partial<ItemT>[] | undefined, typeSuffix?: string | undefined) => {
create(items?: ItemsT<ItemT> | undefined, typeSuffix?: string | undefined): {
type: string;
items: PartialWithId<ItemT>[];
items: PartialWithId<AnyItem>[];
};
/** Update an item */
update: (items: ItemsT<ItemT>, typeSuffix?: string | undefined) => {
update(items: ItemsT<ItemT>, typeSuffix?: string | undefined): {
type: string;
items: PartialWithId<ItemT>[];
items: PartialWithId<AnyItem>[];
};
/** Remove an item */
remove: (items: string | Partial<ItemT> | Partial<ItemT>[] | string[], typeSuffix?: string | undefined) => {
remove(items: string | ItemsT<ItemT> | string[], typeSuffix?: string | undefined): {
type: string;
items: PartialWithId<ItemT>[];
items: PartialWithId<AnyItem>[];
};
/** DEPRECATED, Use remove instead */
delete: (items: string | Partial<ItemT> | Partial<ItemT>[] | string[], typeSuffix?: string | undefined) => {
delete(items: string | ItemsT<ItemT> | string[], typeSuffix?: string | undefined): {
type: string;
items: PartialWithId<ItemT>[];
items: PartialWithId<AnyItem>[];
};
/** Replace an item */
replace: (items: ItemsT<ItemT>, typeSuffix?: string | undefined) => {
replace(items: ItemsT<ItemT>, typeSuffix?: string | undefined): {
type: string;
items: PartialWithId<ItemT>[];
items: PartialWithId<AnyItem>[];
};
/** Set meta content */
setMeta: (meta: Partial<BranchStateT>, typeSuffix?: string | undefined) => {
setMeta(meta: Partial<BranchStateT>, typeSuffix?: string | undefined): {
type: string;
meta: Partial<BranchStateT>;
meta: Partial<State<any>>;
};
/** Reset branch to initial state */
reset: (typeSuffix?: string | undefined) => {
reset(typeSuffix?: string | undefined): {
type: string;
};
constructor(branchName: string, constants: Constants, defaultItem: Partial<ItemT>, generateId: () => string);
}

@@ -137,0 +139,0 @@ export declare class StateBranch<ItemT extends AnyItem, BranchStateT extends State<ItemT>, ActionsT extends Actions<ItemT, BranchStateT> | {

@@ -68,8 +68,20 @@ "use strict";

this.branchName = branchName;
var _a = exports.selectorsFactory(branchName), all = _a.all, byId = _a.byId, where = _a.where, meta = _a.meta;
this.all = all;
this.byId = byId;
this.where = where;
this.meta = meta;
this.methods = exports.selectorsFactory(branchName);
}
/** Get all items */
Selectors.prototype.all = function (state) {
return this.methods.all(state);
};
/** Get an item by id */
Selectors.prototype.byId = function (state, id) {
return this.methods.byId(state, id);
};
/** Get an items that meet a filter condition */
Selectors.prototype.where = function (state, condition) {
return this.methods.where(state, condition);
};
/** Get the top level meta content */
Selectors.prototype.meta = function (state) {
return this.methods.meta(state);
};
return Selectors;

@@ -147,14 +159,32 @@ }());

this.generateId = generateId;
var _a = exports.actionsFactory(branchName, defaultItem, generateId), create = _a.create, update = _a.update, remove = _a.remove, replace = _a.replace, setMeta = _a.setMeta, reset = _a.reset;
this.create = create;
this.update = update;
this.delete = function (items, typeSuffix) {
console.log(branchName + ".action.delete is deprecated. Please use .remove instead.");
return remove(items, typeSuffix);
};
this.remove = remove;
this.replace = replace;
this.setMeta = setMeta;
this.reset = reset;
this.methods = exports.actionsFactory(branchName, defaultItem, generateId);
}
/** Create an item */
Actions.prototype.create = function (items, typeSuffix) {
return this.methods.create(items, typeSuffix);
};
/** Update an item */
Actions.prototype.update = function (items, typeSuffix) {
return this.methods.update(items, typeSuffix);
};
/** Remove an item */
Actions.prototype.remove = function (items, typeSuffix) {
return this.methods.remove(items, typeSuffix);
};
/** DEPRECATED, Use remove instead */
Actions.prototype.delete = function (items, typeSuffix) {
return this.methods.remove(items, typeSuffix);
};
/** Replace an item */
Actions.prototype.replace = function (items, typeSuffix) {
return this.methods.replace(items, typeSuffix);
};
/** Set meta content */
Actions.prototype.setMeta = function (meta, typeSuffix) {
return this.methods.setMeta(meta, typeSuffix);
};
/** Reset branch to initial state */
Actions.prototype.reset = function (typeSuffix) {
return this.methods.reset(typeSuffix);
};
return Actions;

@@ -161,0 +191,0 @@ }());

{
"name": "redux-state-branch",
"version": "0.0.38",
"version": "0.0.39",
"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