@kashcode/reduxish 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ import type { Reducer } from "./types/core";
2
+ import type { StoreEnhancer, Middleware, InferDispatchExtensionsFromMiddlewareArray } from "./types/helpers";
3
+ /**
4
+ * Combine multiple reducers into a single root reducer.
5
+ *
6
+ * @template S - The type of the global state
7
+ * @param reducerMap - A map of reducers, where each key corresponds to a key in the global state and each value is the corresponding reducer.
8
+ * @returns A single root reducer that will manage the global state.
9
+ */
10
+ export declare function combineReducers<S extends Record<string, unknown>>(reducerMap: {
11
+ [K in keyof S]: Reducer<S[K]>;
12
+ }): Reducer<S>;
13
+ export declare function applyMiddleware<S, A extends ReadonlyArray<Middleware>>(middlewares: A): StoreEnhancer<S, {
14
+ dispatch: InferDispatchExtensionsFromMiddlewareArray<A>;
15
+ }>;
16
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAS,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,0CAA0C,EAAE,MAAM,iBAAiB,CAAA;AAE5G;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7D,UAAU,EAAE;KACH,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAChC,GACN,OAAO,CAAC,CAAC,CAAC,CAKZ;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,CAAC,SAAS,aAAa,CAAC,UAAU,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE;IACtG,QAAQ,EAAE,0CAA0C,CAAC,CAAC,CAAC,CAAA;CAC1D,CAAC,CAYD"}
@@ -0,0 +1,6 @@
1
+ import type { Reducer, Store, UnknownAction } from "./types/core";
2
+ import type { StoreEnhancer } from "./types/helpers";
3
+ declare function createStore<S, Ext = {}, A extends UnknownAction = UnknownAction>(reducer: Reducer<S, A>, intialState?: S, storeEnhancer?: StoreEnhancer<S, Ext>): Store<S> & Ext;
4
+ export { createStore };
5
+ export type StoreCreator<S, Ext = {}> = typeof createStore<S, Ext>;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAmB,aAAa,EAAE,MAAM,cAAc,CAAC;AAEnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,iBAAS,WAAW,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,EAAE,CAAC,SAAS,aAAa,GAAG,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,EAAE,aAAa,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAoBzK;AAED,OAAO,EAAC,WAAW,EAAC,CAAA;AACpB,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,IAAI,OAAO,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA"}
@@ -0,0 +1,17 @@
1
+ export type Action = {
2
+ type: string;
3
+ };
4
+ export type UnknownAction = Record<string, unknown> & Action;
5
+ export interface Dispatch<A extends UnknownAction = UnknownAction> {
6
+ (action: A): A;
7
+ }
8
+ export type StoreSubscriber = Function;
9
+ export interface Store<S> {
10
+ dispatch<A extends UnknownAction = UnknownAction>(action: A): ReturnType<Dispatch<A>>;
11
+ getState: () => S;
12
+ subscribe: (...subscribtionRequests: StoreSubscriber[]) => () => void;
13
+ }
14
+ export interface Reducer<S, A extends UnknownAction = UnknownAction> {
15
+ (state: S | undefined, action?: A): S;
16
+ }
17
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/types/core.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG;IACjB,IAAI,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAA;AAE5D,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa;IAC7D,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAA;CACjB;AAED,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAA;AAEtC,MAAM,WAAW,KAAK,CAAC,CAAC;IACpB,QAAQ,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAAE,MAAM,EAAE,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;IACrF,QAAQ,EAAE,MAAM,CAAC,CAAA;IACjB,SAAS,EAAE,CAAC,GAAG,oBAAoB,EAAE,eAAe,EAAE,KAAK,MAAM,IAAI,CAAA;CACxE;AAGD,MAAM,WAAW,OAAO,CAAC,CAAC,EAAE,CAAC,SAAS,aAAa,GAAG,aAAa;IAC/D,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;CACxC"}
@@ -0,0 +1,6 @@
1
+ import { StoreCreator } from "..";
2
+ import { Store } from "./core";
3
+ export type Middleware<DispatchExt = any> = (store: Store<any>) => (next: (action: any) => any) => DispatchExt;
4
+ export type StoreEnhancer<S = unknown, Ext = {}> = (next: StoreCreator<S, unknown>) => StoreCreator<S, Ext>;
5
+ export type InferDispatchExtensionsFromMiddlewareArray<A extends readonly any[], Acc = {}> = [...A] extends [infer First, ...infer Rest] ? InferDispatchExtensionsFromMiddlewareArray<[...Rest], Acc & (First extends Middleware<infer M> ? M extends never ? {} : M : {})> : Acc;
6
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/types/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,MAAM,MAAM,UAAU,CAAC,WAAW,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,KAAK,WAAW,CAAA;AAC9G,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,EAAC,GAAG,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,YAAY,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;AAC1G,MAAM,MAAM,0CAA0C,CAAC,CAAC,SAAS,SAAS,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,0CAA0C,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,KAAK,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,GAAG,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kashcode/reduxish",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "A tiny, fully-typed Redux-inspired state management library with store enhancement/plugin support for functionality such as thunking, logging, etc with full type inference on the enhanced store. Complies with flux architecture and fully compatible with react-redux bindings.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -16,7 +16,7 @@
16
16
  "test": "jest --coverage",
17
17
  "test:watch": "jest --watch",
18
18
  "prepublishOnly": "npm run test && npm run build",
19
- "publish": "npm run prepublishOnly && npm publish"
19
+ "push": "npm run prepublishOnly && npm publish"
20
20
  },
21
21
  "author": "Kasope <kasopej@gmail.com>",
22
22
  "license": "MIT",