Socket
Socket
Sign inDemoInstall

@eknkc/dux

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eknkc/dux - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

80

build.js

@@ -16,5 +16,2 @@ 'use strict';

exports.bindActions = bindActions;
exports.scopeReducer = scopeReducer;
exports.scopeAction = scopeAction;
exports.scopeActions = scopeActions;

@@ -127,74 +124,23 @@ var _seamlessImmutable = require('seamless-immutable');

function bindActions(actions, dispatch, meta) {
if (typeof actions === 'function') return bindAction(actions, dispatch, meta);
return wrapActions(actions, bindAction, dispatch, meta);
}
if ((typeof actions === 'undefined' ? 'undefined' : _typeof(actions)) !== 'object' || actions === null) throw new Error("Action creators must be a function.");
var keys = Object.keys(actions);
var bound = {};
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (key === 'default') continue;
var action = actions[key];
if (typeof action === 'function') {
bound[key] = bindAction(action, dispatch, meta);
} else if ((typeof action === 'undefined' ? 'undefined' : _typeof(action)) === 'object') {
bound[key] = bindActions(action, dispatch, meta);
}
function wrapActions(actions, wrapper) {
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
args[_key2 - 2] = arguments[_key2];
}
return bound;
}
var scopedAction = createAction("scopedAction");
if (typeof actions === 'function') return wrapper.apply(undefined, [actions].concat(args));
function scopeReducer(scope, reducer) {
return function (state, action) {
if (action.type === scopedAction.type && action.meta.scope === scope) action = action.payload;
if ((typeof actions === 'undefined' ? 'undefined' : _typeof(actions)) !== 'object' || actions === null) throw new Error("Action creators must be a function.");
return reducer(state, action);
};
}
return Object.keys(actions).reduce(function (memo, key) {
if (key === 'default') return memo;
function scopeAction(scope, action) {
function wrapResult(result) {
if (typeof result === 'function') return function (dispatch, getState) {
return result(function (action) {
return dispatch(wrapResult(action));
}, getState);
};
var action = actions[key];
if (typeof result.then === 'function') return result.then(function (r) {
return wrapResult(r);
});
if (typeof action === 'function') memo[key] = wrapper.apply(undefined, [action].concat(args));else if ((typeof action === 'undefined' ? 'undefined' : _typeof(action)) === 'object') memo[key] = wrapActions.apply(undefined, [action, wrapper].concat(args));
return scopedAction(result, {
scope: scope,
logTransform: function logTransform() {
return Object.assign({}, result, { type: '[' + scope + '] ' + String(result.type) });
}
});
}
return function (payload, meta) {
return wrapResult(action(payload, meta));
};
return memo;
}, {});
}
function scopeActions(scope, actions) {
if (typeof actions === 'function') return scopeAction(scope, actions);
if ((typeof actions === 'undefined' ? 'undefined' : _typeof(actions)) !== 'object' || actions === null) throw new Error("Action creators must be a function.");
var keys = Object.keys(actions);
var scoped = {};
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (key === 'default') continue;
var action = actions[key];
if (typeof action === 'function') {
scoped[key] = scopeAction(scope, action);
} else if ((typeof action === 'undefined' ? 'undefined' : _typeof(action)) === 'object') {
scoped[key] = scopeActions(scope, action);
}
}
return scoped;
}

@@ -79,4 +79,8 @@ import Immutable from 'seamless-immutable'

export function bindActions(actions, dispatch, meta) {
return wrapActions(actions, bindAction, dispatch, meta);
}
function wrapActions(actions, wrapper, ...args) {
if (typeof actions === 'function')
return bindAction(actions, dispatch, meta)
return wrapper(actions, ...args)

@@ -86,65 +90,15 @@ if (typeof actions !== 'object' || actions === null)

var keys = Object.keys(actions)
var bound = {}
for (var i = 0; i < keys.length; i++) {
var key = keys[i]
if (key === 'default') continue;
var action = actions[key]
if (typeof action === 'function') {
bound[key] = bindAction(action, dispatch, meta)
} else if (typeof action === 'object') {
bound[key] = bindActions(action, dispatch, meta)
}
}
return bound
}
return Object.keys(actions).reduce((memo, key) => {
if (key === 'default')
return memo;
const scopedAction = createAction("scopedAction");
let action = actions[key];
export function scopeReducer(scope, reducer) {
return (state, action) => {
if (action.type === scopedAction.type && action.meta.scope === scope)
action = action.payload
if (typeof action === 'function')
memo[key] = wrapper(action, ...args)
else if (typeof action === 'object')
memo[key] = wrapActions(action, wrapper, ...args)
return reducer(state, action);
}
return memo;
}, {});
}
export function scopeAction(scope, action) {
function wrapResult(result) {
if (typeof result === 'function')
return (dispatch, getState) => result(action => dispatch(wrapResult(action)), getState)
if (typeof result.then === 'function')
return result.then(r => wrapResult(r));
return scopedAction(result, {
scope,
logTransform: () => Object.assign({}, result, { type: `[${scope}] ${String(result.type)}` })
});
}
return (payload, meta) => wrapResult(action(payload, meta));
}
export function scopeActions(scope, actions) {
if (typeof actions === 'function')
return scopeAction(scope, actions)
if (typeof actions !== 'object' || actions === null)
throw new Error("Action creators must be a function.")
var keys = Object.keys(actions)
var scoped = {}
for (var i = 0; i < keys.length; i++) {
var key = keys[i]
if (key === 'default') continue;
var action = actions[key]
if (typeof action === 'function') {
scoped[key] = scopeAction(scope, action)
} else if (typeof action === 'object') {
scoped[key] = scopeActions(scope, action)
}
}
return scoped
}

2

package.json
{
"name": "@eknkc/dux",
"version": "3.1.0",
"version": "3.1.1",
"description": "Redux helpers",

@@ -5,0 +5,0 @@ "main": "build.js",

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