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

refect

Package Overview
Dependencies
Maintainers
5
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

refect - npm Package Compare versions

Comparing version 0.1.1 to 1.0.0

42

lib/core/configureRefect.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,13 +6,20 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = configureRefect;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _parseRefect = require("./parseRefect");
exports.default = configureRefect;
var _utils = require("../utils");
var _parseRefect = require('./parseRefect');
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
var _utils = require('../utils');
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var defaultEffects = [];

@@ -27,10 +34,9 @@ var defaultRefectReducer = _utils.defaultRefectTasks;

var _options$reducer = options.reducer,
refectReducer = _options$reducer === undefined ? defaultRefectReducer : _options$reducer,
refectReducer = _options$reducer === void 0 ? defaultRefectReducer : _options$reducer,
_options$tasks = options.tasks,
refectTasks = _options$tasks === undefined ? _utils.defaultRefectTasks : _options$tasks,
refectTasks = _options$tasks === void 0 ? _utils.defaultRefectTasks : _options$tasks,
initialState = options.initialState,
_options$effects = options.effects,
effects = _options$effects === undefined ? defaultEffects : _options$effects;
effects = _options$effects === void 0 ? defaultEffects : _options$effects;
function getActions() {

@@ -42,3 +48,2 @@ return store.getActions(namespace);

var hasActionExists = currActions && _utils.is.object(currActions) && Object.keys(currActions).length;
var hasNamespaceExists = !!(0, _utils.get)(store.getState(), namespace);

@@ -48,4 +53,3 @@

var savedUUID = store.getUUID(namespace);
var errMsg = 'You can not use the same ' + ('namespace \'' + namespace + '\' in different refect component, please set a different one.');
var errMsg = 'You can not use the same ' + "namespace '".concat(namespace, "' in different refect component, please set a different one.");
(0, _utils.check)(savedUUID === uuid, errMsg);

@@ -60,16 +64,18 @@ } else {

var reducers = [].concat(_toConsumableArray(rootPutinReducers), _toConsumableArray(putinReducers), [refectReducer]);
var finalRefectReducer = _parseRefect.combineRefectReducer.apply(undefined, _toConsumableArray(reducers));
var finalRefectReducer = _parseRefect.combineRefectReducer.apply(void 0, _toConsumableArray(reducers));
var reducerActionCreators = (0, _parseRefect.parseRefectActions)(finalRefectReducer, namespace);
var reducer = (0, _parseRefect.parseRefectReducer)(finalRefectReducer, namespace, initialState);
(0, _utils.check)(store.runTask, 'store should use a task middleware!');
var taskActionCreators = store.runTask({
refectTasks: refectTasks, namespace: namespace, getActions: getActions,
refectTasks: refectTasks,
namespace: namespace,
getActions: getActions,
effectors: effectors
});
var actionCreators = _extends({}, reducerActionCreators, taskActionCreators);
var actionCreators = _objectSpread({}, reducerActionCreators, taskActionCreators);
(0, _utils.check)(store.updateRefect, 'store should use refect enhancer!');
store.updateRefect({

@@ -76,0 +82,0 @@ reducer: reducer,

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -8,23 +8,26 @@ Object.defineProperty(exports, "__esModule", {

var _enhancer = require('./enhancer');
var _enhancer = _interopRequireDefault(require("./enhancer"));
var _enhancer2 = _interopRequireDefault(_enhancer);
var _middleware = _interopRequireDefault(require("./middleware"));
var _middleware = require('./middleware');
var _redux = require("redux");
var _middleware2 = _interopRequireDefault(_middleware);
var _parseRefect = require("./parseRefect");
var _redux = require('redux');
var _utils = require("../utils");
var _parseRefect = require('./parseRefect');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _utils = require('../utils');
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var defaultCustom = function defaultCustom() {
return {};
};
var noOp = function noOp() {};

@@ -35,14 +38,14 @@

var _storeConfig$middlewa = storeConfig.middlewares,
middlewares = _storeConfig$middlewa === undefined ? [] : _storeConfig$middlewa,
middlewares = _storeConfig$middlewa === void 0 ? [] : _storeConfig$middlewa,
_storeConfig$enhancer = storeConfig.enhancers,
enhancers = _storeConfig$enhancer === undefined ? [] : _storeConfig$enhancer,
enhancers = _storeConfig$enhancer === void 0 ? [] : _storeConfig$enhancer,
_storeConfig$rootEffe = storeConfig.rootEffects,
rootEffects = _storeConfig$rootEffe === undefined ? [] : _storeConfig$rootEffe,
rootEffects = _storeConfig$rootEffe === void 0 ? [] : _storeConfig$rootEffe,
_storeConfig$initRedu = storeConfig.initReducers,
initReducers = _storeConfig$initRedu === undefined ? _utils.identity : _storeConfig$initRedu,
initReducers = _storeConfig$initRedu === void 0 ? _utils.identity : _storeConfig$initRedu,
initialState = storeConfig.initialState,
_storeConfig$storeCre = storeConfig.storeCreated,
storeCreated = _storeConfig$storeCre === undefined ? noOp : _storeConfig$storeCre,
storeCreated = _storeConfig$storeCre === void 0 ? noOp : _storeConfig$storeCre,
_storeConfig$createTa = storeConfig.createTaskMiddleware,
createTaskMiddleware = _storeConfig$createTa === undefined ? _middleware2.default : _storeConfig$createTa;
createTaskMiddleware = _storeConfig$createTa === void 0 ? _middleware.default : _storeConfig$createTa;

@@ -55,10 +58,8 @@ var _parseRefectEffects = (0, _parseRefect.parseRefectEffects)(rootEffects),

var finalCreateStore = _redux.compose.apply(undefined, [_redux.applyMiddleware.apply(undefined, _toConsumableArray(middlewares).concat([taskMiddleware])), (0, _enhancer2.default)(putinReducers)].concat(_toConsumableArray(enhancers)))(_redux.createStore);
var finalCreateStore = _redux.compose.apply(void 0, [_redux.applyMiddleware.apply(void 0, _toConsumableArray(middlewares).concat([taskMiddleware])), (0, _enhancer.default)(putinReducers)].concat(_toConsumableArray(enhancers)))(_redux.createStore);
var store = finalCreateStore(initReducers, initialState);
store.runTask = taskMiddleware.runTask;
storeCreated(store);
return store;
}

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = createRefectEnhancer;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _utils = require("../utils");
exports.default = createRefectEnhancer;
var _parseRefect = require("./parseRefect");
var _utils = require('../utils');
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
var _parseRefect = require('./parseRefect');
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

@@ -45,5 +46,3 @@ function createRefectEnhancer(rootPutinReducers) {

var restState = (0, _utils.omit)(state, namespace);
var newState = prevReducer(restState, action);
return (0, _utils.set)(newState, namespace, reducerNode(nodeState, action));

@@ -58,16 +57,13 @@ }

actions = subActions;
return;
}
(0, _utils.check)(!(0, _utils.get)(actions, namespace), 'enhancer/updateActions: actions in ' + namespace + ' has existed');
(0, _utils.check)(!(0, _utils.get)(actions, namespace), "enhancer/updateActions: actions in ".concat(namespace, " has existed"));
actions = (0, _utils.set)(actions, namespace, subActions);
}
return _extends({}, store, {
return _objectSpread({}, store, {
replaceReducer: replaceReducer,
updateRefect: function updateRefect(refect) {
var namespace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
updateReducer(refect.reducer, namespace);

@@ -79,3 +75,2 @@ updateActions(refect.actions, namespace);

var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
return (0, _utils.get)(actions, namespace) || {};

@@ -85,4 +80,3 @@ },

var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
return (0, _utils.get)(uuids, namespace + '.uuid') || '';
return (0, _utils.get)(uuids, "".concat(namespace, ".uuid")) || '';
},

@@ -89,0 +83,0 @@ getRootPutinReducers: function getRootPutinReducers() {

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,27 +6,37 @@ Object.defineProperty(exports, "__esModule", {

});
exports.createRefectStore = exports.configureRefect = exports.parseTasksActions = exports.createRefectEnhancer = undefined;
Object.defineProperty(exports, "createRefectEnhancer", {
enumerable: true,
get: function get() {
return _enhancer.default;
}
});
Object.defineProperty(exports, "parseTasksActions", {
enumerable: true,
get: function get() {
return _parseRefect.parseTasksActions;
}
});
Object.defineProperty(exports, "configureRefect", {
enumerable: true,
get: function get() {
return _configureRefect.default;
}
});
Object.defineProperty(exports, "createRefectStore", {
enumerable: true,
get: function get() {
return _createRefectStore.default;
}
});
var _enhancer = require('./enhancer');
var _enhancer = _interopRequireDefault(require("./enhancer"));
var _enhancer2 = _interopRequireDefault(_enhancer);
var _middleware = _interopRequireDefault(require("./middleware"));
var _middleware = require('./middleware');
var _parseRefect = require("./parseRefect");
var _middleware2 = _interopRequireDefault(_middleware);
var _configureRefect = _interopRequireDefault(require("./configureRefect"));
var _parseRefect = require('./parseRefect');
var _createRefectStore = _interopRequireDefault(require("./createRefectStore"));
var _configureRefect = require('./configureRefect');
var _configureRefect2 = _interopRequireDefault(_configureRefect);
var _createRefectStore = require('./createRefectStore');
var _createRefectStore2 = _interopRequireDefault(_createRefectStore);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.createRefectEnhancer = _enhancer2.default;
exports.parseTasksActions = _parseRefect.parseTasksActions;
exports.configureRefect = _configureRefect2.default;
exports.createRefectStore = _createRefectStore2.default;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,15 +6,23 @@ Object.defineProperty(exports, "__esModule", {

});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
exports.isActionCreator = isActionCreator;
exports.defaultMatcher = defaultMatcher;
exports.defaultWorker = defaultWorker;
exports.default = void 0;
var _utils = require('../utils');
var _utils = require("../utils");
var _parseRefect = require('./parseRefect');
var _parseRefect = require("./parseRefect");
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function isActionCreator(actionCreator) {

@@ -49,7 +57,7 @@ return actionCreator && _utils.is.func(actionCreator) && actionCreator.type;

for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return task.apply(undefined, args);
return task.apply(void 0, args);
}

@@ -59,3 +67,2 @@

// watch pattern should auto support namespace
if (_utils.is.string(pattern)) {

@@ -77,3 +84,2 @@ return (0, _utils.getActionType)(pattern, namespace);

var worker = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultWorker;
var listeners = [];

@@ -90,7 +96,5 @@ var effectsStore = null;

var result = next(action);
listeners.forEach(function (listener) {
listener(action);
});
return result;

@@ -102,3 +106,3 @@ };

function subscribe(pattern, task) {
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
args[_key2 - 2] = arguments[_key2];

@@ -110,11 +114,8 @@ }

var payload = action.payload;
(0, _utils.check)(_utils.is.undef(payload) || _utils.is.array(payload), 'action in worker is not a refect action!');
worker.apply(undefined, [task].concat(args, _toConsumableArray(payload || [])));
worker.apply(void 0, [task].concat(args, _toConsumableArray(payload || [])));
}
}
listeners.push(listener);
return function () {

@@ -137,5 +138,3 @@ var index = listeners.indexOf(listener);

var store = getStore();
(0, _utils.check)(store, 'refect-thunk middleware not registerred yet!');
var state = store.getState();

@@ -148,4 +147,3 @@

(0, _utils.check)(_utils.is.string(path) || _utils.is.number(path), 'path should be a stirng or number');
return (0, _utils.get)(state, namespace + '.' + path);
return (0, _utils.get)(state, "".concat(namespace, ".").concat(path));
},

@@ -155,3 +153,3 @@ dispatch: function dispatch(action) {

for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
args[_key3 - 1] = arguments[_key3];

@@ -170,7 +168,7 @@ }

for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
args[_key4 - 1] = arguments[_key4];
}
return getStore().dispatch(action.apply(undefined, args));
return getStore().dispatch(action.apply(void 0, args));
},

@@ -180,7 +178,7 @@ watch: function watch(pattern, task) {

for (var _len5 = arguments.length, args = Array(_len5 > 2 ? _len5 - 2 : 0), _key5 = 2; _key5 < _len5; _key5++) {
for (var _len5 = arguments.length, args = new Array(_len5 > 2 ? _len5 - 2 : 0), _key5 = 2; _key5 < _len5; _key5++) {
args[_key5 - 2] = arguments[_key5];
}
return subscribe.apply(undefined, [wrapPattern(pattern, namespace), task].concat(args));
return subscribe.apply(void 0, [wrapPattern(pattern, namespace), task].concat(args));
},

@@ -190,7 +188,7 @@ done: function done(actionCreator) {

for (var _len6 = arguments.length, args = Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
args[_key6 - 1] = arguments[_key6];
}
return worker.apply(undefined, [actionCreator.task].concat(args));
return worker.apply(void 0, [actionCreator.task].concat(args));
}

@@ -205,14 +203,15 @@ };

effectors = _ref.effectors;
var taskActionCreators = (0, _parseRefect.parseTasksActions)(refectTasks, namespace);
var coreEffects = getEffects(namespace, getActions);
var currEffectors = [].concat(_toConsumableArray(rootEffectors), _toConsumableArray(effectors));
var customEffects = currEffectors.reduce(function (result, effector) {
var currPlugins = effector({ getActions: getActions, namespace: namespace, getStore: getStore });
return _extends({}, result, currPlugins);
var currPlugins = effector({
getActions: getActions,
namespace: namespace,
getStore: getStore
});
return _objectSpread({}, result, currPlugins);
}, {});
var finalEffects = _extends({}, coreEffects, customEffects);
var finalEffects = _objectSpread({}, coreEffects, customEffects);

@@ -226,10 +225,7 @@ return (0, _utils.map)(taskActionCreators, function (actionCreator, actionName) {

var task = taskMap[actionName];
return task.apply(undefined, arguments);
return task.apply(void 0, arguments);
};
subscribe(actionCreator.type, finalTask);
actionCreator.task = finalTask;
return actionCreator;

@@ -242,2 +238,3 @@ });

exports.default = createTaskMiddleware;
var _default = createTaskMiddleware;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,5 +6,2 @@ Object.defineProperty(exports, "__esModule", {

});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
exports.combineRefectReducer = combineRefectReducer;

@@ -16,8 +13,18 @@ exports.parseRefectEffects = parseRefectEffects;

var _utils = require('../utils');
var _utils = require("../utils");
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function combineRefectReducer() {
for (var _len = arguments.length, refectReducers = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, refectReducers = new Array(_len), _key = 0; _key < _len; _key++) {
refectReducers[_key] = arguments[_key];

@@ -30,5 +37,4 @@ }

});
return refectReducerMaps.reduce(function (finalMap, refectReducerMap) {
return _extends({}, finalMap, refectReducerMap);
return _objectSpread({}, finalMap, refectReducerMap);
}, {});

