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 5.1.1 to 6.0.0-beta.0

.gitattributes

49

dist/es/index.js

@@ -8,21 +8,20 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

/**
* Note to contributors: Please also remember to check and make sure
* that `index.d.ts` is also up to date with the implementation when
* you add new features or modify existing ones.
* For TypeScript support: Remember to check and make sure
* that `index.d.ts` is also up to date with the implementation.
*/
export var ActionType = {
Pending: 'PENDING',
Fulfilled: 'FULFILLED',
Rejected: 'REJECTED'
};
// The default async action types
export var PENDING = 'PENDING';
export var FULFILLED = 'FULFILLED';
export var REJECTED = 'REJECTED';
var defaultTypes = [PENDING, FULFILLED, REJECTED];
/**
* Function: promiseMiddleware
* Description: The main promiseMiddleware accepts a configuration
* Function: createPromise
* Description: The main createPromise accepts a configuration
* object and returns the middleware.
*/
export default function promiseMiddleware() {
export function createPromise() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var defaultTypes = [ActionType.Pending, ActionType.Fulfilled, ActionType.Rejected];
var PROMISE_TYPE_SUFFIXES = config.promiseTypeSuffixes || defaultTypes;

@@ -111,5 +110,5 @@ var PROMISE_TYPE_DELIMITER = config.promiseTypeDelimiter || '_';

var _PROMISE_TYPE_SUFFIXE = _slicedToArray(PROMISE_TYPE_SUFFIXES, 3),
_PENDING = _PROMISE_TYPE_SUFFIXE[0],
_FULFILLED = _PROMISE_TYPE_SUFFIXE[1],
_REJECTED = _PROMISE_TYPE_SUFFIXE[2];
PENDING = _PROMISE_TYPE_SUFFIXE[0],
FULFILLED = _PROMISE_TYPE_SUFFIXE[1],
REJECTED = _PROMISE_TYPE_SUFFIXE[2];

@@ -144,3 +143,3 @@ /**

// Concatentate the type string property.
type: [TYPE, isRejected ? _REJECTED : _FULFILLED].join(PROMISE_TYPE_DELIMITER)
type: [TYPE, isRejected ? REJECTED : FULFILLED].join(PROMISE_TYPE_DELIMITER)

@@ -192,3 +191,3 @@ }, newPayload === null || typeof newPayload === 'undefined' ? {} : {

// Concatentate the type string.
type: [TYPE, _PENDING].join(PROMISE_TYPE_DELIMITER)
type: [TYPE, PENDING].join(PROMISE_TYPE_DELIMITER)

@@ -205,2 +204,18 @@ }, data !== undefined ? { payload: data } : {}, META !== undefined ? { meta: META } : {}));

};
}
export default function middleware() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
dispatch = _ref.dispatch;
if (typeof dispatch === 'function') {
return createPromise()({ dispatch: dispatch });
}
if (process && process.env && (process.env.NODE_ENV === 'development' || 'test')) {
// eslint-disable-next-line no-console
console.warn('Redux Promise Middleware: As of version 6.0.0, the middleware library supports both preconfigured and custom configured middleware. To use a custom configuration, use the "createPromise" export and call this function with your configuration property. To use a preconfiguration, use the default export. For more help, check the upgrading guide: https://docs.psb.codes/redux-promise-middleware/upgrade-guides/v6\n\nFor custom configuration:\nimport { createPromise } from \'redux-promise-middleware\';\nconst promise = createPromise({ types: { fulfilled: \'success\' } });\napplyMiddleware(promise);\n\nFor preconfiguration:\nimport promise from \'redux-promise-middleware\';\napplyMiddleware(promise);\n ');
}
return null;
}

@@ -6,3 +6,3 @@ 'use strict';

});
exports.REJECTED = exports.FULFILLED = exports.PENDING = undefined;
exports.ActionType = undefined;

@@ -13,3 +13,4 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

exports.default = promiseMiddleware;
exports.createPromise = createPromise;
exports.default = middleware;

@@ -23,21 +24,20 @@ var _isPromise = require('./isPromise.js');

/**
* Note to contributors: Please also remember to check and make sure
* that `index.d.ts` is also up to date with the implementation when
* you add new features or modify existing ones.
* For TypeScript support: Remember to check and make sure
* that `index.d.ts` is also up to date with the implementation.
*/
var ActionType = exports.ActionType = {
Pending: 'PENDING',
Fulfilled: 'FULFILLED',
Rejected: 'REJECTED'
};
// The default async action types
var PENDING = exports.PENDING = 'PENDING';
var FULFILLED = exports.FULFILLED = 'FULFILLED';
var REJECTED = exports.REJECTED = 'REJECTED';
var defaultTypes = [PENDING, FULFILLED, REJECTED];
/**
* Function: promiseMiddleware
* Description: The main promiseMiddleware accepts a configuration
* Function: createPromise
* Description: The main createPromise accepts a configuration
* object and returns the middleware.
*/
function promiseMiddleware() {
function createPromise() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var defaultTypes = [ActionType.Pending, ActionType.Fulfilled, ActionType.Rejected];
var PROMISE_TYPE_SUFFIXES = config.promiseTypeSuffixes || defaultTypes;

@@ -126,5 +126,5 @@ var PROMISE_TYPE_DELIMITER = config.promiseTypeDelimiter || '_';

var _PROMISE_TYPE_SUFFIXE = _slicedToArray(PROMISE_TYPE_SUFFIXES, 3),
_PENDING = _PROMISE_TYPE_SUFFIXE[0],
_FULFILLED = _PROMISE_TYPE_SUFFIXE[1],
_REJECTED = _PROMISE_TYPE_SUFFIXE[2];
PENDING = _PROMISE_TYPE_SUFFIXE[0],
FULFILLED = _PROMISE_TYPE_SUFFIXE[1],
REJECTED = _PROMISE_TYPE_SUFFIXE[2];

@@ -159,3 +159,3 @@ /**

// Concatentate the type string property.
type: [TYPE, isRejected ? _REJECTED : _FULFILLED].join(PROMISE_TYPE_DELIMITER)
type: [TYPE, isRejected ? REJECTED : FULFILLED].join(PROMISE_TYPE_DELIMITER)

@@ -207,3 +207,3 @@ }, newPayload === null || typeof newPayload === 'undefined' ? {} : {

// Concatentate the type string.
type: [TYPE, _PENDING].join(PROMISE_TYPE_DELIMITER)
type: [TYPE, PENDING].join(PROMISE_TYPE_DELIMITER)

@@ -220,2 +220,18 @@ }, data !== undefined ? { payload: data } : {}, META !== undefined ? { meta: META } : {}));

};
}
function middleware() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
dispatch = _ref.dispatch;
if (typeof dispatch === 'function') {
return createPromise()({ dispatch: dispatch });
}
if (process && process.env && (process.env.NODE_ENV === 'development' || 'test')) {
// eslint-disable-next-line no-console
console.warn('Redux Promise Middleware: As of version 6.0.0, the middleware library supports both preconfigured and custom configured middleware. To use a custom configuration, use the "createPromise" export and call this function with your configuration property. To use a preconfiguration, use the default export. For more help, check the upgrading guide: https://docs.psb.codes/redux-promise-middleware/upgrade-guides/v6\n\nFor custom configuration:\nimport { createPromise } from \'redux-promise-middleware\';\nconst promise = createPromise({ types: { fulfilled: \'success\' } });\napplyMiddleware(promise);\n\nFor preconfiguration:\nimport promise from \'redux-promise-middleware\';\napplyMiddleware(promise);\n ');
}
return null;
}

@@ -76,3 +76,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ })

@@ -104,11 +104,201 @@ /************************************************************************/

/* 1 */
/***/ (function(module, exports) {
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.REJECTED = exports.FULFILLED = exports.PENDING = undefined;
exports.ActionType = undefined;

@@ -119,3 +309,4 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

exports.default = promiseMiddleware;
exports.createPromise = createPromise;
exports.default = middleware;

@@ -129,21 +320,20 @@ var _isPromise = __webpack_require__(0);

/**
* Note to contributors: Please also remember to check and make sure
* that `index.d.ts` is also up to date with the implementation when
* you add new features or modify existing ones.
* For TypeScript support: Remember to check and make sure
* that `index.d.ts` is also up to date with the implementation.
*/
var ActionType = exports.ActionType = {
Pending: 'PENDING',
Fulfilled: 'FULFILLED',
Rejected: 'REJECTED'
};
// The default async action types
var PENDING = exports.PENDING = 'PENDING';
var FULFILLED = exports.FULFILLED = 'FULFILLED';
var REJECTED = exports.REJECTED = 'REJECTED';
var defaultTypes = [PENDING, FULFILLED, REJECTED];
/**
* Function: promiseMiddleware
* Description: The main promiseMiddleware accepts a configuration
* Function: createPromise
* Description: The main createPromise accepts a configuration
* object and returns the middleware.
*/
function promiseMiddleware() {
function createPromise() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var defaultTypes = [ActionType.Pending, ActionType.Fulfilled, ActionType.Rejected];
var PROMISE_TYPE_SUFFIXES = config.promiseTypeSuffixes || defaultTypes;

@@ -232,5 +422,5 @@ var PROMISE_TYPE_DELIMITER = config.promiseTypeDelimiter || '_';

var _PROMISE_TYPE_SUFFIXE = _slicedToArray(PROMISE_TYPE_SUFFIXES, 3),
_PENDING = _PROMISE_TYPE_SUFFIXE[0],
_FULFILLED = _PROMISE_TYPE_SUFFIXE[1],
_REJECTED = _PROMISE_TYPE_SUFFIXE[2];
PENDING = _PROMISE_TYPE_SUFFIXE[0],
FULFILLED = _PROMISE_TYPE_SUFFIXE[1],
REJECTED = _PROMISE_TYPE_SUFFIXE[2];

@@ -265,3 +455,3 @@ /**

// Concatentate the type string property.
type: [TYPE, isRejected ? _REJECTED : _FULFILLED].join(PROMISE_TYPE_DELIMITER)
type: [TYPE, isRejected ? REJECTED : FULFILLED].join(PROMISE_TYPE_DELIMITER)

@@ -313,3 +503,3 @@ }, newPayload === null || typeof newPayload === 'undefined' ? {} : {

// Concatentate the type string.
type: [TYPE, _PENDING].join(PROMISE_TYPE_DELIMITER)
type: [TYPE, PENDING].join(PROMISE_TYPE_DELIMITER)

@@ -328,4 +518,21 @@ }, data !== undefined ? { payload: data } : {}, META !== undefined ? { meta: META } : {}));

function middleware() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
dispatch = _ref.dispatch;
if (typeof dispatch === 'function') {
return createPromise()({ dispatch: dispatch });
}
if (process && process.env && (process.env.NODE_ENV === 'development' || 'test')) {
// eslint-disable-next-line no-console
console.warn('Redux Promise Middleware: As of version 6.0.0, the middleware library supports both preconfigured and custom configured middleware. To use a custom configuration, use the "createPromise" export and call this function with your configuration property. To use a preconfiguration, use the default export. For more help, check the upgrading guide: https://docs.psb.codes/redux-promise-middleware/upgrade-guides/v6\n\nFor custom configuration:\nimport { createPromise } from \'redux-promise-middleware\';\nconst promise = createPromise({ types: { fulfilled: \'success\' } });\napplyMiddleware(promise);\n\nFor preconfiguration:\nimport promise from \'redux-promise-middleware\';\napplyMiddleware(promise);\n ');
}
return null;
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)))
/***/ })
/******/ ]);
});

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ReduxPromiseMiddleware=t():e.ReduxPromiseMiddleware=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t,r){"use strict";function n(e){return null!==e&&"object"===(void 0===e?"undefined":o(e))&&(e&&"function"==typeof e.then)}Object.defineProperty(t,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=n},function(e,t,r){"use strict";function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.promiseTypeSuffixes||p,r=e.promiseTypeDelimiter||"_";return function(e){var n=e.dispatch;return function(e){return function(u){var a=void 0,l=void 0;if(!u.payload)return e(u);var c=u.payload;if((0,f.default)(c))a=c;else if((0,f.default)(c.promise))a=c.promise,l=c.data;else{if("function"!=typeof c&&"function"!=typeof c.promise)return e(u);if(a=c.promise?c.promise():c(),l=c.promise?c.data:void 0,!(0,f.default)(a))return e(i({},u,{payload:a}))}var p=u.type,d=u.meta,y=o(t,3),s=y[0],v=y[1],m=y[2],b=function(e,t){return i({type:[p,t?m:v].join(r)},null===e||void 0===e?{}:{payload:e},void 0!==d?{meta:d}:{},t?{error:!0}:{})},E=function(e){var t=b(e,!0);throw n(t),e},h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=b(e,!1);return n(t),{value:e,action:t}};return e(i({type:[p,s].join(r)},void 0!==l?{payload:l}:{},void 0!==d?{meta:d}:{})),a.then(h,E)}}}}Object.defineProperty(t,"__esModule",{value:!0}),t.REJECTED=t.FULFILLED=t.PENDING=void 0;var o=function(){function e(e,t){var r=[],n=!0,o=!1,i=void 0;try{for(var u,f=e[Symbol.iterator]();!(n=(u=f.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{!n&&f.return&&f.return()}finally{if(o)throw i}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.default=n;var u=r(0),f=function(e){return e&&e.__esModule?e:{default:e}}(u),a=t.PENDING="PENDING",l=t.FULFILLED="FULFILLED",c=t.REJECTED="REJECTED",p=[a,l,c]}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ReduxPromiseMiddleware=t():e.ReduxPromiseMiddleware=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,r){"use strict";function n(e){return null!==e&&"object"===(void 0===e?"undefined":o(e))&&(e&&"function"==typeof e.then)}Object.defineProperty(t,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=n},function(e,t){function r(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function o(e){if(l===setTimeout)return setTimeout(e,0);if((l===r||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function i(e){if(s===clearTimeout)return clearTimeout(e);if((s===n||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(e);try{return s(e)}catch(t){try{return s.call(null,e)}catch(t){return s.call(this,e)}}}function u(){y&&p&&(y=!1,p.length?m=p.concat(m):h=-1,m.length&&c())}function c(){if(!y){var e=o(u);y=!0;for(var t=m.length;t;){for(p=m,m=[];++h<t;)p&&p[h].run();h=-1,t=m.length}p=null,y=!1,i(e)}}function a(e,t){this.fun=e,this.array=t}function f(){}var l,s,d=e.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:r}catch(e){l=r}try{s="function"==typeof clearTimeout?clearTimeout:n}catch(e){s=n}}();var p,m=[],y=!1,h=-1;d.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];m.push(new a(e,t)),1!==m.length||y||o(c)},a.prototype.run=function(){this.fun.apply(null,this.array)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={},d.on=f,d.addListener=f,d.once=f,d.off=f,d.removeListener=f,d.removeAllListeners=f,d.emit=f,d.prependListener=f,d.prependOnceListener=f,d.listeners=function(e){return[]},d.binding=function(e){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(e){throw new Error("process.chdir is not supported")},d.umask=function(){return 0}},function(e,t,r){"use strict";(function(e){function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[f.Pending,f.Fulfilled,f.Rejected],r=e.promiseTypeSuffixes||t,n=e.promiseTypeDelimiter||"_";return function(e){var t=e.dispatch;return function(e){return function(o){var c=void 0,f=void 0;if(!o.payload)return e(o);var l=o.payload;if((0,a.default)(l))c=l;else if((0,a.default)(l.promise))c=l.promise,f=l.data;else{if("function"!=typeof l&&"function"!=typeof l.promise)return e(o);if(c=l.promise?l.promise():l(),f=l.promise?l.data:void 0,!(0,a.default)(c))return e(u({},o,{payload:c}))}var s=o.type,d=o.meta,p=i(r,3),m=p[0],y=p[1],h=p[2],v=function(e,t){return u({type:[s,t?h:y].join(n)},null===e||void 0===e?{}:{payload:e},void 0!==d?{meta:d}:{},t?{error:!0}:{})},g=function(e){var r=v(e,!0);throw t(r),e},b=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=v(e,!1);return t(r),{value:e,action:r}};return e(u({type:[s,m].join(n)},void 0!==f?{payload:f}:{},void 0!==d?{meta:d}:{})),c.then(b,g)}}}}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.dispatch;return"function"==typeof r?n()({dispatch:r}):(e&&e.env&&(e.env.NODE_ENV,!0)&&console.warn("Redux Promise Middleware: As of version 6.0.0, the middleware library supports both preconfigured and custom configured middleware. To use a custom configuration, use the \"createPromise\" export and call this function with your configuration property. To use a preconfiguration, use the default export. For more help, check the upgrading guide: https://docs.psb.codes/redux-promise-middleware/upgrade-guides/v6\n\nFor custom configuration:\nimport { createPromise } from 'redux-promise-middleware';\nconst promise = createPromise({ types: { fulfilled: 'success' } });\napplyMiddleware(promise);\n\nFor preconfiguration:\nimport promise from 'redux-promise-middleware';\napplyMiddleware(promise);\n "),null)}Object.defineProperty(t,"__esModule",{value:!0}),t.ActionType=void 0;var i=function(){function e(e,t){var r=[],n=!0,o=!1,i=void 0;try{for(var u,c=e[Symbol.iterator]();!(n=(u=c.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{!n&&c.return&&c.return()}finally{if(o)throw i}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.createPromise=n,t.default=o;var c=r(0),a=function(e){return e&&e.__esModule?e:{default:e}}(c),f=t.ActionType={Pending:"PENDING",Fulfilled:"FULFILLED",Rejected:"REJECTED"}}).call(t,r(1))}])});
{
"name": "redux-promise-middleware",
"description": "Redux middleware for promises, async functions and conditional optimistic updates",
"version": "5.1.1",
"description": "Enables simple, yet robust handling of async action creators in Redux",
"version": "6.0.0-beta.0",
"main": "dist/index.js",
"types": "src/index.d.ts",
"module": "dist/es/index.js",
"scripts": {
"push-contributors": "./bin/push.sh",
"generate-lockfile": "rm -rf package-lock.json && synp --source-file ./yarn.lock",
"prepare": "npm run build",
"precommit": "echo 'Running pre-commit hooks...' && npm run test",
"prebuild": "npm run test",

@@ -19,9 +17,6 @@ "build": "rm -rf dist & npm run build-commonjs & npm run build-es & npm run build-umd & npm run build-umd-min",

"pretest": "npm run lint",
"test": "./bin/test.sh",
"lint": "`npm bin`/eslint src/**/*.js examples/**/*.js test/**/*.js",
"test": "`npm bin`/jest",
"lint": "`npm bin`/eslint src/**/*.js test/**/*.js",
"start": "babel-node examples/server.js"
},
"pre-commit": [
"precommit"
],
"repository": {

@@ -53,11 +48,8 @@ "type": "git",

"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.0.0",
"babel-polyfill": "^6.7.4",
"babel-preset-es2015": "^6.24.1",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"bluebird": "^3.5.0",
"chai": "^3.5.0",
"coveralls": "^2.13.1",

@@ -69,30 +61,16 @@ "eslint": "^3.19.0",

"eslint-plugin-react": "^6.7.1",
"express-urlrewrite": "^1.2.0",
"faker": "^4.1.0",
"github-contributors": "^0.4.1",
"isomorphic-fetch": "^2.2.1",
"istanbul": "^1.0.0-alpha.2",
"json-server": "^0.10.1",
"lodash": "^4.6.1",
"mocha": "^3.4.2",
"mocha-lcov-reporter": "^1.2.0",
"pre-commit": "^1.1.3",
"prop-types": "^15.6.0",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-redux": "^5.0.5",
"react-router": "3.0.5",
"jest": "^23.3.0",
"redux": "4.0.0",
"redux-logger": "^3.0.6",
"redux-mock-store": "^1.2.2",
"redux-thunk": "^2.0.1",
"sinon": "^2.3.4",
"sinon-chai": "^2.11.0",
"webpack": "^2.6.1",
"webpack-dev-middleware": "^1.10.2",
"webpack-hot-middleware": "^2.18.0"
"webpack": "^2.6.1"
},
"peerDependencies": {
"redux": "^2.0.0 || ^3.0.0 || ^4.0.0"
},
"jest": {
"verbose": true,
"moduleNameMapper": {
"redux-promise-middleware": "<rootDir>/src/index.js"
}
}
}
# Redux Promise Middleware
[![npm version](https://img.shields.io/npm/v/redux-promise-middleware.svg?style=flat)](https://www.npmjs.com/package/redux-promise-middleware) [![Build Status](https://travis-ci.org/pburtchaell/redux-promise-middleware.svg?branch=master)](https://travis-ci.org/pburtchaell/redux-promise-middleware) [![npm downloads](https://img.shields.io/npm/dm/redux-promise-middleware.svg?style=flat)](https://www.npmjs.com/package/redux-promise-middleware)
[![Build Status](https://travis-ci.org/pburtchaell/redux-promise-middleware.svg?branch=master)](https://travis-ci.org/pburtchaell/redux-promise-middleware) [![npm downloads](https://img.shields.io/npm/dm/redux-promise-middleware.svg?style=flat)](https://www.npmjs.com/package/redux-promise-middleware)
Redux promise middleware enables robust handling of async action creators in [Redux](http://redux.js.org): it accepts a promise and dispatches pending, fulfilled and rejected actions.
Redux Promise Middleware enables simple, yet robust handling of async action creators in [Redux](http://redux.js.org).
```js
const promiseAction = () => ({
const asyncAction = () => ({
type: 'PROMISE',
payload: Promise.resolve(),
payload: new Promise(...),
})
```
The middleware can also be combined with [Redux Thunk](https://github.com/gaearon/redux-thunk) to chain action creators.
Given a single action with an async payload, the middleware transforms the action to a separate a pending action and a separate fulfilled/rejected action, representing the states of the async action.
The middleware can be combined with [Redux Thunk](https://github.com/gaearon/redux-thunk) to chain action creators.
```js
const secondAction = (data) => ({
type: 'TWO',
payload: data,
type: 'SECOND',
payload: {...},
})
const first = () => {
const firstAction = () => {
return (dispatch) => {
const response = dispatch({
type: 'ONE',
payload: Promise.resolve(),
type: 'FIRST',
payload: new Promise(...),
})

@@ -37,3 +39,2 @@

## Documentation and Help
- [Introduction](/docs/introduction.md)

@@ -43,14 +44,17 @@ - [Guides](/docs/guides/)

## Issues and Pull Requests
**Heads Up:** Version 6 included changes to the public API. Check the [upgrading guide](docs/upgrading/v6.md) for help.
- [Contributing Guide](/.github/CONTRIBUTING.md)
- [Code of Conduct](/.github/CODE_OF_CONDUCT.md)
## Issues
For bug reports and feature requests, [file an issue on GitHub](https://github.com/pburtchaell/redux-promise-middleware/issues/new).
For help, [ask a question on StackOverflow](https://stackoverflow.com/questions/tagged/redux-promise-middleware).
## Releases
- [Release History](https://github.com/pburtchaell/redux-promise-middleware/releases)
- [Upgrade from 5.x to 6.0.0](docs/upgrading/v6.md)
- [Upgrade from 4.x to 5.0.0](docs/upgrading/v5.md)
- [Upgrade from 3.x to 4.0.0](docs/upgrading/v4.md)
- [Releases](https://github.com/pburtchaell/redux-promise-middleware/releases)
- [Version Upgrade Guide](/docs/upgrading.md)
**Older versions:**
For older versions:
- [5.x](https://github.com/pburtchaell/redux-promise-middleware/tree/5.0.1)
- [4.x](https://github.com/pburtchaell/redux-promise-middleware/tree/4.4.0)

@@ -62,12 +66,15 @@ - [3.x](https://github.com/pburtchaell/redux-promise-middleware/tree/3.3.0)

## Maintainers
Please reach out to us if you have any questions or comments.
- Patrick Burtchaell (pburtchaell):
- [Twitter](https://twitter.com/pburtchaell)
- [GitHub](https://github.com/pburtchaell)
- Thomas Hudspith-Tatham (tomatau):
- [GitHub](https://github.com/tomatau)
Patrick Burtchaell (pburtchaell):
- [Twitter](https://twitter.com/pburtchaell)
- [GitHub](https://github.com/pburtchaell)
Please reach out to us if you have any questions!
Thomas Hudspith-Tatham (tomatau):
- [GitHub](https://github.com/tomatau)
---
Copyright (c) 2015-Current Patrick Burtchaell. [Code licensed with the MIT License (MIT)](/LICENSE). [Documentation licensed with the CC BY-NC License](https://creativecommons.org/licenses/by-nc/4.0/).
## License
[Code licensed with the MIT License (MIT)](/LICENSE).
[Documentation licensed with the CC BY-NC License](https://creativecommons.org/licenses/by-nc/4.0/).
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