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 3.1.0 to 3.2.0

63

dist/index.js

@@ -106,2 +106,40 @@ 'use strict';

/*
* @function handleReject
* @description Dispatch the rejected action and return
* an error object. The error object should contain the
* reason and the dispatched action.
* @params reason The reason the promise was rejected
* @returns {object}
*/
var handleReject = function handleReject() {
var reason = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0];
var rejectedAction = getAction(reason, true);
dispatch(rejectedAction);
var error = new Error();
error.reason = reason;
error.action = rejectedAction;
return error;
};
/*
* @function handleFulfill
* @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() {
var value = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0];
var resolvedAction = getAction(value, false);
dispatch(resolvedAction);
return { value: value, action: resolvedAction };
};
/**

@@ -136,26 +174,3 @@ * Second, dispatch a rejected or fulfilled action. This flux standard

*/
return new Promise(function (resolve, reject) {
promise.then(function () {
var value = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0];
var resolvedAction = getAction(value, false);
dispatch(resolvedAction);
resolve({ value: value, action: resolvedAction });
return;
}, function () {
var reason = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0];
var rejectedAction = getAction(reason, true);
dispatch(rejectedAction);
var error = new Error();
error.reason = reason;
error.action = rejectedAction;
reject(error);
return;
});
});
return promise.then(handleFulfill, handleReject);
};

@@ -162,0 +177,0 @@ };

{
"name": "redux-promise-middleware",
"version": "3.1.0",
"version": "3.2.0",
"description": "Redux middleware for handling promises and optimistic updates",

@@ -47,2 +47,3 @@ "main": "dist/index.js",

"babel-preset-stage-0": "^6.5.0",
"bluebird": "^3.4.0",
"chai": "^3.5.0",

@@ -49,0 +50,0 @@ "coveralls": "^2.11.9",

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