@@ -48,3 +54,2 @@ };

});
return {

@@ -58,5 +63,3 @@ effectors: effectors,

var namespace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var tasks = refectTasks({}, {});
var actionCreators = (0, _utils.map)(tasks, function (task, taskName) {

@@ -66,3 +69,3 @@ var type = (0, _utils.getActionType)(taskName, namespace);

function actionCreator() {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];

@@ -72,3 +75,6 @@ }

if (task.length) {
return { type: type, payload: args };
return {
type: type,
payload: args
};
}

@@ -84,3 +90,2 @@

});
return actionCreators;

@@ -91,6 +96,4 @@ }

var namespace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var mockState = {};
var refectReducerMap = refectReducer(mockState, (0, _utils.getManager)(mockState));
return (0, _utils.map)(refectReducerMap, function (reducer, actionCreatorName) {

@@ -100,3 +103,3 @@ var type = (0, _utils.getActionType)(actionCreatorName, namespace);

function actionCreator() {
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];

@@ -112,7 +115,8 @@ }

return { type: type };
return {
type: type
};
}
actionCreator.type = type;
return actionCreator;

@@ -125,4 +129,3 @@ });

var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
var action = arguments[1];
var action = arguments.length > 1 ? arguments[1] : undefined;
var manager = (0, _utils.getManager)(state);

