@kashcode/reduxish 0.4.0 → 0.5.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.
- package/dist/helpers.js +2 -6
- package/dist/index.js +3 -8
- package/dist/types/core.js +1 -2
- package/dist/types/helpers.js +1 -2
- package/package.json +1 -1
package/dist/helpers.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.combineReducers = combineReducers;
|
|
4
|
-
exports.applyMiddleware = applyMiddleware;
|
|
5
1
|
/**
|
|
6
2
|
* Combine multiple reducers into a single root reducer.
|
|
7
3
|
*
|
|
@@ -9,14 +5,14 @@ exports.applyMiddleware = applyMiddleware;
|
|
|
9
5
|
* @param reducerMap - A map of reducers, where each key corresponds to a key in the global state and each value is the corresponding reducer.
|
|
10
6
|
* @returns A single root reducer that will manage the global state.
|
|
11
7
|
*/
|
|
12
|
-
function combineReducers(reducerMap) {
|
|
8
|
+
export function combineReducers(reducerMap) {
|
|
13
9
|
return function (state, action) { return (Object.entries(reducerMap)).reduce(function (partialState, _a) {
|
|
14
10
|
var key = _a[0], reducer = _a[1];
|
|
15
11
|
partialState[key] = reducer(state === null || state === void 0 ? void 0 : state[key], action);
|
|
16
12
|
return partialState;
|
|
17
13
|
}, {}); };
|
|
18
14
|
}
|
|
19
|
-
function applyMiddleware(middlewares) {
|
|
15
|
+
export function applyMiddleware(middlewares) {
|
|
20
16
|
return function (storeCreator) { return function (reducer, intialState) {
|
|
21
17
|
var store = storeCreator(reducer, intialState);
|
|
22
18
|
middlewares.concat().reverse().forEach(function (middleware) {
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createStore = createStore;
|
|
7
|
-
var deep_freeze_1 = __importDefault(require("deep-freeze"));
|
|
1
|
+
import deepFreeze from "deep-freeze";
|
|
8
2
|
function createStore(reducer, intialState, storeEnhancer) {
|
|
9
3
|
var state = intialState;
|
|
10
4
|
var subscribers = [];
|
|
11
5
|
var storeCreator = {
|
|
12
6
|
dispatch: function (action) {
|
|
13
|
-
state = reducer(typeof state === 'object' ? (
|
|
7
|
+
state = reducer(typeof state === 'object' ? deepFreeze(state) : state, action);
|
|
14
8
|
subscribers.forEach(function (sub) { return sub(); });
|
|
15
9
|
return action;
|
|
16
10
|
},
|
|
@@ -30,3 +24,4 @@ function createStore(reducer, intialState, storeEnhancer) {
|
|
|
30
24
|
};
|
|
31
25
|
return storeEnhancer ? storeEnhancer(createStore)(reducer, intialState) : storeCreator;
|
|
32
26
|
}
|
|
27
|
+
export { createStore };
|
package/dist/types/core.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/types/helpers.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kashcode/reduxish",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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",
|