redux-promise-middleware-es3
Version:
Redux middleware for handling promises and optimistic updates with ES3 support
1 lines • 2.71 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ReduxPromiseMiddleware=e():t.ReduxPromiseMiddleware=e()}(this,function(){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},i=function(){function t(t,e){var r=[],o=!0,n=!1,u=void 0;try{for(var i,a=t[Symbol.iterator]();!(o=(i=a.next()).done)&&(r.push(i.value),!e||r.length!==e);o=!0);}catch(f){n=!0,u=f}finally{try{!o&&a["return"]&&a["return"]()}finally{if(n)throw u}}return r}return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=r(1),f=o(a),l=["PENDING","FULFILLED","REJECTED"];t.exports=function(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=t.promiseTypeSuffixes||l;return function(t){var r=t.dispatch;return function(t){return function(o){if(!o.payload)return t(o);if(!(0,f["default"])(o.payload)&&!(0,f["default"])(o.payload.promise))return t(o);var a=o.type,l=o.payload,c=o.meta,y=(c||{}).promiseTypeSuffixes||e,p=i(y,3),d=p[0],s=p[1],m=p[2],v=function(t,e){return u({type:a+"_"+(e?m:s)},t?{payload:t}:{},c?{meta:c}:{},e?{error:!0}:{})},b=void 0,h=void 0;(0,f["default"])(o.payload)||"object"!==n(o.payload)?(b=l,h=null):(b=l.promise,h=l.data),t(u({type:a+"_"+d},h?{payload:h}:{},c?{meta:c}:{}));var x=function(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=v(t,!0);r(e);var o=t instanceof Error?t:new Error;throw o.reason=t,o.action=e,o},S=function(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=v(t,!1);return r(e),{value:t,action:e}};return b.then(S,x)}}}}},function(t,e){"use strict";function r(t){return null!==t&&"object"===("undefined"==typeof t?"undefined":o(t))&&(t&&"function"==typeof t.then)}Object.defineProperty(e,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t};e["default"]=r}])});