@@ -137,3 +140,2 @@ var freshRefectReducerMap = refectReducer(state, manager);

var payload = action.payload;
var currentReducer = (0, _utils.get)(freshRefectReducerMap, funcName);

@@ -143,3 +145,3 @@ (0, _utils.check)(_utils.is.func(currentReducer), 'currentReducer is not a function');

if (payload) {
return currentReducer.apply(undefined, _toConsumableArray(payload));
return currentReducer.apply(void 0, _toConsumableArray(payload));
}

@@ -146,0 +148,0 @@

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,8 +6,16 @@ Object.defineProperty(exports, "__esModule", {

});
exports.curry = exports.placeholder = void 0;
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
var placeholder = exports.placeholder = {
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var placeholder = {
'@@functional/placeholder': true
};
exports.placeholder = placeholder;

@@ -24,3 +32,3 @@ var isPlaceHolder = function isPlaceHolder(val) {

return fn.apply(undefined, arguments);
return fn.apply(void 0, arguments);
};

@@ -35,3 +43,3 @@ };

return curry0(function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];

@@ -45,7 +53,7 @@ }

if (argsLength >= n) {
return fn.apply(undefined, args);
return fn.apply(void 0, args);
}
return curryN(n - argsLength, curry0(function () {
for (var _len2 = arguments.length, restArgs = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
for (var _len2 = arguments.length, restArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
restArgs[_key2] = arguments[_key2];

@@ -57,4 +65,3 @@ }

});
return fn.apply(undefined, _toConsumableArray(newArgs).concat(restArgs));
return fn.apply(void 0, _toConsumableArray(newArgs).concat(restArgs));
}));

