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 2.4.0 to 2.5.0

28

dist/index.js

@@ -15,3 +15,10 @@ 'use strict';

var defaultTypes = ['PENDING', 'FULFILLED', 'REJECTED'];
var PENDING = 'PENDING';
exports.PENDING = PENDING;
var FULFILLED = 'FULFILLED';
exports.FULFILLED = FULFILLED;
var REJECTED = 'REJECTED';
exports.REJECTED = REJECTED;
var defaultTypes = [PENDING, FULFILLED, REJECTED];
var IS_ERROR = true;

@@ -41,5 +48,5 @@

var PENDING = _ref2[0];
var FULFILLED = _ref2[1];
var REJECTED = _ref2[2];
var _PENDING = _ref2[0];
var _FULFILLED = _ref2[1];
var _REJECTED = _ref2[2];

@@ -51,3 +58,3 @@ /**

next(_extends({
type: type + '_' + PENDING
type: type + '_' + _PENDING
}, !data ? {} : { payload: data }, !meta ? {} : { meta: meta }));

@@ -58,6 +65,7 @@

};
var getPartialAction = function getPartialAction(isError) {
return _extends({
type: type + '_' + (isError ? REJECTED : FULFILLED)
}, !meta ? {} : { meta: meta }, !isError ? {} : { error: true });
type: type + '_' + (isError ? _REJECTED : _FULFILLED)
}, meta === undefined ? {} : { meta: meta }, !isError ? {} : { error: true });
};

@@ -74,3 +82,3 @@

var resolveAction = getPartialAction();
dispatch(isThunk(resolved) ? resolved.bind(null, resolveAction) : _extends({}, resolveAction, !resolved ? {} : { payload: resolved }));
dispatch(isThunk(resolved) ? resolved.bind(null, resolveAction) : _extends({}, resolveAction, resolved === undefined ? {} : { payload: resolved }));
}, function () {

@@ -80,3 +88,3 @@ var rejected = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

var rejectedAction = getPartialAction(IS_ERROR);
dispatch(isThunk(rejected) ? rejected.bind(null, rejectedAction) : _extends({}, rejectedAction, !rejected ? {} : { payload: rejected }));
dispatch(isThunk(rejected) ? rejected.bind(null, rejectedAction) : _extends({}, rejectedAction, rejected === undefined ? {} : { payload: rejected }));
})['catch'](function (error) {

@@ -95,3 +103,1 @@ return(

}
module.exports = exports['default'];
{
"name": "redux-promise-middleware",
"version": "2.4.0",
"version": "2.5.0",
"description": "Redux middleware for handling promises",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -109,3 +109,8 @@ # Redux Promise Middleware

The default promise status suffix can be imported from this module.
```js
import { PENDING, FULFILLED, REJECTED } from 'redux-promise-middleware'
```
---
Licensed MIT. Copyright 2015 Patrick Burtchaell.

@@ -6,3 +6,3 @@ import chai, { expect } from 'chai';

import configureStore from 'redux-mock-store';
import promiseMiddleware from '../src';
import promiseMiddleware, { PENDING, FULFILLED, REJECTED } from '../src';
chai.use(sinonChai);

@@ -13,2 +13,8 @@

it(`exports the default types`, () => {
expect(PENDING).to.eql('PENDING');
expect(FULFILLED).to.eql('FULFILLED');
expect(REJECTED).to.eql('REJECTED');
});
it('must return a function to handle next', () => {

@@ -146,3 +152,3 @@ expect(nextHandler).to.be.a('function');

it('returns the new promise object', () => {
it('returns the original promise object from dispatch', () => {
expect(store.dispatch(promiseAction)).to.eql(promiseAction.payload.promise);

@@ -187,6 +193,7 @@ });

it('works when resolve is null', () => {
it('allows promise to reject resolve null', () => {
rejectingPromiseAction.payload.promise = Promise.reject(null);
rejectedAction = {
type: `${rejectingPromiseAction.type}_REJECTED`,
payload: null,
error: true

@@ -285,6 +292,7 @@ };

it('works when resolve is null', async () => {
it('allows payload to be null', async () => {
fulfillingPromiseAction.payload.promise = Promise.resolve(null);
fulfillingAction = {
type: `${fulfillingPromiseAction.type}_FULFILLED`
type: `${fulfillingPromiseAction.type}_FULFILLED`,
payload: null
};

@@ -291,0 +299,0 @@ await store.dispatch(fulfillingPromiseAction);

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