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.0.8 to 3.1.0

28

build.js

@@ -145,7 +145,7 @@ 'use strict';

var nilAction = createAction("NIL")();
var scopedAction = createAction("scopedAction");
function scopeReducer(scope, reducer) {
return function (state, action) {
if (!action || !action.meta || action.meta.scope !== scope) return reducer(state, nilAction);
if (action.type === scopedAction.type && action.meta.scope === scope) action = action.payload;

@@ -157,5 +157,23 @@ return reducer(state, action);

function scopeAction(scope, action) {
return function (payload) {
var meta = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
return action(payload, Object.assign({}, meta, { scope: scope }));
function wrapResult(result) {
if (typeof result === 'function') return function (dispatch, getState) {
return result(function (action) {
return dispatch(wrapResult(action));
}, getState);
};
if (typeof result.then === 'function') return result.then(function (r) {
return wrapResult(r);
});
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));
};

@@ -162,0 +180,0 @@ }

@@ -100,8 +100,8 @@ import Immutable from 'seamless-immutable'

const nilAction = createAction("NIL")();
const scopedAction = createAction("scopedAction");
export function scopeReducer(scope, reducer) {
return (state, action) => {
if (!action || !action.meta || action.meta.scope !== scope)
return reducer(state, nilAction);
if (action.type === scopedAction.type && action.meta.scope === scope)
action = action.payload

@@ -113,3 +113,16 @@ return reducer(state, action);

export function scopeAction(scope, action) {
return (payload, meta = {}) => action(payload, Object.assign({}, meta, { scope }))
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));
}

@@ -116,0 +129,0 @@

2

package.json
{
"name": "@eknkc/dux",
"version": "3.0.8",
"version": "3.1.0",
"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