@@ -64,4 +71,6 @@ });

var curry = exports.curry = function curry(fn) {
var curry = function curry(fn) {
return curryN(fn.length, fn);
};
};
exports.curry = curry;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,10 +6,31 @@ Object.defineProperty(exports, "__esModule", {

});
exports.createTaskMiddleware = exports.createRefectEnhancer = exports.parseTasksActions = exports.createRefectStore = undefined;
Object.defineProperty(exports, "createRefectStore", {
enumerable: true,
get: function get() {
return _core.createRefectStore;
}
});
Object.defineProperty(exports, "parseTasksActions", {
enumerable: true,
get: function get() {
return _core.parseTasksActions;
}
});
Object.defineProperty(exports, "createRefectEnhancer", {
enumerable: true,
get: function get() {
return _core.createRefectEnhancer;
}
});
Object.defineProperty(exports, "createTaskMiddleware", {
enumerable: true,
get: function get() {
return _core.createTaskMiddleware;
}
});
exports.default = void 0;
var _core = require('./core/');
var _core = require("./core/");
exports.default = _core.configureRefect;
exports.createRefectStore = _core.createRefectStore;
exports.parseTasksActions = _core.parseTasksActions;
exports.createRefectEnhancer = _core.createRefectEnhancer;
exports.createTaskMiddleware = _core.createTaskMiddleware;
var _default = _core.configureRefect;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,8 +6,2 @@ Object.defineProperty(exports, "__esModule", {

});
exports.noOp = exports.defaultRefectTasks = exports.is = exports.identity = exports.placeholder = exports.curry = undefined;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.check = check;

