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

redux-promise-middleware

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-promise-middleware - npm Package Compare versions

Comparing version 4.4.0 to 4.4.1

dist/es/index.js

52

dist/index.js

@@ -37,2 +37,3 @@ 'use strict';

var promiseTypeSuffixes = config.promiseTypeSuffixes || defaultTypes;
var promiseTypeSeparator = config.promiseTypeSeparator || '_';

@@ -76,3 +77,3 @@ return function (ref) {

return _extends({
type: type + '_' + (isRejected ? _REJECTED : _FULFILLED)
type: [type, isRejected ? _REJECTED : _FULFILLED].join(promiseTypeSeparator)
}, newPayload === null || typeof newPayload === 'undefined' ? {} : {

@@ -108,25 +109,19 @@ payload: newPayload

next(_extends({
type: type + '_' + _PENDING
type: [type, _PENDING].join(promiseTypeSeparator)
}, data !== undefined ? { payload: data } : {}, meta !== undefined ? { meta: meta } : {}));
/*
* @function transformFulfill
* @description Transforms a fulfilled value into a success object.
* @function handleReject
* @description Dispatch the rejected action and return
* an error object. The error object is the original error
* that was thrown. The user of the library is responsible for
* best practices in ensure that they are throwing an Error object.
* @params reason The reason the promise was rejected
* @returns {object}
*/
var transformFulfill = function transformFulfill() {
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var resolvedAction = getAction(value, false);
return { value: value, action: resolvedAction };
};
/*
* @function handleReject
* @description Dispatch the rejected action.
* @returns {void}
*/
var handleReject = function handleReject(reason) {
var rejectedAction = getAction(reason, true);
dispatch(rejectedAction);
throw reason;
};

@@ -136,8 +131,15 @@

* @function handleFulfill
* @description Dispatch the fulfilled action.
* @param successValue The value from transformFulfill
* @returns {void}
* @description Dispatch the fulfilled action and
* return the success object. The success object should
* contain the value and the dispatched action.
* @param value The value the promise was resloved with
* @returns {object}
*/
var handleFulfill = function handleFulfill(successValue) {
dispatch(successValue.action);
var handleFulfill = function handleFulfill() {
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var resolvedAction = getAction(value, false);
dispatch(resolvedAction);
return { value: value, action: resolvedAction };
};

@@ -174,9 +176,3 @@

*/
var promiseValue = promise.then(transformFulfill);
var sideEffects = promiseValue.then(handleFulfill, handleReject);
return sideEffects.then(function () {
return promiseValue;
}, function () {
return promiseValue;
});
return promise.then(handleFulfill, handleReject);
};

@@ -183,0 +179,0 @@ };

{
"name": "redux-promise-middleware",
"version": "4.4.0",
"description": "Redux middleware for promises and optimistic updates",
"description": "Redux middleware for handling promises and optimistic updates",
"version": "4.4.1",
"main": "dist/index.js",

@@ -11,3 +11,3 @@ "module": "dist/es/index.js",

"prebuild": "npm run test",
"build": "npm run build-commonjs & npm run build-es & npm run build-umd & npm run build-umd-min",
"build": "rm -rf dist & npm run build-commonjs & npm run build-es & npm run build-umd & npm run build-umd-min",
"build-es": "BABEL_ENV=es `npm bin`/babel src -d dist/es",

@@ -14,0 +14,0 @@ "build-commonjs": "`npm bin`/babel src -d dist",

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