@@ -25,13 +19,40 @@ exports.map = map;

exports.getManager = getManager;
Object.defineProperty(exports, "curry", {
enumerable: true,
get: function get() {
return _curry.curry;
}
});
Object.defineProperty(exports, "placeholder", {
enumerable: true,
get: function get() {
return _curry.placeholder;
}
});
exports.noOp = exports.defaultRefectTasks = exports.is = exports.identity = void 0;
var _curry = require('./curry');
var _curry = require("./curry");
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
exports.curry = _curry.curry;
exports.placeholder = _curry.placeholder;
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function check(isPredicated, error) {

@@ -43,7 +64,8 @@ if (!isPredicated) {

var identity = exports.identity = function identity(el) {
var identity = function identity(el) {
return el;
};
var is = exports.is = {
exports.identity = identity;
var is = {
func: function func(origin) {

@@ -59,3 +81,3 @@ return typeof origin === 'function';

object: function object(origin) {
return !!(origin && !is.array(origin) && (typeof origin === 'undefined' ? 'undefined' : _typeof(origin)) === 'object');
return !!(origin && !is.array(origin) && _typeof(origin) === 'object');
},

@@ -68,13 +90,12 @@ undef: function undef(origin) {

}
};
}; // object mapper
// object mapper
exports.is = is;
function map(data, mapper) {
check(is.object(data), 'refect/utils/map: data should be an plain object');
check(is.func(mapper), 'refect/utils/map: mapper should be a function');
return Object.keys(data).reduce(function (result, key) {
var value = data[key];
return _extends({}, result, _defineProperty({}, key, mapper(value, key)));
return _objectSpread({}, result, _defineProperty({}, key, mapper(value, key)));
}, {});

@@ -138,6 +159,4 @@ }

check(isNumberStr(path), 'set an array with a key of string!');
var index = Number(path);
var validData = data || [];
check(index <= validData.length, 'array length smaller than index');

@@ -150,6 +169,6 @@

return validData.slice(0, index).concat([value]).concat(validData.slice(index + 1));
}
} // object
// object
return _extends({}, data, _defineProperty({}, path, value));
return _objectSpread({}, data, _defineProperty({}, path, value));
}

@@ -164,3 +183,2 @@

var fpathValue = set(cData, paths.join('.'), value);
return set(data, fpath, fpathValue);

@@ -172,6 +190,4 @@ }

check(is.string(path) || is.number(path), 'refect/utils/update: path should be string or number');
var value = get(data, path);
var newValue = updator(value);
return set(data, path, newValue);

@@ -193,3 +209,3 @@ }

var pathData = data[path],
rest = _objectWithoutProperties(data, [path]);
rest = _objectWithoutProperties(data, [path].map(_toPropertyKey));

@@ -208,8 +224,7 @@ return rest;

return set(data, purePath, omit(pureData, lastPath));
}
} // traverse leaf node of an object
// traverse leaf node of an object
function traverse(data, visitor) {
var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
check(is.func(visitor), 'refect/utils/traverse: visitor should be a function');

@@ -222,4 +237,3 @@

return map(data, function (currData, dataPath) {
var currPath = path ? path + '.' + dataPath : dataPath;
var currPath = path ? "".concat(path, ".").concat(dataPath) : dataPath;
return traverse(currData, visitor, currPath);

@@ -233,3 +247,2 @@ });

check(is.string(actionType), 'refect/utils/parseActionType: actionType should be a string');
var actionTypePath = actionType.replace(/\//g, '.');

@@ -247,4 +260,6 @@ var namespaceEndPos = actionTypePath.lastIndexOf('.');

var name = actionTypePath.slice(namespaceEndPos + 1);
return { namespace: namespace, name: name };
return {
namespace: namespace,
name: name
};
}

@@ -256,7 +271,11 @@

var defaultRefectTasks = exports.defaultRefectTasks = function defaultRefectTasks() {
var defaultRefectTasks = function defaultRefectTasks() {
return {};
};
var noOp = exports.noOp = function noOp() {};
exports.defaultRefectTasks = defaultRefectTasks;
var noOp = function noOp() {};
exports.noOp = noOp;
var hasOwnProperty = Object.prototype.hasOwnProperty;

@@ -270,3 +289,2 @@

});
return target;

@@ -278,4 +296,5 @@ }

check(is.func(action), 'refect/utils/deepBindActions: action ' + action + 'is not a function');
var boundAction = function boundAction() {
return dispatch(action.apply(undefined, arguments));
return dispatch(action.apply(void 0, arguments));
};

@@ -289,3 +308,3 @@

function setState() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];

@@ -297,5 +316,4 @@ }

if (is.object(pathOrMutation)) {
return _extends({}, state, pathOrMutation);
return _objectSpread({}, state, pathOrMutation);
}

@@ -302,0 +320,0 @@

{
"name": "refect",
"version": "0.1.1",
"version": "1.0.0",
"description": "",

@@ -9,3 +9,3 @@ "main": "lib/index.js",

"build": "rm -rf lib && babel src --out-dir lib",
"demo": "webpack-dev-server --progress --port 3030 --colors --content-base demos --hot --inline --config demos/webpack.config.js",
"demo": "node_modules/.bin/webpack-dev-server --progress --port 3030 --colors --content-base demos --hot --inline --config demos/webpack.config.js",
"autofix": "eslint src --fix",

@@ -38,44 +38,44 @@ "lint": "eslint src",

"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-decorators": "^7.2.3",
"@babel/polyfill": "^7.2.5",
"@babel/preset-env": "^7.2.3",
"@babel/preset-react": "^7.0.0",
"@babel/preset-stage-0": "^7.0.0",
"antd": "^2.6.1",
"babel": "^6.5.2",
"babel-cli": "^6.18.0",
"babel-core": "^6.21.0",
"babel-eslint": "^6.1.0",
"babel-loader": "^6.2.10",
"babel-plugin-import": "^1.1.0",
"babel-plugin-module-alias": "^1.6.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-polyfill": "^6.20.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"css-loader": "^0.26.1",
"eslint": "^2.9.0",
"eslint-config-airbnb": "^9.0.1",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.4",
"css-loader": "^2.1.0",
"eslint": "^5.11.0",
"eslint-config-airbnb": "^17.0.1",
"eslint-plugin-import": "^1.7.0",
"eslint-plugin-jsx-a11y": "^1.5.0",
"eslint-plugin-react": "^5.2.0",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.0.0",
"karma-coveralls": "^1.1.2",
"eslint-plugin-jsx-a11y": "^6.1.0",
"eslint-plugin-react": "^7.12.0",
"karma": "^3.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.0",
"karma-coveralls": "^2.1.0",
"karma-mocha": "^1.3.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.8.0",
"mocha": "^3.1.0",
"node-sass": "^3.8.0",
"karma-webpack": "^3.0.0",
"mocha": "^5.2.0",
"node-sass": "^4.0.0",
"pre-commit": "^1.2.2",
"react": "^15.4.2",
"react-dom": "^15.4.1",
"react-hot-loader": "^3.0.0-beta.6",
"react-redux": "^5.0.3",
"react": "^16",
"react-dom": "^16",
"react-hot-loader": "^4.6.3",
"react-redux": "^6.0.0",
"react-refect": "^0.1.2",
"redux": "^3.6.0",
"redux-logger": "^2.7.4",
"redux-saga": "^0.13.0",
"sass-loader": "^3.2.0",
"sinon": "^1.17.7",
"style-loader": "^0.13.1",
"webpack": "^1.14.0",
"webpack-dev-server": "^1.16.2"
"redux-saga": "^0.16.0",
"refect-saga-middleware": "0.1.0-alpha.0",
"sass-loader": "^7.0.0",
"sinon": "^7.2.0",
"style-loader": "^0.23.1",
"webpack": "^4.0.0",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.0"
}
}

@@ -5,3 +5,3 @@ import createRefectEnhancer from './enhancer';

import { combineRefectReducer, parseRefectEffects } from './parseRefect';
import { identity } from 'utils';
import { identity } from '../utils';

@@ -8,0 +8,0 @@ const defaultCustom = () => ({});

@@ -1,2 +0,2 @@

import { get, set, check, parseActionType, identity, omit } from 'utils';
import { get, set, check, parseActionType, identity, omit } from '../utils';
import { parseRefectActions, parseRefectReducer } from './parseRefect';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

import { get, getActionType, is, check, map, deepBindActions } from 'utils';
import { get, getActionType, is, check, map, deepBindActions } from '../utils';
import { parseTasksActions } from './parseRefect';

@@ -3,0 +3,0 @@

import { parseActionType, getActionType, map, check, is,
defaultRefectTasks, noOp, get, assign, getManager } from 'utils';
defaultRefectTasks, noOp, get, assign, getManager } from '../utils';

@@ -4,0 +4,0 @@ export function combineRefectReducer(...refectReducers) {

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