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

redux-saga

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-saga - npm Package Compare versions

Comparing version 0.16.0 to 1.0.0-beta.0

es/internal/matcher.js

2

dist/redux-saga.min.js

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

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.ReduxSaga={})}(this,function(n){"use strict";function t(n,t,e){if(!t(n))throw c("error","uncaught at check",e),Error(e)}function e(n,t){return nn.notUndef(n)&&$.call(n,t)}function r(n,t){var e=n.indexOf(t);0>e||n.splice(e,1)}function o(){var n=H({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),t=new Promise(function(t,e){n.resolve=t,n.reject=e});return n.promise=t,n}function a(n){var t=1>=arguments.length||void 0===arguments[1]||arguments[1],e=void 0,r=new Promise(function(r){e=setTimeout(function(){return r(t)},n)});return r[X]=function(){return clearTimeout(e)},r}function u(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:on,e={name:arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",next:n,throw:t,return:an};return arguments[3]&&(e[z]=!0),"undefined"!=typeof Symbol&&(e[Symbol.iterator]=function(){return e}),e}function c(n,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";"undefined"==typeof window?console.log("redux-saga "+n+": "+t+"\n"+(e&&e.stack||e)):console[n](t,e)}function i(n,t){return function(){return n.apply(void 0,arguments)}}function f(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t=arguments[1],e=Array(n),r=0,o=0,a=0,u=function(t){e[o]=t,o=(o+1)%n,r++},c=function(){if(0!=r){var t=e[a];return e[a]=null,r--,a=(a+1)%n,t}},i=function(){for(var n=[];r;)n.push(c());return n};return{isEmpty:function(){return 0==r},put:function(c){if(n>r)u(c);else{var f=void 0;switch(t){case dn:throw Error(sn);case vn:e[o]=c,a=o=(o+1)%n;break;case gn:f=2*n,e=i(),r=e.length,o=e.length,a=0,e.length=f,n=f,u(c)}}},take:c,flush:i}}function l(n){try{d(),n()}finally{v()}}function s(n){yn.push(n),mn||(d(),g())}function d(){mn++}function v(){mn--}function g(){v();for(var n=void 0;!mn&&void 0!==(n=yn.shift());)l(n)}function h(){var n=[];return{subscribe:function(t){return n.push(t),function(){return r(n,t)}},emit:function(t){for(var e=n.slice(),r=0,o=e.length;o>r;r++)e[r](t)}}}function p(){function n(){if(o&&a.length)throw cn("Cannot have a closed channel with pending takers");if(a.length&&!e.isEmpty())throw cn("Cannot have pending takers with non empty buffer")}var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:pn.fixed(),o=!1,a=[];return t(e,nn.buffer,kn),{take:function(u){n(),t(u,nn.func,"channel.take's callback must be a function"),o&&e.isEmpty()?u(bn):e.isEmpty()?(a.push(u),u.cancel=function(){return r(a,u)}):u(e.take())},put:function(r){if(n(),t(r,nn.notUndef,Cn),!o){if(!a.length)return e.put(r);for(var u=0;a.length>u;u++){var c=a[u];if(!c[B]||c[B](r))return a.splice(u,1),c(r)}}},flush:function(r){n(),t(r,nn.func,"channel.flush' callback must be a function"),r(o&&e.isEmpty()?bn:e.flush())},close:function(){if(n(),!o&&(o=!0,a.length)){var t=a;a=[];for(var e=0,r=t.length;r>e;e++)t[e](bn)}},get __takers__(){return a},get __closed__(){return o}}}function y(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:pn.none(),r=arguments[2];arguments.length>2&&t(r,nn.func,"Invalid match function passed to eventChannel");var o=p(e),a=function(){o.__closed__||(u&&u(),o.close())},u=n(function(n){En(n)?a():r&&!r(n)||o.put(n)});if(o.__closed__&&u(),!nn.func(u))throw Error("in eventChannel: subscribe should return a function to unsubscribe");return{take:o.take,flush:o.flush,close:a}}function m(n){var e=y(function(t){return n(function(n){n[J]?t(n):s(function(){return t(n)})})});return H({},e,{take:function(n,r){arguments.length>1&&(t(r,nn.func,"channel.take's matcher argument must be a function"),n[B]=r),e.take(n)}})}function b(n){return nn.channel(n)?"channel":Array.isArray(n)?n.map(function(n){return n+""})+"":n+""}function E(n,t){function e(t,e){if(o===An)return _n;if(e)throw o=An,e;r&&r(t);var a=n[o](),u=a[0],c=a[1];return o=u,r=a[2],o===An?_n:c}var r=void 0,o=t;return u(e,function(n){return e(null,n)},arguments.length>2&&void 0!==arguments[2]?arguments[2]:"iterator",!0)}function k(n,t){for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];var a={done:!1,value:A(n)},u=function(n){return{done:!1,value:T.apply(void 0,[t].concat(r,[n]))}},c=void 0,i=function(n){return c=n};return E({q1:function(){return["q2",a,i]},q2:function(){return c===bn?[An]:["q1",u(c)]}},"q1","takeEvery("+b(n)+", "+t.name+")")}function C(n,t){for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];var a={done:!1,value:A(n)},u=function(n){return{done:!1,value:T.apply(void 0,[t].concat(r,[n]))}},c=function(n){return{done:!1,value:N(n)}},i=void 0,f=void 0,l=function(n){return i=n},s=function(n){return f=n};return E({q1:function(){return["q2",a,s]},q2:function(){return f===bn?[An]:i?["q3",c(i)]:["q1",u(f),l]},q3:function(){return["q1",u(f),l]}},"q1","takeLatest("+b(n)+", "+t.name+")")}function _(n,t,e){for(var r=arguments.length,o=Array(r>3?r-3:0),u=3;r>u;u++)o[u-3]=arguments[u];var c=void 0,i=void 0,f={done:!1,value:R(t,pn.sliding(1))},l=function(){return{done:!1,value:A(i)}},s=function(n){return{done:!1,value:T.apply(void 0,[e].concat(o,[n]))}},d={done:!1,value:j(a,n)},v=function(n){return c=n},g=function(n){return i=n};return E({q1:function(){return["q2",f,g]},q2:function(){return["q3",l(),v]},q3:function(){return c===bn?[An]:["q4",s(c)]},q4:function(){return["q2",d]}},"q1","throttle("+b(t)+", "+e.name+")")}function A(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"*";if(arguments.length&&t(arguments[0],nn.notUndef,"take(patternOrChannel): patternOrChannel is undefined"),nn.pattern(n))return Xn(On,{pattern:n});if(nn.channel(n))return Xn(On,{channel:n});throw Error("take(patternOrChannel): argument "+n+" is not valid channel or a valid pattern")}function x(n,e){return arguments.length>1?(t(n,nn.notUndef,"put(channel, action): argument channel is undefined"),t(n,nn.channel,"put(channel, action): argument "+n+" is not a valid channel"),t(e,nn.notUndef,"put(channel, action): argument action is undefined")):(t(n,nn.notUndef,"put(action): argument action is undefined"),e=n,n=null),Xn(Nn,{channel:n,action:e})}function w(n){return Xn(Rn,n)}function S(n,e,r){t(e,nn.notUndef,n+": argument fn is undefined");var o=null;if(nn.array(e)){var a=e;o=a[0],e=a[1]}else if(e.fn){var u=e;o=u.context,e=u.fn}return o&&nn.string(e)&&nn.func(o[e])&&(e=o[e]),t(e,nn.func,n+": argument "+e+" is not a function"),{context:o,fn:e,args:r}}function j(n){for(var t=arguments.length,e=Array(t>1?t-1:0),r=1;t>r;r++)e[r-1]=arguments[r];return Xn(qn,S("call",n,e))}function T(n){for(var t=arguments.length,e=Array(t>1?t-1:0),r=1;t>r;r++)e[r-1]=arguments[r];return Xn(Mn,S("fork",n,e))}function O(){for(var n=arguments.length,e=Array(n),r=0;n>r;r++)e[r]=arguments[r];if(e.length>1)return w(e.map(function(n){return O(n)}));var o=e[0];return t(o,nn.notUndef,"join(task): argument task is undefined"),t(o,nn.task,"join(task): argument "+o+" is not a valid Task object "+Bn),Xn(In,o)}function N(){for(var n=arguments.length,e=Array(n),r=0;n>r;r++)e[r]=arguments[r];if(e.length>1)return w(e.map(function(n){return N(n)}));var o=e[0];return 1===e.length&&(t(o,nn.notUndef,"cancel(task): argument task is undefined"),t(o,nn.task,"cancel(task): argument "+o+" is not a valid Task object "+Bn)),Xn(Pn,o||Q)}function R(n,e){return t(n,nn.notUndef,"actionChannel(pattern,...): argument pattern is undefined"),arguments.length>1&&(t(e,nn.notUndef,"actionChannel(pattern, buffer): argument buffer is undefined"),t(e,nn.buffer,"actionChannel(pattern, buffer): argument "+e+" is not a valid buffer")),Xn(Hn,{pattern:n,buffer:e})}function L(n){return("*"===n?nt.wildcard:nn.array(n)?nt.array:nn.stringableFunc(n)?nt.default:nn.func(n)?nt.predicate:nt.default)(n)}function q(n,t,e){function o(n){u(),e(n,!0)}function a(n){c.push(n),n.cont=function(a,u){f||(r(c,n),n.cont=Y,u?o(a):(n===t&&(i=a),c.length||(f=!0,e(i))))}}function u(){f||(f=!0,c.forEach(function(n){n.cont=Y,n.cancel()}),c=[])}var c=[],i=void 0,f=!1;return a(t),{addTask:a,cancelAll:u,abort:o,getTasks:function(){return c},taskNames:function(){return c.map(function(n){return n.name})}}}function U(n){var t=n.context,e=n.fn,r=n.args;if(nn.iterator(e))return e;var o=void 0,a=void 0;try{o=e.apply(t,r)}catch(n){a=n}return nn.iterator(o)?o:u(a?function(){throw a}:function(){var n=void 0,t={done:!1,value:o},e=function(n){return{done:!0,value:n}};return function(r){return n?e(r):(n=!0,t)}}())}function M(n){function e(){n._isRunning&&!n._isCancelled&&(n._isCancelled=!0,vn.cancelAll(),u($n))}function a(t,e){if(!dn.isRunning)throw Error("Trying to resume an already finished generator");try{var r=void 0;e?r=n.throw(t):t===$n?(dn.isCancelled=!0,a.cancel(),r=nn.func(n.return)?n.return($n):{done:!0,value:$n}):r=t===Zn?nn.func(n.return)?n.return():{done:!0}:n.next(t),r.done?(dn.isMainRunning=!1,dn.cont&&dn.cont(r.value)):f(r.value,z,"",a)}catch(n){dn.isCancelled&&an(n),dn.isMainRunning=!1,dn.cont(n,!0)}}function u(t,e){n._isRunning=!1,cn.close(),e?(t instanceof Error&&Object.defineProperty(t,"sagaStack",{value:"at "+B+" \n "+(t.sagaStack||t.stack),configurable:!0}),sn.cont||(t instanceof Error&&$?$(t):an(t)),n._error=t,n._isAborted=!0,n._deferredEnd&&n._deferredEnd.reject(t)):(n._result=t,n._deferredEnd&&n._deferredEnd.resolve(t)),sn.cont&&sn.cont(t,e),sn.joiners.forEach(function(n){return n.cb(t,e)}),sn.joiners=null}function f(n,t){function e(n,t){u||(u=!0,o.cancel=Y,W&&(t?W.effectRejected(a,n):W.effectResolved(a,n)),o(n,t))}var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=arguments[3],a=rn();W&&W.effectTriggered({effectId:a,parentEffectId:t,label:r,effect:n});var u=void 0;e.cancel=Y,o.cancel=function(){if(!u){u=!0;try{e.cancel()}catch(n){an(n)}e.cancel=Y,W&&W.effectCancelled(a)}};var c=void 0;return nn.promise(n)?l(n,e):nn.helper(n)?k(tt(n),a,e):nn.iterator(n)?v(n,a,B,e):nn.array(n)?V(n,a,e):(c=Wn.take(n))?h(c,e):(c=Wn.put(n))?p(c,e):(c=Wn.all(n))?A(c,a,e):(c=Wn.race(n))?x(c,a,e):(c=Wn.call(n))?b(c,a,e):(c=Wn.cps(n))?E(c,e):(c=Wn.fork(n))?k(c,a,e):(c=Wn.join(n))?C(c,e):(c=Wn.cancel(n))?_(c,e):(c=Wn.select(n))?w(c,e):(c=Wn.actionChannel(n))?S(c,e):(c=Wn.flush(n))?T(c,e):(c=Wn.cancelled(n))?j(c,e):(c=Wn.getContext(n))?O(c,e):(c=Wn.setContext(n))?N(c,e):e(n)}function l(n,t){var e=n[X];nn.func(e)?t.cancel=e:nn.func(n.abort)&&(t.cancel=function(){return n.abort()}),n.then(t,function(n){return t(n,!0)})}function v(n,t,e,r){M(n,R,I,P,ln,F,t,e,r)}function h(n,t){var e=n.channel,r=n.pattern,o=n.maybe;e=e||cn;var a=function(n){return n instanceof Error?t(n,!0):t(En(n)&&!o?Zn:n)};try{e.take(a,L(r))}catch(n){return t(n,!0)}t.cancel=a.cancel}function p(n,t){var e=n.channel,r=n.action,o=n.resolve;s(function(){var n=void 0;try{n=(e?e.put:I)(r)}catch(n){if(e||o)return t(n,!0);an(n)}if(!o||!nn.promise(n))return t(n);l(n,t)})}function b(n,t,e){var r=n.context,o=n.fn,a=n.args,u=void 0;try{u=o.apply(r,a)}catch(n){return e(n,!0)}return nn.promise(u)?l(u,e):nn.iterator(u)?v(u,t,o.name,e):e(u)}function E(n,t){var e=n.context,r=n.fn,o=n.args;try{var a=function(n,e){return nn.undef(n)?t(e):t(n,!0)};r.apply(e,o.concat(a)),a.cancel&&(t.cancel=function(){return a.cancel()})}catch(n){return t(n,!0)}}function k(n,t,e){var r=n.context,o=n.fn,a=n.args,u=n.detached,c=U({context:r,fn:o,args:a});try{d();var i=M(c,R,I,P,ln,F,t,o.name,u?null:Y);u?e(i):c._isRunning?(vn.addTask(i),e(i)):c._error?vn.abort(c._error):e(i)}finally{g()}}function C(n,t){if(n.isRunning()){var e={task:sn,cb:t};t.cancel=function(){return r(n.joiners,e)},n.joiners.push(e)}else n.isAborted()?t(n.error(),!0):t(n.result())}function _(n,t){n===Q&&(n=sn),n.isRunning()&&n.cancel(),t()}function A(n,t,e){function r(){a===o.length&&(u=!0,e(nn.array(n)?en.from(H({},c,{length:o.length})):c))}var o=Object.keys(n);if(!o.length)return e(nn.array(n)?[]:{});var a=0,u=void 0,c={},i={};o.forEach(function(n){var t=function(t,o){u||(o||En(t)||t===Zn||t===$n?(e.cancel(),e(t,o)):(c[n]=t,a++,r()))};t.cancel=Y,i[n]=t}),e.cancel=function(){u||(u=!0,o.forEach(function(n){return i[n].cancel()}))},o.forEach(function(e){return f(n[e],t,e,i[e])})}function x(n,t,e){var r=void 0,o=Object.keys(n),a={};o.forEach(function(t){var u=function(a,u){if(!r)if(u)e.cancel(),e(a,!0);else if(!En(a)&&a!==Zn&&a!==$n){var c;e.cancel(),r=!0;var i=(c={},c[t]=a,c);e(nn.array(n)?[].slice.call(H({},i,{length:o.length})):i)}};u.cancel=Y,a[t]=u}),e.cancel=function(){r||(r=!0,o.forEach(function(n){return a[n].cancel()}))},o.forEach(function(e){r||f(n[e],t,e,a[e])})}function w(n,t){var e=n.selector,r=n.args;try{var o=e.apply(void 0,[P()].concat(r));t(o)}catch(n){t(n,!0)}}function S(n,t){var e=n.pattern,r=n.buffer,o=L(e);o.pattern=e,t(y(R,r||pn.fixed(),o))}function j(n,t){t(!!dn.isCancelled)}function T(n,t){n.flush(t)}function O(n,t){t(ln[n])}function N(n,t){tn.assign(ln,n),t()}var R=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){return Y},I=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Y,P=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Y,G=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},F=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},z=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,B=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"anonymous",J=arguments[8];t(n,nn.iterator,Yn);var V=i(A,un("[...effects]","all([...effects])")),W=F.sagaMonitor,Z=F.logger,$=F.onError,on=Z||c,an=function(n){var t=n.sagaStack;!t&&n.stack&&(t=-1!==n.stack.split("\n")[0].indexOf(n.message)?n.stack:"Error: "+n.message+"\n"+n.stack),on("error","uncaught at "+B,t||n.message||n)},cn=m(R),ln=Object.create(G);a.cancel=Y;var sn=function(n,r,a,u){var c,i;return a._deferredEnd=null,c={},c[K]=!0,c.id=n,c.name=r,i={},i.done=i.done||{},i.done.get=function(){if(a._deferredEnd)return a._deferredEnd.promise;var n=o();return a._deferredEnd=n,a._isRunning||(a._error?n.reject(a._error):n.resolve(a._result)),n.promise},c.cont=u,c.joiners=[],c.cancel=e,c.isRunning=function(){return a._isRunning},c.isCancelled=function(){return a._isCancelled},c.isAborted=function(){return a._isAborted},c.result=function(){return a._result},c.error=function(){return a._error},c.setContext=function(n){t(n,nn.object,fn("task",n)),tn.assign(ln,n)},D(c,i),c}(z,B,n,J),dn={name:B,cancel:function(){dn.isRunning&&!dn.isCancelled&&(dn.isCancelled=!0,a($n))},isRunning:!0},vn=q(B,dn,u);return J&&(J.cancel=e),n._isRunning=!0,a(),sn}function I(n,e){for(var r=arguments.length,o=Array(r>2?r-2:0),a=2;r>a;a++)o[a-2]=arguments[a];var u=void 0;nn.iterator(n)?(u=n,n=e):(t(e,nn.func,et),t(u=e.apply(void 0,o),nn.iterator,et));var c=n,i=c.subscribe,f=c.dispatch,l=c.getState,s=c.context,d=c.sagaMonitor,v=c.logger,g=c.onError,h=rn();d&&(d.effectTriggered=d.effectTriggered||Y,d.effectResolved=d.effectResolved||Y,d.effectRejected=d.effectRejected||Y,d.effectCancelled=d.effectCancelled||Y,d.actionDispatched=d.actionDispatched||Y,d.effectTriggered({effectId:h,root:!0,parentEffectId:0,effect:{root:!0,saga:e,args:o}}));var p=M(u,i,ln(f),l,s,{sagaMonitor:d,logger:v,onError:g},h,e.name);return d&&d.effectResolved(h,p),p}var P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},D=function(n,t){for(var e in t){var r=t[e];r.configurable=r.enumerable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,e,r)}return n},H=Object.assign||function(n){for(var t=1;arguments.length>t;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},G=function(n,t){var e={};for(var r in n)0>t.indexOf(r)&&Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},F=function(n){return"@@redux-saga/"+n},K=F("TASK"),z=F("HELPER"),B=F("MATCH"),X=F("CANCEL_PROMISE"),J=F("SAGA_ACTION"),Q=F("SELF_CANCELLATION"),V=function(n){return function(){return n}},W=V(!0),Y=function(){},Z=function(n){return n},$=Object.prototype.hasOwnProperty,nn={undef:function(n){return null===n||void 0===n},notUndef:function(n){return null!==n&&void 0!==n},func:function(n){return"function"==typeof n},number:function(n){return"number"==typeof n},string:function(n){return"string"==typeof n},array:Array.isArray,object:function(n){return n&&!nn.array(n)&&"object"===(void 0===n?"undefined":P(n))},promise:function(n){return n&&nn.func(n.then)},iterator:function(n){return n&&nn.func(n.next)&&nn.func(n.throw)},iterable:function(n){return n&&nn.func(Symbol)?nn.func(n[Symbol.iterator]):nn.array(n)},task:function(n){return n&&n[K]},observable:function(n){return n&&nn.func(n.subscribe)},buffer:function(n){return n&&nn.func(n.isEmpty)&&nn.func(n.take)&&nn.func(n.put)},pattern:function(n){return n&&(nn.string(n)||"symbol"===(void 0===n?"undefined":P(n))||nn.func(n)||nn.array(n))},channel:function(n){return n&&nn.func(n.take)&&nn.func(n.close)},helper:function(n){return n&&n[z]},stringableFunc:function(n){return nn.func(n)&&e(n,"toString")}},tn={assign:function(n,t){for(var r in t)e(t,r)&&(n[r]=t[r])}},en={from:function(n){var t=Array(n.length);for(var r in n)e(n,r)&&(t[r]=n[r]);return t}},rn=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function(){return++n}}(),on=function(n){throw n},an=function(n){return{value:n,done:!0}},un=function(n,t){return n+" has been deprecated in favor of "+t+", please update your code"},cn=function(n){return Error("\n redux-saga: Error checking hooks detected an inconsistent state. This is likely a bug\n in redux-saga code and not yours. Thanks for reporting this in the project's github repo.\n Error: "+n+"\n")},fn=function(n,t){return(n?n+".":"")+"setContext(props): argument "+t+" is not a plain object"},ln=function(n){return function(t){return n(Object.defineProperty(t,J,{value:!0}))}},sn="Channel's Buffer overflow!",dn=1,vn=3,gn=4,hn={isEmpty:W,put:Y,take:Y},pn={none:function(){return hn},fixed:function(n){return f(n,dn)},dropping:function(n){return f(n,2)},sliding:function(n){return f(n,vn)},expanding:function(n){return f(n,gn)}},yn=[],mn=0,bn={type:"@@redux-saga/CHANNEL_END"},En=function(n){return n&&"@@redux-saga/CHANNEL_END"===n.type},kn="invalid buffer passed to channel factory function",Cn="Saga was provided with an undefined action",_n={done:!0,value:void 0},An={},xn=function(n){return"import { "+n+" } from 'redux-saga' has been deprecated in favor of import { "+n+" } from 'redux-saga/effects'.\nThe latter will not work with yield*, as helper effects are wrapped automatically for you in fork effect.\nTherefore yield "+n+" will return task descriptor to your saga and execute next lines of code."},wn=i(k,xn("takeEvery")),Sn=i(C,xn("takeLatest")),jn=i(_,xn("throttle")),Tn=F("IO"),On="TAKE",Nn="PUT",Rn="ALL",Ln="RACE",qn="CALL",Un="CPS",Mn="FORK",In="JOIN",Pn="CANCEL",Dn="SELECT",Hn="ACTION_CHANNEL",Gn="CANCELLED",Fn="FLUSH",Kn="GET_CONTEXT",zn="SET_CONTEXT",Bn="\n(HINT: if you are getting this errors in tests, consider using createMockTask from redux-saga/utils)",Xn=function(n,t){var e;return e={},e[Tn]=!0,e[n]=t,e},Jn=function(n){return t(Wn.fork(n),nn.object,"detach(eff): argument must be a fork effect"),n[Mn].detached=!0,n},Qn=i(A.maybe=function(){var n=A.apply(void 0,arguments);return n[On].maybe=!0,n},un("takem","take.maybe"));x.resolve=function(){var n=x.apply(void 0,arguments);return n[Nn].resolve=!0,n},x.sync=i(x.resolve,un("put.sync","put.resolve"));var Vn=function(n){return function(t){return t&&t[Tn]&&t[n]}},Wn={take:Vn(On),put:Vn(Nn),all:Vn(Rn),race:Vn(Ln),call:Vn(qn),cps:Vn(Un),fork:Vn(Mn),join:Vn(In),cancel:Vn(Pn),select:Vn(Dn),actionChannel:Vn(Hn),cancelled:Vn(Gn),flush:Vn(Fn),getContext:Vn(Kn),setContext:Vn(zn)},Yn="proc first argument (Saga function result) must be an iterator",Zn={toString:function(){return"@@redux-saga/CHANNEL_END"}},$n={toString:function(){return"@@redux-saga/TASK_CANCEL"}},nt={wildcard:function(){return W},default:function(n){return"symbol"===(void 0===n?"undefined":P(n))?function(t){return t.type===n}:function(t){return t.type===n+""}},array:function(n){return function(t){return n.some(function(n){return L(n)(t)})}},predicate:function(n){return function(t){return n(t)}}},tt=function(n){return{fn:n}},et="runSaga(storeInterface, saga, ...args): saga argument must be a Generator function!",rt=Object.freeze({take:A,takem:Qn,put:x,all:w,race:function(n){return Xn(Ln,n)},call:j,apply:function(n,t){return Xn(qn,S("apply",{context:n,fn:t},arguments.length>2&&void 0!==arguments[2]?arguments[2]:[]))},cps:function(n){for(var t=arguments.length,e=Array(t>1?t-1:0),r=1;t>r;r++)e[r-1]=arguments[r];return Xn(Un,S("cps",n,e))},fork:T,spawn:function(n){for(var t=arguments.length,e=Array(t>1?t-1:0),r=1;t>r;r++)e[r-1]=arguments[r];return Jn(T.apply(void 0,[n].concat(e)))},join:O,cancel:N,select:function(n){for(var e=arguments.length,r=Array(e>1?e-1:0),o=1;e>o;o++)r[o-1]=arguments[o];return 0===arguments.length?n=Z:(t(n,nn.notUndef,"select(selector,[...]): argument selector is undefined"),t(n,nn.func,"select(selector,[...]): argument "+n+" is not a function")),Xn(Dn,{selector:n,args:r})},actionChannel:R,cancelled:function(){return Xn(Gn,{})},flush:function(n){return t(n,nn.channel,"flush(channel): argument "+n+" is not valid channel"),Xn(Fn,n)},getContext:function(n){return t(n,nn.string,"getContext(prop): argument "+n+" is not a string"),Xn(Kn,n)},setContext:function(n){return t(n,nn.object,fn(null,n)),Xn(zn,n)},takeEvery:function(n,t){for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];return T.apply(void 0,[k,n,t].concat(r))},takeLatest:function(n,t){for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];return T.apply(void 0,[C,n,t].concat(r))},throttle:function(n,t,e){for(var r=arguments.length,o=Array(r>3?r-3:0),a=3;r>a;a++)o[a-3]=arguments[a];return T.apply(void 0,[_,n,t,e].concat(o))}}),ot=Object.freeze({TASK:K,SAGA_ACTION:J,noop:Y,is:nn,deferred:o,arrayOfDeffered:function(n){for(var t=[],e=0;n>e;e++)t.push(o());return t},createMockTask:function(){var n,t=!0,e=void 0,r=void 0;return n={},n[K]=!0,n.isRunning=function(){return t},n.result=function(){return e},n.error=function(){return r},n.setRunning=function(n){return t=n},n.setResult=function(n){return e=n},n.setError=function(n){return r=n},n},cloneableGenerator:function n(t){return function(){for(var e=arguments.length,r=Array(e),o=0;e>o;o++)r[o]=arguments[o];var a=[],u=t.apply(void 0,r);return{next:function(n){return a.push(n),u.next(n)},clone:function(){var e=n(t).apply(void 0,r);return a.forEach(function(n){return e.next(n)}),e},return:function(n){return u.return(n)},throw:function(n){return u.throw(n)}}}},asEffect:Wn,CHANNEL_END:Zn});n.default=function(){function n(t){var e=t.getState,r=t.dispatch,f=h();return f.emit=(a.emitter||Z)(f.emit),n.run=I.bind(null,{context:o,subscribe:f.subscribe,dispatch:r,getState:e,sagaMonitor:u,logger:c,onError:i}),function(n){return function(t){u&&u.actionDispatched&&u.actionDispatched(t);var e=n(t);return f.emit(t),e}}}var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.context,o=void 0===r?{}:r,a=G(e,["context"]),u=a.sagaMonitor,c=a.logger,i=a.onError;if(nn.func(a))throw Error("Saga middleware no longer accept Generator functions. Use sagaMiddleware.run instead");if(c&&!nn.func(c))throw Error("`options.logger` passed to the Saga middleware is not a function!");if(i&&!nn.func(i))throw Error("`options.onError` passed to the Saga middleware is not a function!");if(a.emitter&&!nn.func(a.emitter))throw Error("`options.emitter` passed to the Saga middleware is not a function!");return n.run=function(){throw Error("Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware")},n.setContext=function(n){t(n,nn.object,fn("sagaMiddleware",n)),tn.assign(o,n)},n},n.effects=rt,n.utils=ot,n.runSaga=I,n.END=bn,n.eventChannel=y,n.channel=p,n.buffers=pn,n.takeEvery=wn,n.takeLatest=Sn,n.throttle=jn,n.delay=a,n.CANCEL=X,n.detach=Jn,Object.defineProperty(n,"__esModule",{value:!0})});
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.ReduxSaga={})}(this,function(n){"use strict";function t(n){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function r(){return(r=Object.assign||function(n){for(var t=1;arguments.length>t;t++){var r=arguments[t];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=r[e])}return n}).apply(this,arguments)}function e(n,t){return Q.notUndef(n)&&J.call(n,t)}function o(n,t){var r=n.indexOf(t);0>r||n.splice(r,1)}function u(n){var t=!1;return function(){t||(t=!0,n())}}function c(n){void 0===n&&(n={});var t=r({},n),e=new Promise(function(n,r){t.resolve=n,t.reject=r});return t.promise=e,t}function i(n,t){void 0===t&&(t=!0);var r,e=new Promise(function(e){r=setTimeout(function(){return e(t)},n)});return e[q]=function(){return clearTimeout(r)},e}function a(n,t,r){void 0===t&&(t=Z),void 0===r&&(r="iterator");var e={name:r,next:n,throw:t,return:$};return"undefined"!=typeof Symbol&&(e[Symbol.iterator]=function(){return e}),e}function f(n,t){void 0===n&&(n=10);var r=Array(n),e=0,o=0,u=0,c=function(t){r[o]=t,o=(o+1)%n,e++},i=function(){if(0!=e){var t=r[u];return r[u]=null,e--,u=(u+1)%n,t}},a=function(){for(var n=[];e;)n.push(i());return n};return{isEmpty:function(){return 0==e},put:function(i){if(n>e)c(i);else{var f;switch(t){case en:throw Error(rn);case on:r[o]=i,u=o=(o+1)%n;break;case un:f=2*n,r=a(),e=r.length,o=r.length,u=0,r.length=f,n=f,c(i)}}},take:i,flush:a}}function l(n){dn.push(n),vn||(s(),v())}function s(){vn++}function d(){vn--}function v(){d();for(var n;!vn&&void 0!==(n=dn.shift());)!function(n){try{s(),n()}finally{d()}}(n)}function p(n){var t="*"===n?bn:Q.string(n)?hn:Q.array(n)?pn:Q.stringableFunc(n)?hn:Q.func(n)?gn:Q.symbol(n)?yn:null;if(null===t)throw Error("invalid pattern: "+n);return t(n)}function g(n){function t(){if(r&&e.length)throw nn("Cannot have a closed channel with pending takers");if(e.length&&!n.isEmpty())throw nn("Cannot have pending takers with non empty buffer")}void 0===n&&(n=ln());var r=!1,e=[];return{take:function(u){t(),r&&n.isEmpty()?u(mn):n.isEmpty()?(e.push(u),u.cancel=function(){return o(e,u)}):u(n.take())},put:function(o){if(t(),!r){if(!e.length)return n.put(o);var u=e[0];e.splice(0,1),u(o)}},flush:function(e){t(),e(r&&n.isEmpty()?mn:n.flush())},close:function(){if(t(),!r&&(r=!0,e.length)){var n=e;e=[];for(var o=0,u=n.length;u>o;o++)(0,n[o])(mn)}}}}function h(){var n,t=!1,r=[],e=r,c=function(){e===r&&(e=r.slice())},i=function(){t=!0;for(var n=r=e,o=0;n.length>o;o++)(0,n[o])(mn);e=[]};return n={},n[D]=!0,n.put=function(n){if(!t)if(En(n))i();else for(var o=r=e,u=0;o.length>u;u++){var c=o[u];c[P](n)&&(c.cancel(),c(n))}},n.take=function(n,r){void 0===r&&(r=bn),t?n(mn):(n[P]=r,c(),e.push(n),n.cancel=u(function(){c(),o(e,n)}))},n.close=i,n}function y(){var n=h(),t=n.put;return n.put=function(n){n[F]?t(n):l(function(){return t(n)})},n}function b(n){return Q.channel(n)?"channel":Q.stringableFunc(n)?n+"":Q.func(n)?n.name:n+""}function m(n,t,r){function e(t,r){if(u===jn)return kn;if(r)throw u=jn,r;o&&o(t);var e=n[u]();return u=e[0],o=e[2],u===jn?kn:e[1]}var o,u=t;return a(e,function(n){return e(null,n)},r)}function E(n,t){if(void 0===n&&(n="*"),Q.pattern(n))return Un(On,{pattern:n});if(Q.multicast(n)&&Q.notUndef(t)&&Q.pattern(t))return Un(On,{channel:n,pattern:t});if(Q.channel(n))return Un(On,{channel:n});throw Error("take(patternOrChannel): argument "+n+" is not valid channel or a valid pattern")}function C(n,t){return Q.undef(t)&&(t=n,n=null),Un(Sn,{channel:n,action:t})}function A(n){return Un(_n,n)}function k(n,t,r){var e=null;if(Q.array(t)){var o=t;e=o[0],t=o[1]}else if(t.fn){var u=t;e=u.context,t=u.fn}return e&&Q.string(t)&&Q.func(e[t])&&(t=e[t]),{context:e,fn:t,args:r}}function j(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return Un(xn,k(0,n,r))}function O(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return Un(Rn,k(0,n,r))}function S(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return t.length>1?A(t.map(function(n){return S(n)})):Un(Nn,t[0])}function _(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];if(t.length>1)return A(t.map(function(n){return _(n)}));var e=t[0];return Un(qn,e||U)}function w(n,t){return Un(Mn,{pattern:n,buffer:t})}function x(n,t,e,u,i,f,d,h,y){function b(){n._isRunning&&!n._isCancelled&&(n._isCancelled=!0,I.cancelAll(),E(Bn))}function m(t,r){if(!M.isRunning)throw Error("Trying to resume an already finished generator");try{var e;r?e=n.throw(t):t===Bn?(M.isCancelled=!0,m.cancel(),e=Q.func(n.return)?n.return(Bn):{done:!0,value:Bn}):e=t===zn?Q.func(n.return)?n.return():{done:!0}:n.next(t),e.done?(M.isMainRunning=!1,M.cont&&M.cont(e.value)):A(e.value,d,"",m)}catch(n){M.isCancelled&&R(n),M.isMainRunning=!1,M.cont(n,!0)}}function E(t,r){n._isRunning=!1,r?(t instanceof Error&&Object.defineProperty(t,"sagaStack",{value:"at "+h+" \n "+(t.sagaStack||t.stack),configurable:!0}),L.cont||(t instanceof Error&&_?_(t):R(t)),n._error=t,n._isAborted=!0,n._deferredEnd&&n._deferredEnd.reject(t)):(n._result=t,n._deferredEnd&&n._deferredEnd.resolve(t)),L.cont&&L.cont(t,r),L.joiners.forEach(function(n){return n.cb(t,r)}),L.joiners=null}function C(n,c,i,d){void 0===i&&(i="");var y;return Q.promise(n)?k(n,d):Q.iterator(n)?j(n,c,h,d):(y=Gn.take(n))?function(n,r){var e=n.channel,o=void 0===e?t:e,u=n.pattern,c=n.maybe,i=function(n){n instanceof Error?r(n,!0):r(!En(n)||c?n:zn)};try{o.take(i,Q.notUndef(u)?p(u):null)}catch(n){return void r(n,!0)}r.cancel=i.cancel}(y,d):(y=Gn.put(n))?function(n,t){var r=n.channel,o=n.action,u=n.resolve;l(function(){var n;try{n=(r?r.put:e)(o)}catch(n){return R(n),void t(n,!0)}u&&Q.promise(n)?k(n,t):t(n)})}(y,d):(y=Gn.all(n))?function(n,t,e){var o=Object.keys(n);if(!o.length)return void e(Q.array(n)?[]:{});var u,c=0,i={},a={};o.forEach(function(t){var f=function(a,f){u||(f||En(a)||a===zn||a===Bn?(e.cancel(),e(a,f)):(i[t]=a,++c===o.length&&(u=!0,e(Q.array(n)?W.from(r({},i,{length:o.length})):i))))};f.cancel=B,a[t]=f}),e.cancel=function(){u||(u=!0,o.forEach(function(n){return a[n].cancel()}))},o.forEach(function(r){return A(n[r],t,r,a[r])})}(y,c,d):(y=Gn.race(n))?function(n,t,e){var o,u=Object.keys(n),c={};u.forEach(function(t){var i=function(c,i){if(!o)if(i)e.cancel(),e(c,!0);else if(!En(c)&&c!==zn&&c!==Bn){var a;e.cancel(),o=!0;var f=(a={},a[t]=c,a);e(Q.array(n)?[].slice.call(r({},f,{length:u.length})):f)}};i.cancel=B,c[t]=i}),e.cancel=function(){o||(o=!0,u.forEach(function(n){return c[n].cancel()}))},u.forEach(function(r){o||A(n[r],t,r,c[r])})}(y,c,d):(y=Gn.call(n))?function(n,t,r){var e,o=n.context,u=n.fn,c=n.args;try{e=u.apply(o,c)}catch(n){return void r(n,!0)}return Q.promise(e)?k(e,r):Q.iterator(e)?j(e,t,u.name,r):r(e)}(y,c,d):(y=Gn.cps(n))?function(n,t){var r=n.context,e=n.fn,o=n.args;try{var u=function(n,r){return Q.undef(n)?t(r):t(n,!0)};e.apply(r,o.concat(u)),u.cancel&&(t.cancel=function(){return u.cancel()})}catch(n){return void t(n,!0)}}(y,d):(y=Gn.fork(n))?function(n,r,o){var c=n.fn,i=n.detached,l=function(n){var t=n.context,r=n.fn,e=n.args;if(Q.iterator(r))return r;var o,u;try{o=r.apply(t,e)}catch(n){u=n}return Q.iterator(o)?o:a(u?function(){throw u}:function(){var n,t={done:!1,value:o};return function(r){return n?function(n){return{done:!0,value:r}}():(n=!0,t)}}())}({context:n.context,fn:c,args:n.args});try{s();var d=x(l,t,e,u,N,f,r,c.name,i?null:B);i?o(d):l._isRunning?(I.addTask(d),o(d)):l._error?I.abort(l._error):o(d)}finally{v()}}(y,c,d):(y=Gn.join(n))?function(n,t){if(n.isRunning()){var r={task:L,cb:t};t.cancel=function(){return o(n.joiners,r)},n.joiners.push(r)}else n.isAborted()?t(n.error(),!0):t(n.result())}(y,d):(y=Gn.cancel(n))?function(n,t){n===U&&(n=L);n.isRunning()&&n.cancel();t()}(y,d):(y=Gn.select(n))?function(n,t){var r=n.selector,e=n.args;try{var o=r.apply(void 0,[u()].concat(e));t(o)}catch(n){t(n,!0)}}(y,d):(y=Gn.actionChannel(n))?function(n,r){var e=n.pattern,o=g(n.buffer),u=p(e);t.take(function n(r){En(r)||t.take(n,u),o.put(r)},u),r(o)}(y,d):(y=Gn.flush(n))?function(n,t){n.flush(t)}(y,d):(y=Gn.cancelled(n))?function(n,t){t(!!M.isCancelled)}(0,d):(y=Gn.getContext(n))?function(n,t){t(N[n])}(y,d):(y=Gn.setContext(n))?function(n,t){V.assign(N,n),t()}(y,d):d(n)}function A(n,t,r,e){function o(n,t){c||(c=!0,e.cancel=B,S&&(t?S.effectRejected(u,n):S.effectResolved(u,n)),e(n,t))}void 0===r&&(r="");var u=Y();S&&S.effectTriggered({effectId:u,parentEffectId:t,label:r,effect:n});var c;o.cancel=B,e.cancel=function(){if(!c){c=!0;try{o.cancel()}catch(n){R(n)}o.cancel=B,S&&S.effectCancelled(u)}},Q.func(w)?w(function(n){return C(n,u,r,o)})(n):C(n,u,r,o)}function k(n,t){var r=n[q];Q.func(r)?t.cancel=r:Q.func(n.abort)&&(t.cancel=function(){return n.abort()}),n.then(t,function(n){return t(n,!0)})}function j(n,r,o,c){x(n,t,e,u,N,f,r,o,c)}void 0===e&&(e=B),void 0===u&&(u=B),void 0===i&&(i={}),void 0===f&&(f={}),void 0===d&&(d=0),void 0===h&&(h="anonymous");var O=f,S=O.sagaMonitor,_=O.onError,w=O.middleware,T=O.logger||function(n,t,r){void 0===r&&(r=""),"undefined"==typeof window?console.log("redux-saga "+n+": "+t+"\n"+(r&&r.stack||r)):console[n](t,r)},R=function(n){var t=n.sagaStack;!t&&n.stack&&(t=-1!==n.stack.split("\n")[0].indexOf(n.message)?n.stack:"Error: "+n.message+"\n"+n.stack),T("error","uncaught at "+h,t||n.message||n)},N=Object.create(i);m.cancel=B;var L=function(n,t,r,e){var o;return r._deferredEnd=null,o={},o[H]=!0,o.id=n,o.name=t,o.toPromise=function(){if(r._deferredEnd)return r._deferredEnd.promise;var n=c();return r._deferredEnd=n,r._isRunning||(r._isAborted?n.reject(r._error):n.resolve(r._result)),n.promise},o.cont=e,o.joiners=[],o.cancel=b,o.isRunning=function(){return r._isRunning},o.isCancelled=function(){return r._isCancelled},o.isAborted=function(){return r._isAborted},o.result=function(){return r._result},o.error=function(){return r._error},o.setContext=function(n){V.assign(N,n)},o}(d,h,n,y),M={name:h,cancel:function(){M.isRunning&&!M.isCancelled&&(M.isCancelled=!0,m(Bn))},isRunning:!0},I=function(n,t,r){function e(n){c(),r(n,!0)}function u(n){a.push(n),n.cont=function(u,c){f||(o(a,n),n.cont=B,c?e(u):(n===t&&(i=u),a.length||(f=!0,r(i))))}}function c(){f||(f=!0,a.forEach(function(n){n.cont=B,n.cancel()}),a=[])}var i,a=[],f=!1;return u(t),{addTask:u,cancelAll:c,abort:e,getTasks:function(){return a},taskNames:function(){return a.map(function(n){return n.name})}}}(0,M,E);return y&&(y.cancel=b),n._isRunning=!0,m(),L}function T(n,t){for(var r=arguments.length,e=Array(r>2?r-2:0),o=2;r>o;o++)e[o-2]=arguments[o];var u=t.apply(void 0,e),c=n.channel,i=void 0===c?y():c,a=n.dispatch,f=n.getState,l=n.context,s=n.sagaMonitor,d=n.logger,v=n.effectMiddlewares,p=n.onError,g=Y();s&&(s.effectTriggered=s.effectTriggered||B,s.effectResolved=s.effectResolved||B,s.effectRejected=s.effectRejected||B,s.effectCancelled=s.effectCancelled||B,s.actionDispatched=s.actionDispatched||B,s.effectTriggered({effectId:g,root:!0,parentEffectId:0,effect:{root:!0,saga:t,args:e}}));var h=v&&function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return 0===t.length?function(n){return n}:1===t.length?t[0]:t.reduce(function(n,t){return function(){return n(t.apply(void 0,arguments))}})}.apply(void 0,v),b=x(u,i,tn(a),f,l,{sagaMonitor:s,logger:d,onError:p,middleware:h},g,t.name);return s&&s.effectResolved(g,b),b}var R,N=function(n){return n="@@redux-saga/"+n,"function"==typeof Symbol?Symbol(n):n},q=N("CANCEL_PROMISE"),L=N("CHANNEL_END"),M=N("CHANNEL_END"),I=N("IO"),P=N("MATCH"),D=N("MULTICAST"),F=N("SAGA_ACTION"),U=N("SELF_CANCELLATION"),H=N("TASK"),K=N("TASK_CANCEL"),G=function(n){return function(){return n}},z=G(!0),B=function(){},X=function(n){return n},J=Object.prototype.hasOwnProperty,Q={undef:function(n){return null===n||void 0===n},notUndef:function(n){return null!==n&&void 0!==n},func:function(n){return"function"==typeof n},number:function(n){return"number"==typeof n},string:function(n){return"string"==typeof n},array:Array.isArray,object:function(n){return n&&!Q.array(n)&&"object"===t(n)},promise:function(n){return n&&Q.func(n.then)},iterator:function(n){return n&&Q.func(n.next)&&Q.func(n.throw)},iterable:function(n){return n&&Q.func(Symbol)?Q.func(n[Symbol.iterator]):Q.array(n)},task:function(n){return n&&n[H]},observable:function(n){return n&&Q.func(n.subscribe)},buffer:function(n){return n&&Q.func(n.isEmpty)&&Q.func(n.take)&&Q.func(n.put)},pattern:function(n){return n&&(Q.string(n)||Q.symbol(n)||Q.func(n)||Q.array(n))},channel:function(n){return n&&Q.func(n.take)&&Q.func(n.close)},stringableFunc:function(n){return Q.func(n)&&e(n,"toString")},symbol:function(n){return"symbol"===t(n)},multicast:function(n){return Q.channel(n)&&n[D]}},V={assign:function(n,t){for(var r in t)e(t,r)&&(n[r]=t[r])}},W={from:function(n){var t=Array(n.length);for(var r in n)e(n,r)&&(t[r]=n[r]);return t}},Y=function(n){return void 0===n&&(n=0),function(){return++n}}(),Z=function(n){throw n},$=function(n){return{value:n,done:!0}},nn=function(n){return Error("\n redux-saga: Error checking hooks detected an inconsistent state. This is likely a bug\n in redux-saga code and not yours. Thanks for reporting this in the project's github repo.\n Error: "+n+"\n")},tn=function(n){return function(t){return n(Object.defineProperty(t,F,{value:!0}))}},rn="Channel's Buffer overflow!",en=1,on=3,un=4,cn={isEmpty:z,put:B,take:B},an=function(){return cn},fn=function(n){return f(n,on)},ln=function(n){return f(n,un)},sn=Object.freeze({none:an,fixed:function(n){return f(n,en)},dropping:function(n){return f(n,2)},sliding:fn,expanding:ln}),dn=[],vn=0,pn=function(n){return function(t){return n.some(function(n){return p(n)(t)})}},gn=function(n){return function(t){return n(t)}},hn=function(n){return function(t){return t.type===n+""}},yn=function(n){return function(t){return t.type===n}},bn=function(){return z},mn={type:M},En=function(n){return n&&n.type===M},Cn="object"==typeof global&&global&&global.Object===Object&&global,An="object"==typeof self&&self&&self.Object===Object&&self,kn=(Cn||An||Function("return this")(),Function.prototype.toString.call(Object),function(n){var t,r=n.Symbol;"function"==typeof r?r.observable?t=r.observable:(t=r("observable"),r.observable=t):t="@@observable"}(R="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),{done:!0,value:void 0}),jn={},On="TAKE",Sn="PUT",_n="ALL",wn="RACE",xn="CALL",Tn="CPS",Rn="FORK",Nn="JOIN",qn="CANCEL",Ln="SELECT",Mn="ACTION_CHANNEL",In="CANCELLED",Pn="FLUSH",Dn="GET_CONTEXT",Fn="SET_CONTEXT",Un=function(n,t){var r;return r={},r[I]=!0,r[n]=t,r},Hn=function(n){return n[Rn].detached=!0,n},Kn=function(n){return function(t){return t&&t[I]&&t[n]}},Gn={take:Kn(On),put:Kn(Sn),all:Kn(_n),race:Kn(wn),call:Kn(xn),cps:Kn(Tn),fork:Kn(Rn),join:Kn(Nn),cancel:Kn(qn),select:Kn(Ln),actionChannel:Kn(Mn),cancelled:Kn(In),flush:Kn(Pn),getContext:Kn(Dn),setContext:Kn(Fn)},zn={toString:function(){return L}},Bn={toString:function(){return K}},Xn=Object.freeze({take:E,takeMaybe:function(){var n=E.apply(void 0,arguments);return n[On].maybe=!0,n},put:C,putResolve:function(){var n=C.apply(void 0,arguments);return n[Sn].resolve=!0,n},all:A,race:function(n){return Un(wn,n)},call:j,apply:function(n,t,r){return void 0===r&&(r=[]),Un(xn,k(0,{context:n,fn:t},r))},cps:function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return Un(Tn,k(0,n,r))},fork:O,spawn:function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return Hn(O.apply(void 0,[n].concat(r)))},join:S,cancel:_,select:function(n){void 0===n&&(n=X);for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return Un(Ln,{selector:n,args:r})},actionChannel:w,cancelled:function(){return Un(In,{})},flush:function(n){return Un(Pn,n)},getContext:function(n){return Un(Dn,n)},setContext:function(n){return Un(Fn,n)},takeEvery:function(n,t){for(var r=arguments.length,e=Array(r>2?r-2:0),o=2;r>o;o++)e[o-2]=arguments[o];return O.apply(void 0,[function(n,t){for(var r=arguments.length,e=Array(r>2?r-2:0),o=2;r>o;o++)e[o-2]=arguments[o];var u,c={done:!1,value:E(n)};return m({q1:function(){return["q2",c,function(n){return u=n}]},q2:function(){return u===mn?[jn]:["q1",{done:!1,value:O.apply(void 0,[t].concat(e,[u]))}]}},"q1","takeEvery("+b(n)+", "+t.name+")")},n,t].concat(e))},takeLatest:function(n,t){for(var r=arguments.length,e=Array(r>2?r-2:0),o=2;r>o;o++)e[o-2]=arguments[o];return O.apply(void 0,[function(n,t){for(var r=arguments.length,e=Array(r>2?r-2:0),o=2;r>o;o++)e[o-2]=arguments[o];var u,c,i={done:!1,value:E(n)},a=function(n){return{done:!1,value:O.apply(void 0,[t].concat(e,[n]))}},f=function(n){return u=n};return m({q1:function(){return["q2",i,function(n){return c=n}]},q2:function(){return c===mn?[jn]:u?["q3",function(n){return{done:!1,value:_(n)}}(u)]:["q1",a(c),f]},q3:function(){return["q1",a(c),f]}},"q1","takeLatest("+b(n)+", "+t.name+")")},n,t].concat(e))},throttle:function(n,t,r){for(var e=arguments.length,o=Array(e>3?e-3:0),u=3;e>u;u++)o[u-3]=arguments[u];return O.apply(void 0,[function(n,t,r){for(var e=arguments.length,o=Array(e>3?e-3:0),u=3;e>u;u++)o[u-3]=arguments[u];var c,a,f={done:!1,value:w(t,fn(1))},l={done:!1,value:j(i,n)};return m({q1:function(){return["q2",f,function(n){return a=n}]},q2:function(){return["q3",{done:!1,value:E(a)},function(n){return c=n}]},q3:function(){return c===mn?[jn]:["q4",{done:!1,value:O.apply(void 0,[r].concat(o,[c]))}]},q4:function(){return["q2",l]}},"q1","throttle("+b(t)+", "+r.name+")")},n,t,r].concat(o))}}),Jn=Object.freeze({noop:B,is:Q,deferred:c,arrayOfDeferred:function(n){for(var t=[],r=0;n>r;r++)t.push(c());return t},createMockTask:function(){var n,t,r,e=!0;return n={},n[H]=!0,n.isRunning=function(){return e},n.result=function(){return t},n.error=function(){return r},n.setRunning=function(n){return e=n},n.setResult=function(n){return t=n},n.setError=function(n){return r=n},n},cloneableGenerator:function n(t){return function(){for(var r=arguments.length,e=Array(r),o=0;r>o;o++)e[o]=arguments[o];var u=[],c=t.apply(void 0,e);return{next:function(n){return u.push(n),c.next(n)},clone:function(){var r=n(t).apply(void 0,e);return u.forEach(function(n){return r.next(n)}),r},return:function(n){return c.return(n)},throw:function(n){return c.throw(n)}}}},SAGA_ACTION:F,TASK:H,asEffect:Gn,CHANNEL_END:zn});n.default=function(n){function t(n){var r=n.getState,e=n.dispatch,l=y();return l.put=(u.emitter||X)(l.put),t.run=T.bind(null,{context:o,channel:l,dispatch:e,getState:r,sagaMonitor:c,logger:i,onError:a,effectMiddlewares:f}),function(n){return function(t){c&&c.actionDispatched&&c.actionDispatched(t);var r=n(t);return l.put(t),r}}}void 0===n&&(n={});var r=n,e=r.context,o=void 0===e?{}:e,u=function(n,t){if(null==n)return{};var r,e,o={},u=Object.keys(n);for(e=0;u.length>e;e++)0>t.indexOf(r=u[e])&&(o[r]=n[r]);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(n);for(e=0;c.length>e;e++)0>t.indexOf(r=c[e])&&Object.prototype.propertyIsEnumerable.call(n,r)&&(o[r]=n[r])}return o}(r,["context"]),c=u.sagaMonitor,i=u.logger,a=u.onError,f=u.effectMiddlewares;return t.run=function(){throw Error("Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware")},t.setContext=function(n){V.assign(o,n)},t},n.effects=Xn,n.utils=Jn,n.buffers=sn,n.runSaga=T,n.END=mn,n.eventChannel=function(n,t){void 0===t&&(t=an());var r,e=!1,o=g(t),c=function(){Q.func(r)&&r(),o.close()};if(r=n(function(n){if(En(n))return c(),void(e=!0);o.put(n)}),!Q.func(r))throw Error("in eventChannel: subscribe should return a function to unsubscribe");return r=u(r),e&&r(),{take:o.take,flush:o.flush,close:c}},n.channel=g,n.multicastChannel=h,n.stdChannel=y,n.CANCEL=q,n.delay=i,n.detach=Hn,Object.defineProperty(n,"__esModule",{value:!0})});

@@ -42,15 +42,8 @@ import {Action} from "redux";

<T>(channel: Channel<T>): ChannelTakeEffect<T>;
maybe<A extends Action>(pattern?: Pattern): TakeEffect;
maybe<T>(channel: Channel<T>): ChannelTakeEffect<T>;
}
export const take: Take;
export const takeMaybe: Take;
/**
* @deprecated
*/
export const takem: typeof take.maybe;
export interface PutEffectDescriptor<A extends Action> {

@@ -79,19 +72,7 @@ action: A;

<T>(channel: Channel<T>, action: T | END): ChannelPutEffect<T | END>;
resolve<A extends Action>(action: A): PutEffect<A>;
resolve<T>(channel: Channel<T>, action: T | END): ChannelPutEffect<T | END>;
/**
* @deprecated
*/
sync<A extends Action>(action: A): PutEffect<A>;
/**
* @deprecated
*/
sync<T>(channel: Channel<T>, action: T | END): ChannelPutEffect<T | END>;
}
export const put: Put;
export const putResolve: Put;
export type GenericAllEffectDescriptor<T> = T[] | {[key: string]: T};

@@ -98,0 +79,0 @@

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

export { take, takem, put, all, race, call, apply, cps, fork, spawn, join, cancel, select, actionChannel, cancelled, flush, getContext, setContext, takeEvery, takeLatest, throttle } from './internal/io';
export { take, takeMaybe, put, putResolve, all, race, call, apply, cps, fork, spawn, join, cancel, select, actionChannel, cancelled, flush, getContext, setContext, takeEvery, takeLatest, throttle } from './internal/io';
import middleware from './internal/middleware';
export default middleware;
export { runSaga } from './internal/runSaga';
export { END, eventChannel, channel } from './internal/channel';
export { buffers } from './internal/buffers';
export { takeEvery, takeLatest, throttle } from './internal/sagaHelpers';
export { delay, CANCEL } from './internal/utils';
export { END, eventChannel, channel, multicastChannel, stdChannel } from './internal/channel';
export { CANCEL } from './internal/symbols';
export { delay } from './internal/utils';
export { detach } from './internal/io';
import * as effects from './effects';
import * as utils from './utils';
export { effects, utils };
import * as buffers from './internal/buffers';
export { effects, utils, buffers };
import { kTrue, noop } from './utils';
export var BUFFER_OVERFLOW = "Channel's Buffer overflow!";
var BUFFER_OVERFLOW = "Channel's Buffer overflow!";
var ON_OVERFLOW_THROW = 1;

@@ -9,9 +7,13 @@ var ON_OVERFLOW_DROP = 2;

var ON_OVERFLOW_EXPAND = 4;
var zeroBuffer = {
isEmpty: kTrue,
put: noop,
take: noop
};
var zeroBuffer = { isEmpty: kTrue, put: noop, take: noop };
function ringBuffer(limit, overflowAction) {
if (limit === void 0) {
limit = 10;
}
function ringBuffer() {
var limit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
var overflowAction = arguments[1];
var arr = new Array(limit);

@@ -40,5 +42,7 @@ var length = 0;

var items = [];
while (length) {
items.push(take());
}
return items;

@@ -55,6 +59,8 @@ };

} else {
var doubledLimit = void 0;
var doubledLimit;
switch (overflowAction) {
case ON_OVERFLOW_THROW:
throw new Error(BUFFER_OVERFLOW);
case ON_OVERFLOW_SLIDE:

@@ -65,18 +71,16 @@ arr[pushIndex] = it;

break;
case ON_OVERFLOW_EXPAND:
doubledLimit = 2 * limit;
arr = flush();
length = arr.length;
pushIndex = arr.length;
popIndex = 0;
arr.length = doubledLimit;
limit = doubledLimit;
push(it);
break;
default:
// DROP
default: // DROP
}

@@ -90,18 +94,16 @@ }

export var buffers = {
none: function none() {
return zeroBuffer;
},
fixed: function fixed(limit) {
return ringBuffer(limit, ON_OVERFLOW_THROW);
},
dropping: function dropping(limit) {
return ringBuffer(limit, ON_OVERFLOW_DROP);
},
sliding: function sliding(limit) {
return ringBuffer(limit, ON_OVERFLOW_SLIDE);
},
expanding: function expanding(initialSize) {
return ringBuffer(initialSize, ON_OVERFLOW_EXPAND);
}
export var none = function none() {
return zeroBuffer;
};
export var fixed = function fixed(limit) {
return ringBuffer(limit, ON_OVERFLOW_THROW);
};
export var dropping = function dropping(limit) {
return ringBuffer(limit, ON_OVERFLOW_DROP);
};
export var sliding = function sliding(limit) {
return ringBuffer(limit, ON_OVERFLOW_SLIDE);
};
export var expanding = function expanding(initialSize) {
return ringBuffer(initialSize, ON_OVERFLOW_EXPAND);
};

@@ -1,50 +0,25 @@

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
import { is, check, remove, MATCH, internalErr, SAGA_ACTION } from './utils';
import { buffers } from './buffers';
import { CHANNEL_END_TYPE, MATCH, MULTICAST, SAGA_ACTION } from './symbols';
import { is, check, remove, once, internalErr } from './utils';
import * as buffers from './buffers';
import { asap } from './scheduler';
var CHANNEL_END_TYPE = '@@redux-saga/CHANNEL_END';
export var END = { type: CHANNEL_END_TYPE };
import * as matchers from './matcher';
export var END = {
type: CHANNEL_END_TYPE
};
export var isEnd = function isEnd(a) {
return a && a.type === CHANNEL_END_TYPE;
};
export function emitter() {
var subscribers = [];
function subscribe(sub) {
subscribers.push(sub);
return function () {
return remove(subscribers, sub);
};
var INVALID_BUFFER = 'invalid buffer passed to channel factory function';
var UNDEFINED_INPUT_ERROR = "Saga or channel was provided with an undefined action\nHints:\n - check that your Action Creator returns a non-undefined value\n - if the Saga was started using runSaga, check that your subscribe source provides the action to its listeners";
export function channel(buffer) {
if (buffer === void 0) {
buffer = buffers.expanding();
}
function emit(item) {
var arr = subscribers.slice();
for (var i = 0, len = arr.length; i < len; i++) {
arr[i](item);
}
}
return {
subscribe: subscribe,
emit: emit
};
}
export var INVALID_BUFFER = 'invalid buffer passed to channel factory function';
export var UNDEFINED_INPUT_ERROR = 'Saga was provided with an undefined action';
if (process.env.NODE_ENV !== 'production') {
UNDEFINED_INPUT_ERROR += '\nHints:\n - check that your Action Creator returns a non-undefined value\n - if the Saga was started using runSaga, check that your subscribe source provides the action to its listeners\n ';
}
export function channel() {
var buffer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : buffers.fixed();
var closed = false;
var takers = [];
check(buffer, is.buffer, INVALID_BUFFER);
if (process.env.NODE_ENV === 'development') {
check(buffer, is.buffer, INVALID_BUFFER);
}

@@ -55,2 +30,3 @@ function checkForbiddenStates() {

}
if (takers.length && !buffer.isEmpty()) {

@@ -63,16 +39,18 @@ throw internalErr('Cannot have pending takers with non empty buffer');

checkForbiddenStates();
check(input, is.notUndef, UNDEFINED_INPUT_ERROR);
if (process.env.NODE_ENV === 'development') {
check(input, is.notUndef, UNDEFINED_INPUT_ERROR);
}
if (closed) {
return;
}
if (!takers.length) {
return buffer.put(input);
}
for (var i = 0; i < takers.length; i++) {
var cb = takers[i];
if (!cb[MATCH] || cb[MATCH](input)) {
takers.splice(i, 1);
return cb(input);
}
}
var cb = takers[0];
takers.splice(0, 1);
cb(input);
}

@@ -82,4 +60,7 @@

checkForbiddenStates();
check(cb, is.func, "channel.take's callback must be a function");
if (process.env.NODE_ENV === 'development') {
check(cb, is.func, "channel.take's callback must be a function");
}
if (closed && buffer.isEmpty()) {

@@ -91,2 +72,3 @@ cb(END);

takers.push(cb);
cb.cancel = function () {

@@ -100,3 +82,7 @@ return remove(takers, cb);

checkForbiddenStates(); // TODO: check if some new state should be forbidden now
check(cb, is.func, "channel.flush' callback must be a function");
if (process.env.NODE_ENV === 'development') {
check(cb, is.func, "channel.flush' callback must be a function");
}
if (closed && buffer.isEmpty()) {

@@ -106,2 +92,3 @@ cb(END);

}
cb(buffer.flush());

@@ -112,9 +99,13 @@ }

checkForbiddenStates();
if (!closed) {
closed = true;
if (takers.length) {
var arr = takers;
takers = [];
for (var i = 0, len = arr.length; i < len; i++) {
arr[i](END);
var taker = arr[i];
taker(END);
}

@@ -129,46 +120,31 @@ }

flush: flush,
close: close,
get __takers__() {
return takers;
},
get __closed__() {
return closed;
}
close: close
};
}
export function eventChannel(subscribe) {
var buffer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : buffers.none();
var matcher = arguments[2];
/**
should be if(typeof matcher !== undefined) instead?
see PR #273 for a background discussion
**/
if (arguments.length > 2) {
check(matcher, is.func, 'Invalid match function passed to eventChannel');
export function eventChannel(subscribe, buffer) {
if (buffer === void 0) {
buffer = buffers.none();
}
var closed = false;
var unsubscribe;
var chan = channel(buffer);
var close = function close() {
if (!chan.__closed__) {
if (unsubscribe) {
unsubscribe();
}
chan.close();
if (is.func(unsubscribe)) {
unsubscribe();
}
chan.close();
};
var unsubscribe = subscribe(function (input) {
unsubscribe = subscribe(function (input) {
if (isEnd(input)) {
close();
closed = true;
return;
}
if (matcher && !matcher(input)) {
return;
}
chan.put(input);
});
if (chan.__closed__) {
unsubscribe();
}

@@ -179,2 +155,8 @@ if (!is.func(unsubscribe)) {

unsubscribe = once(unsubscribe);
if (closed) {
unsubscribe();
}
return {

@@ -186,25 +168,91 @@ take: chan.take,

}
export function multicastChannel() {
var _ref;
export function stdChannel(subscribe) {
var chan = eventChannel(function (cb) {
return subscribe(function (input) {
if (input[SAGA_ACTION]) {
cb(input);
return;
var closed = false;
var currentTakers = [];
var nextTakers = currentTakers;
var ensureCanMutateNextTakers = function ensureCanMutateNextTakers() {
if (nextTakers !== currentTakers) {
return;
}
nextTakers = currentTakers.slice();
}; // TODO: check if its possible to extract closing function and reuse it in both unicasts and multicasts
var close = function close() {
closed = true;
var takers = currentTakers = nextTakers;
for (var i = 0; i < takers.length; i++) {
var taker = takers[i];
taker(END);
}
nextTakers = [];
};
return _ref = {}, _ref[MULTICAST] = true, _ref.put = function put(input) {
// TODO: should I check forbidden state here? 1 of them is even impossible
// as we do not possibility of buffer here
if (process.env.NODE_ENV === 'development') {
check(input, is.notUndef, UNDEFINED_INPUT_ERROR);
}
if (closed) {
return;
}
if (isEnd(input)) {
close();
return;
}
var takers = currentTakers = nextTakers;
for (var i = 0; i < takers.length; i++) {
var taker = takers[i];
if (taker[MATCH](input)) {
taker.cancel();
taker(input);
}
asap(function () {
return cb(input);
});
}
}, _ref.take = function take(cb, matcher) {
if (matcher === void 0) {
matcher = matchers.wildcard;
}
if (closed) {
cb(END);
return;
}
cb[MATCH] = matcher;
ensureCanMutateNextTakers();
nextTakers.push(cb);
cb.cancel = once(function () {
ensureCanMutateNextTakers();
remove(nextTakers, cb);
});
});
}, _ref.close = close, _ref;
}
export function stdChannel() {
var chan = multicastChannel();
var put = chan.put;
return _extends({}, chan, {
take: function take(cb, matcher) {
if (arguments.length > 1) {
check(matcher, is.func, "channel.take's matcher argument must be a function");
cb[MATCH] = matcher;
}
chan.take(cb);
chan.put = function (input) {
if (input[SAGA_ACTION]) {
put(input);
return;
}
});
asap(function () {
return put(input);
});
};
return chan;
}

@@ -1,5 +0,4 @@

import { sym, is, ident, check, deprecate, updateIncentive, createSetContextWarning, SELF_CANCELLATION } from './utils';
import { IO, SELF_CANCELLATION } from './symbols';
import { is, identity, check, createSetContextWarning } from './utils';
import { takeEveryHelper, takeLatestHelper, throttleHelper } from './sagaHelpers';
var IO = /*#__PURE__*/sym('IO');
var TAKE = 'TAKE';

@@ -20,3 +19,2 @@ var PUT = 'PUT';

var SET_CONTEXT = 'SET_CONTEXT';
var TEST_HINT = '\n(HINT: if you are getting this errors in tests, consider using createMockTask from redux-saga/utils)';

@@ -31,24 +29,42 @@

export var detach = function detach(eff) {
check(asEffect.fork(eff), is.object, 'detach(eff): argument must be a fork effect');
if (process.env.NODE_ENV === 'development') {
check(asEffect.fork(eff), is.object, 'detach(eff): argument must be a fork effect');
}
eff[FORK].detached = true;
return eff;
};
export function take(patternOrChannel, multicastPattern) {
if (patternOrChannel === void 0) {
patternOrChannel = '*';
}
export function take() {
var patternOrChannel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '*';
if (arguments.length) {
if (process.env.NODE_ENV === 'development' && arguments.length) {
check(arguments[0], is.notUndef, 'take(patternOrChannel): patternOrChannel is undefined');
}
if (is.pattern(patternOrChannel)) {
return effect(TAKE, { pattern: patternOrChannel });
return effect(TAKE, {
pattern: patternOrChannel
});
}
if (is.multicast(patternOrChannel) && is.notUndef(multicastPattern) && is.pattern(multicastPattern)) {
return effect(TAKE, {
channel: patternOrChannel,
pattern: multicastPattern
});
}
if (is.channel(patternOrChannel)) {
return effect(TAKE, { channel: patternOrChannel });
return effect(TAKE, {
channel: patternOrChannel
});
}
throw new Error('take(patternOrChannel): argument ' + String(patternOrChannel) + ' is not valid channel or a valid pattern');
throw new Error("take(patternOrChannel): argument " + patternOrChannel + " is not valid channel or a valid pattern");
}
take.maybe = function () {
var eff = take.apply(undefined, arguments);
var takeMaybe = function takeMaybe() {
var eff = take.apply(void 0, arguments);
eff[TAKE].maybe = true;

@@ -58,19 +74,27 @@ return eff;

export var takem = /*#__PURE__*/deprecate(take.maybe, /*#__PURE__*/updateIncentive('takem', 'take.maybe'));
export { takeMaybe };
export function put(channel, action) {
if (process.env.NODE_ENV === 'development') {
if (arguments.length > 1) {
check(channel, is.notUndef, 'put(channel, action): argument channel is undefined');
check(channel, is.channel, "put(channel, action): argument " + channel + " is not a valid channel");
check(action, is.notUndef, 'put(channel, action): argument action is undefined');
} else {
check(channel, is.notUndef, 'put(action): argument action is undefined');
}
}
export function put(channel, action) {
if (arguments.length > 1) {
check(channel, is.notUndef, 'put(channel, action): argument channel is undefined');
check(channel, is.channel, 'put(channel, action): argument ' + channel + ' is not a valid channel');
check(action, is.notUndef, 'put(channel, action): argument action is undefined');
} else {
check(channel, is.notUndef, 'put(action): argument action is undefined');
if (is.undef(action)) {
action = channel;
channel = null;
}
return effect(PUT, { channel: channel, action: action });
return effect(PUT, {
channel: channel,
action: action
});
}
put.resolve = function () {
var eff = put.apply(undefined, arguments);
var putResolve = function putResolve() {
var eff = put.apply(void 0, arguments);
eff[PUT].resolve = true;

@@ -80,8 +104,6 @@ return eff;

put.sync = /*#__PURE__*/deprecate(put.resolve, /*#__PURE__*/updateIncentive('put.sync', 'put.resolve'));
export { putResolve };
export function all(effects) {
return effect(ALL, effects);
}
export function race(effects) {

@@ -92,5 +114,8 @@ return effect(RACE, effects);

function getFnCallDesc(meth, fn, args) {
check(fn, is.notUndef, meth + ': argument fn is undefined');
if (process.env.NODE_ENV === 'development') {
check(fn, is.notUndef, meth + ": argument fn is undefined");
}
var context = null;
if (is.array(fn)) {

@@ -105,12 +130,20 @@ var _fn = fn;

}
if (context && is.string(fn) && is.func(context[fn])) {
fn = context[fn];
}
check(fn, is.func, meth + ': argument ' + fn + ' is not a function');
return { context: context, fn: fn, args: args };
if (process.env.NODE_ENV === 'development') {
check(fn, is.func, meth + ": argument " + fn + " is not a function");
}
return {
context: context,
fn: fn,
args: args
};
}
export function call(fn) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];

@@ -121,11 +154,14 @@ }

}
export function apply(context, fn, args) {
if (args === void 0) {
args = [];
}
export function apply(context, fn) {
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
return effect(CALL, getFnCallDesc('apply', { context: context, fn: fn }, args));
return effect(CALL, getFnCallDesc('apply', {
context: context,
fn: fn
}, args));
}
export function cps(fn) {
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];

@@ -136,5 +172,4 @@ }

}
export function fork(fn) {
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
args[_key3 - 1] = arguments[_key3];

@@ -145,13 +180,11 @@ }

}
export function spawn(fn) {
for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
args[_key4 - 1] = arguments[_key4];
}
return detach(fork.apply(undefined, [fn].concat(args)));
return detach(fork.apply(void 0, [fn].concat(args)));
}
export function join() {
for (var _len5 = arguments.length, tasks = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
for (var _len5 = arguments.length, tasks = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
tasks[_key5] = arguments[_key5];

@@ -165,10 +198,14 @@ }

}
var task = tasks[0];
check(task, is.notUndef, 'join(task): argument task is undefined');
check(task, is.task, 'join(task): argument ' + task + ' is not a valid Task object ' + TEST_HINT);
if (process.env.NODE_ENV === 'development') {
check(task, is.notUndef, 'join(task): argument task is undefined');
check(task, is.task, "join(task): argument " + task + " is not a valid Task object " + TEST_HINT);
}
return effect(JOIN, task);
}
export function cancel() {
for (var _len6 = arguments.length, tasks = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
for (var _len6 = arguments.length, tasks = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
tasks[_key6] = arguments[_key6];

@@ -182,77 +219,94 @@ }

}
var task = tasks[0];
if (tasks.length === 1) {
if (process.env.NODE_ENV === 'development' && tasks.length === 1) {
check(task, is.notUndef, 'cancel(task): argument task is undefined');
check(task, is.task, 'cancel(task): argument ' + task + ' is not a valid Task object ' + TEST_HINT);
check(task, is.task, "cancel(task): argument " + task + " is not a valid Task object " + TEST_HINT);
}
return effect(CANCEL, task || SELF_CANCELLATION);
}
export function select(selector) {
if (selector === void 0) {
selector = identity;
}
export function select(selector) {
for (var _len7 = arguments.length, args = Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
for (var _len7 = arguments.length, args = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
args[_key7 - 1] = arguments[_key7];
}
if (arguments.length === 0) {
selector = ident;
} else {
check(selector, is.notUndef, 'select(selector,[...]): argument selector is undefined');
check(selector, is.func, 'select(selector,[...]): argument ' + selector + ' is not a function');
if (process.env.NODE_ENV === 'development' && arguments.length) {
check(arguments[0], is.notUndef, 'select(selector, [...]): argument selector is undefined');
check(selector, is.func, "select(selector, [...]): argument " + selector + " is not a function");
}
return effect(SELECT, { selector: selector, args: args });
return effect(SELECT, {
selector: selector,
args: args
});
}
/**
channel(pattern, [buffer]) => creates an event channel for store actions
channel(pattern, [buffer]) => creates a proxy channel for store actions
**/
export function actionChannel(pattern, buffer) {
check(pattern, is.notUndef, 'actionChannel(pattern,...): argument pattern is undefined');
if (arguments.length > 1) {
check(buffer, is.notUndef, 'actionChannel(pattern, buffer): argument buffer is undefined');
check(buffer, is.buffer, 'actionChannel(pattern, buffer): argument ' + buffer + ' is not a valid buffer');
if (process.env.NODE_ENV === 'development') {
check(pattern, is.notUndef, 'actionChannel(pattern,...): argument pattern is undefined');
if (arguments.length > 1) {
check(buffer, is.notUndef, 'actionChannel(pattern, buffer): argument buffer is undefined');
check(buffer, is.buffer, "actionChannel(pattern, buffer): argument " + buffer + " is not a valid buffer");
}
}
return effect(ACTION_CHANNEL, { pattern: pattern, buffer: buffer });
return effect(ACTION_CHANNEL, {
pattern: pattern,
buffer: buffer
});
}
export function cancelled() {
return effect(CANCELLED, {});
}
export function flush(channel) {
if (process.env.NODE_ENV === 'development') {
check(channel, is.channel, "flush(channel): argument " + channel + " is not valid channel");
}
export function flush(channel) {
check(channel, is.channel, 'flush(channel): argument ' + channel + ' is not valid channel');
return effect(FLUSH, channel);
}
export function getContext(prop) {
if (process.env.NODE_ENV === 'development') {
check(prop, is.string, "getContext(prop): argument " + prop + " is not a string");
}
export function getContext(prop) {
check(prop, is.string, 'getContext(prop): argument ' + prop + ' is not a string');
return effect(GET_CONTEXT, prop);
}
export function setContext(props) {
if (process.env.NODE_ENV === 'development') {
check(props, is.object, createSetContextWarning(null, props));
}
export function setContext(props) {
check(props, is.object, createSetContextWarning(null, props));
return effect(SET_CONTEXT, props);
}
export function takeEvery(patternOrChannel, worker) {
for (var _len8 = arguments.length, args = Array(_len8 > 2 ? _len8 - 2 : 0), _key8 = 2; _key8 < _len8; _key8++) {
for (var _len8 = arguments.length, args = new Array(_len8 > 2 ? _len8 - 2 : 0), _key8 = 2; _key8 < _len8; _key8++) {
args[_key8 - 2] = arguments[_key8];
}
return fork.apply(undefined, [takeEveryHelper, patternOrChannel, worker].concat(args));
return fork.apply(void 0, [takeEveryHelper, patternOrChannel, worker].concat(args));
}
export function takeLatest(patternOrChannel, worker) {
for (var _len9 = arguments.length, args = Array(_len9 > 2 ? _len9 - 2 : 0), _key9 = 2; _key9 < _len9; _key9++) {
for (var _len9 = arguments.length, args = new Array(_len9 > 2 ? _len9 - 2 : 0), _key9 = 2; _key9 < _len9; _key9++) {
args[_key9 - 2] = arguments[_key9];
}
return fork.apply(undefined, [takeLatestHelper, patternOrChannel, worker].concat(args));
return fork.apply(void 0, [takeLatestHelper, patternOrChannel, worker].concat(args));
}
export function throttle(ms, pattern, worker) {
for (var _len10 = arguments.length, args = Array(_len10 > 3 ? _len10 - 3 : 0), _key10 = 3; _key10 < _len10; _key10++) {
for (var _len10 = arguments.length, args = new Array(_len10 > 3 ? _len10 - 3 : 0), _key10 = 3; _key10 < _len10; _key10++) {
args[_key10 - 3] = arguments[_key10];
}
return fork.apply(undefined, [throttleHelper, ms, pattern, worker].concat(args));
return fork.apply(void 0, [throttleHelper, ms, pattern, worker].concat(args));
}

@@ -267,17 +321,47 @@

export var asEffect = {
take: /*#__PURE__*/createAsEffectType(TAKE),
put: /*#__PURE__*/createAsEffectType(PUT),
all: /*#__PURE__*/createAsEffectType(ALL),
race: /*#__PURE__*/createAsEffectType(RACE),
call: /*#__PURE__*/createAsEffectType(CALL),
cps: /*#__PURE__*/createAsEffectType(CPS),
fork: /*#__PURE__*/createAsEffectType(FORK),
join: /*#__PURE__*/createAsEffectType(JOIN),
cancel: /*#__PURE__*/createAsEffectType(CANCEL),
select: /*#__PURE__*/createAsEffectType(SELECT),
actionChannel: /*#__PURE__*/createAsEffectType(ACTION_CHANNEL),
cancelled: /*#__PURE__*/createAsEffectType(CANCELLED),
flush: /*#__PURE__*/createAsEffectType(FLUSH),
getContext: /*#__PURE__*/createAsEffectType(GET_CONTEXT),
setContext: /*#__PURE__*/createAsEffectType(SET_CONTEXT)
take:
/*#__PURE__*/
createAsEffectType(TAKE),
put:
/*#__PURE__*/
createAsEffectType(PUT),
all:
/*#__PURE__*/
createAsEffectType(ALL),
race:
/*#__PURE__*/
createAsEffectType(RACE),
call:
/*#__PURE__*/
createAsEffectType(CALL),
cps:
/*#__PURE__*/
createAsEffectType(CPS),
fork:
/*#__PURE__*/
createAsEffectType(FORK),
join:
/*#__PURE__*/
createAsEffectType(JOIN),
cancel:
/*#__PURE__*/
createAsEffectType(CANCEL),
select:
/*#__PURE__*/
createAsEffectType(SELECT),
actionChannel:
/*#__PURE__*/
createAsEffectType(ACTION_CHANNEL),
cancelled:
/*#__PURE__*/
createAsEffectType(CANCELLED),
flush:
/*#__PURE__*/
createAsEffectType(FLUSH),
getContext:
/*#__PURE__*/
createAsEffectType(GET_CONTEXT),
setContext:
/*#__PURE__*/
createAsEffectType(SET_CONTEXT)
};

@@ -1,54 +0,44 @@

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
import { is, check, object, createSetContextWarning } from './utils';
import { emitter } from './channel';
import { ident } from './utils';
import { stdChannel } from './channel';
import { identity } from './utils';
import { runSaga } from './runSaga';
export default function sagaMiddlewareFactory(_ref) {
if (_ref === void 0) {
_ref = {};
}
export default function sagaMiddlewareFactory() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var _ref2 = _ref,
_ref2$context = _ref2.context,
context = _ref2$context === void 0 ? {} : _ref2$context,
options = _objectWithoutProperties(_ref2, ["context"]);
var _ref$context = _ref.context,
context = _ref$context === undefined ? {} : _ref$context,
options = _objectWithoutProperties(_ref, ['context']);
var sagaMonitor = options.sagaMonitor,
logger = options.logger,
onError = options.onError;
onError = options.onError,
effectMiddlewares = options.effectMiddlewares;
if (process.env.NODE_ENV === 'development') {
if (is.notUndef(logger)) {
check(logger, is.func, 'options.logger passed to the Saga middleware is not a function!');
}
if (is.func(options)) {
if (process.env.NODE_ENV === 'production') {
throw new Error('Saga middleware no longer accept Generator functions. Use sagaMiddleware.run instead');
} else {
throw new Error('You passed a function to the Saga middleware. You are likely trying to start a Saga by directly passing it to the middleware. This is no longer possible starting from 0.10.0. To run a Saga, you must do it dynamically AFTER mounting the middleware into the store.\n Example:\n import createSagaMiddleware from \'redux-saga\'\n ... other imports\n\n const sagaMiddleware = createSagaMiddleware()\n const store = createStore(reducer, applyMiddleware(sagaMiddleware))\n sagaMiddleware.run(saga, ...args)\n ');
if (is.notUndef(onError)) {
check(onError, is.func, 'options.onError passed to the Saga middleware is not a function!');
}
}
if (logger && !is.func(logger)) {
throw new Error('`options.logger` passed to the Saga middleware is not a function!');
if (is.notUndef(options.emitter)) {
check(options.emitter, is.func, 'options.emitter passed to the Saga middleware is not a function!');
}
}
if (process.env.NODE_ENV === 'development' && options.onerror) {
throw new Error('`options.onerror` was removed. Use `options.onError` instead.');
}
if (onError && !is.func(onError)) {
throw new Error('`options.onError` passed to the Saga middleware is not a function!');
}
if (options.emitter && !is.func(options.emitter)) {
throw new Error('`options.emitter` passed to the Saga middleware is not a function!');
}
function sagaMiddleware(_ref2) {
var getState = _ref2.getState,
dispatch = _ref2.dispatch;
var sagaEmitter = emitter();
sagaEmitter.emit = (options.emitter || ident)(sagaEmitter.emit);
function sagaMiddleware(_ref3) {
var getState = _ref3.getState,
dispatch = _ref3.dispatch;
var channel = stdChannel();
channel.put = (options.emitter || identity)(channel.put);
sagaMiddleware.run = runSaga.bind(null, {
context: context,
subscribe: sagaEmitter.subscribe,
channel: channel,
dispatch: dispatch,

@@ -58,5 +48,5 @@ getState: getState,

logger: logger,
onError: onError
onError: onError,
effectMiddlewares: effectMiddlewares
});
return function (next) {

@@ -67,4 +57,6 @@ return function (action) {

}
var result = next(action); // hit reducers
sagaEmitter.emit(action);
channel.put(action);
return result;

@@ -80,3 +72,6 @@ };

sagaMiddleware.setContext = function (props) {
check(props, is.object, createSetContextWarning('sagaMiddleware', props));
if (process.env.NODE_ENV === 'development') {
check(props, is.object, createSetContextWarning('sagaMiddleware', props));
}
object.assign(context, props);

@@ -83,0 +78,0 @@ };

@@ -1,18 +0,16 @@

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _defineEnumerableProperties(obj, descs) { for (var key in descs) { var desc = descs[key]; desc.configurable = desc.enumerable = true; if ("value" in desc) desc.writable = true; Object.defineProperty(obj, key, desc); } return obj; }
import { noop, kTrue, is, log as _log, check, deferred, uid as nextEffectId, array, remove, object, TASK, CANCEL, SELF_CANCELLATION, makeIterator, createSetContextWarning, deprecate, updateIncentive } from './utils';
import { CANCEL, CHANNEL_END as CHANNEL_END_SYMBOL, TASK, TASK_CANCEL as TASK_CANCEL_SYMBOL, SELF_CANCELLATION } from './symbols';
import { noop, is, log as _log, check, deferred, uid as nextEffectId, array, remove, object, makeIterator, createSetContextWarning } from './utils';
import { asap, suspend, flush } from './scheduler';
import { asEffect } from './io';
import { stdChannel as _stdChannel, eventChannel, isEnd } from './channel';
import { buffers } from './buffers';
import { channel, isEnd } from './channel';
import matcher from './matcher'; // TODO: check if this hacky toString stuff is needed
// also check again whats the difference between CHANNEL_END and CHANNEL_END_TYPE
// maybe this could become MAYBE_END
// I guess this gets exported so takeMaybe result can be checked
export var NOT_ITERATOR_ERROR = 'proc first argument (Saga function result) must be an iterator';
export var CHANNEL_END = {
toString: function toString() {
return '@@redux-saga/CHANNEL_END';
return CHANNEL_END_SYMBOL;
}

@@ -22,36 +20,5 @@ };

toString: function toString() {
return '@@redux-saga/TASK_CANCEL';
return TASK_CANCEL_SYMBOL;
}
};
var matchers = {
wildcard: function wildcard() {
return kTrue;
},
default: function _default(pattern) {
return (typeof pattern === 'undefined' ? 'undefined' : _typeof(pattern)) === 'symbol' ? function (input) {
return input.type === pattern;
} : function (input) {
return input.type === String(pattern);
};
},
array: function array(patterns) {
return function (input) {
return patterns.some(function (p) {
return matcher(p)(input);
});
};
},
predicate: function predicate(_predicate) {
return function (input) {
return _predicate(input);
};
}
};
function matcher(pattern) {
// prettier-ignore
return (pattern === '*' ? matchers.wildcard : is.array(pattern) ? matchers.array : is.stringableFunc(pattern) ? matchers.default : is.func(pattern) ? matchers.predicate : matchers.default)(pattern);
}
/**

@@ -72,5 +39,6 @@ Used to track a parent task and its forks

**/
function forkQueue(name, mainTask, cb) {
var tasks = [],
result = void 0,
result,
completed = false;

@@ -86,2 +54,3 @@ addTask(mainTask);

tasks.push(task);
task.cont = function (res, isErr) {

@@ -94,2 +63,3 @@ if (completed) {

task.cont = noop;
if (isErr) {

@@ -101,2 +71,3 @@ abort(res);

}
if (!tasks.length) {

@@ -107,4 +78,4 @@ completed = true;

}
};
// task.cont.cancel = task.cancel
}; // task.cont.cancel = task.cancel
}

@@ -116,2 +87,3 @@

}
completed = true;

@@ -147,7 +119,7 @@ tasks.forEach(function (t) {

return fn;
}
} // catch synchronous failures; see #152 and #441
// catch synchronous failures; see #152 and #441
var result = void 0,
error = void 0;
var result, error;
try {

@@ -157,19 +129,27 @@ result = fn.apply(context, args);

error = err;
}
} // i.e. a generator function returns an iterator
// i.e. a generator function returns an iterator
if (is.iterator(result)) {
return result;
}
} // do not bubble up synchronous failures for detached forks
// instead create a failed task. See #152 and #441
// do not bubble up synchronous failures for detached forks
// instead create a failed task. See #152 and #441
return error ? makeIterator(function () {
throw error;
}) : makeIterator(function () {
var pc = void 0;
var eff = { done: false, value: result };
var pc;
var eff = {
done: false,
value: result
};
var ret = function ret(value) {
return { done: true, value: value };
return {
done: true,
value: value
};
};
return function (arg) {

@@ -186,28 +166,34 @@ if (!pc) {

var wrapHelper = function wrapHelper(helper) {
return { fn: helper };
};
export default function proc(iterator, stdChannel, dispatch, getState, parentContext, options, parentEffectId, name, cont) {
if (dispatch === void 0) {
dispatch = noop;
}
export default function proc(iterator) {
var subscribe = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
return noop;
};
var dispatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop;
var getState = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : noop;
var parentContext = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
var parentEffectId = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
var name = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 'anonymous';
var cont = arguments[8];
if (getState === void 0) {
getState = noop;
}
check(iterator, is.iterator, NOT_ITERATOR_ERROR);
if (parentContext === void 0) {
parentContext = {};
}
var effectsString = '[...effects]';
var runParallelEffect = deprecate(runAllEffect, updateIncentive(effectsString, 'all(' + effectsString + ')'));
if (options === void 0) {
options = {};
}
var sagaMonitor = options.sagaMonitor,
logger = options.logger,
onError = options.onError;
if (parentEffectId === void 0) {
parentEffectId = 0;
}
if (name === void 0) {
name = 'anonymous';
}
var _options = options,
sagaMonitor = _options.sagaMonitor,
logger = _options.logger,
onError = _options.onError,
middleware = _options.middleware;
var log = logger || _log;
var logError = function logError(err) {

@@ -217,8 +203,8 @@ var message = err.sagaStack;

if (!message && err.stack) {
message = err.stack.split('\n')[0].indexOf(err.message) !== -1 ? err.stack : 'Error: ' + err.message + '\n' + err.stack;
message = err.stack.split('\n')[0].indexOf(err.message) !== -1 ? err.stack : "Error: " + err.message + "\n" + err.stack;
}
log('error', 'uncaught at ' + name, message || err.message || err);
log('error', "uncaught at " + name, message || err.message || err);
};
var stdChannel = _stdChannel(subscribe);
var taskContext = Object.create(parentContext);

@@ -230,4 +216,4 @@ /**

**/
next.cancel = noop;
/**

@@ -237,9 +223,14 @@ Creates a new task descriptor for this generator, We'll also create a main task

**/
var task = newTask(parentEffectId, name, iterator, cont);
var mainTask = { name: name, cancel: cancelMain, isRunning: true };
var mainTask = {
name: name,
cancel: cancelMain,
isRunning: true
};
var taskQueue = forkQueue(name, mainTask, end);
/**
cancellation of the main task. We'll simply resume the Generator with a Cancel
**/
function cancelMain() {

@@ -251,3 +242,2 @@ if (mainTask.isRunning && !mainTask.isCancelled) {

}
/**

@@ -260,2 +250,4 @@ This may be called by a parent generator to trigger/propagate cancellation

**/
function cancel() {

@@ -272,2 +264,3 @@ /**

**/
end(TASK_CANCEL);

@@ -280,13 +273,11 @@ }

**/
cont && (cont.cancel = cancel);
// tracks the running status
iterator._isRunning = true;
// kicks up the generator
next();
cont && (cont.cancel = cancel); // tracks the running status
// then return the task descriptor to the caller
iterator._isRunning = true; // kicks up the generator
next(); // then return the task descriptor to the caller
return task;
/**

@@ -297,2 +288,3 @@ This is the generator driver

**/
function next(arg, isErr) {

@@ -305,3 +297,4 @@ // Preventive measure. If we end up here, then there is really something wrong

try {
var result = void 0;
var result;
if (isErr) {

@@ -320,2 +313,3 @@ result = iterator.throw(arg);

**/
next.cancel();

@@ -326,6 +320,12 @@ /**

**/
result = is.func(iterator.return) ? iterator.return(TASK_CANCEL) : { done: true, value: TASK_CANCEL };
result = is.func(iterator.return) ? iterator.return(TASK_CANCEL) : {
done: true,
value: TASK_CANCEL
};
} else if (arg === CHANNEL_END) {
// We get CHANNEL_END by taking from a channel that ended using `take` (and not `takem` used to trap End of channels)
result = is.func(iterator.return) ? iterator.return() : { done: true };
result = is.func(iterator.return) ? iterator.return() : {
done: true
};
} else {

@@ -336,3 +336,3 @@ result = iterator.next(arg);

if (!result.done) {
runEffect(result.value, parentEffectId, '', next);
digestEffect(result.value, parentEffectId, '', next);
} else {

@@ -349,2 +349,3 @@ /**

}
mainTask.isMainRunning = false;

@@ -356,4 +357,4 @@ mainTask.cont(error, true);

function end(result, isErr) {
iterator._isRunning = false;
stdChannel.close();
iterator._isRunning = false; // stdChannel.close()
if (!isErr) {

@@ -365,6 +366,7 @@ iterator._result = result;

Object.defineProperty(result, 'sagaStack', {
value: 'at ' + name + ' \n ' + (result.sagaStack || result.stack),
value: "at " + name + " \n " + (result.sagaStack || result.stack),
configurable: true
});
}
if (!task.cont) {

@@ -374,5 +376,7 @@ if (result instanceof Error && onError) {

} else {
// TODO: could we skip this when _deferredEnd is attached?
logError(result);
}
}
iterator._error = result;

@@ -382,2 +386,3 @@ iterator._isAborted = true;

}
task.cont && task.cont(result, isErr);

@@ -390,9 +395,41 @@ task.joiners.forEach(function (j) {

function runEffect(effect, parentEffectId) {
var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var cb = arguments[3];
function runEffect(effect, effectId, label, currCb) {
if (label === void 0) {
label = '';
}
/**
each effect runner must attach its own logic of cancellation to the provided callback
it allows this generator to propagate cancellation downward.
ATTENTION! effect runners must setup the cancel logic by setting cb.cancel = [cancelMethod]
And the setup must occur before calling the callback
This is a sort of inversion of control: called async functions are responsible
of completing the flow by calling the provided continuation; while caller functions
are responsible for aborting the current flow by calling the attached cancel function
Library users can attach their own cancellation logic to promises by defining a
promise[CANCEL] method in their returned promises
ATTENTION! calling cancel must have no effect on an already completed or cancelled effect
**/
var data; // prettier-ignore
return (// Non declarative effect
is.promise(effect) ? resolvePromise(effect, currCb) : is.iterator(effect) ? resolveIterator(effect, effectId, name, currCb) // declarative effects
: (data = asEffect.take(effect)) ? runTakeEffect(data, currCb) : (data = asEffect.put(effect)) ? runPutEffect(data, currCb) : (data = asEffect.all(effect)) ? runAllEffect(data, effectId, currCb) : (data = asEffect.race(effect)) ? runRaceEffect(data, effectId, currCb) : (data = asEffect.call(effect)) ? runCallEffect(data, effectId, currCb) : (data = asEffect.cps(effect)) ? runCPSEffect(data, currCb) : (data = asEffect.fork(effect)) ? runForkEffect(data, effectId, currCb) : (data = asEffect.join(effect)) ? runJoinEffect(data, currCb) : (data = asEffect.cancel(effect)) ? runCancelEffect(data, currCb) : (data = asEffect.select(effect)) ? runSelectEffect(data, currCb) : (data = asEffect.actionChannel(effect)) ? runChannelEffect(data, currCb) : (data = asEffect.flush(effect)) ? runFlushEffect(data, currCb) : (data = asEffect.cancelled(effect)) ? runCancelledEffect(data, currCb) : (data = asEffect.getContext(effect)) ? runGetContextEffect(data, currCb) : (data = asEffect.setContext(effect)) ? runSetContextEffect(data, currCb) :
/* anything else returned as is */
currCb(effect)
);
}
function digestEffect(effect, parentEffectId, label, cb) {
if (label === void 0) {
label = '';
}
var effectId = nextEffectId();
sagaMonitor && sagaMonitor.effectTriggered({ effectId: effectId, parentEffectId: parentEffectId, label: label, effect: effect });
sagaMonitor && sagaMonitor.effectTriggered({
effectId: effectId,
parentEffectId: parentEffectId,
label: label,
effect: effect
});
/**

@@ -403,5 +440,5 @@ completion callback and cancel callback are mutually exclusive

**/
var effectSettled = void 0;
// Completion callback passed to the appropriate effect runner
var effectSettled; // Completion callback passed to the appropriate effect runner
function currCb(res, isErr) {

@@ -414,11 +451,13 @@ if (effectSettled) {

cb.cancel = noop; // defensive measure
if (sagaMonitor) {
isErr ? sagaMonitor.effectRejected(effectId, res) : sagaMonitor.effectResolved(effectId, res);
}
cb(res, isErr);
}
// tracks down the current cancel
currCb.cancel = noop;
} // tracks down the current cancel
// setup cancellation logic on the parent cb
currCb.cancel = noop; // setup cancellation logic on the parent cb
cb.cancel = function () {

@@ -436,2 +475,3 @@ // prevents cancelling an already completed effect

**/
try {

@@ -442,28 +482,20 @@ currCb.cancel();

}
currCb.cancel = noop; // defensive measure
sagaMonitor && sagaMonitor.effectCancelled(effectId);
};
}; // if one can find a way to decouple runEffect from closure variables
// so it could be the call to it could be referentially transparent
// this potentially could be simplified, finalRunEffect created beforehand
// and this part of the code wouldnt have to know about middleware stuff
/**
each effect runner must attach its own logic of cancellation to the provided callback
it allows this generator to propagate cancellation downward.
ATTENTION! effect runners must setup the cancel logic by setting cb.cancel = [cancelMethod]
And the setup must occur before calling the callback
This is a sort of inversion of control: called async functions are responsible
for completing the flow by calling the provided continuation; while caller functions
are responsible for aborting the current flow by calling the attached cancel function
Library users can attach their own cancellation logic to promises by defining a
promise[CANCEL] method in their returned promises
ATTENTION! calling cancel must have no effect on an already completed or cancelled effect
**/
var data = void 0;
// prettier-ignore
return (
// Non declarative effect
is.promise(effect) ? resolvePromise(effect, currCb) : is.helper(effect) ? runForkEffect(wrapHelper(effect), effectId, currCb) : is.iterator(effect) ? resolveIterator(effect, effectId, name, currCb)
// declarative effects
: is.array(effect) ? runParallelEffect(effect, effectId, currCb) : (data = asEffect.take(effect)) ? runTakeEffect(data, currCb) : (data = asEffect.put(effect)) ? runPutEffect(data, currCb) : (data = asEffect.all(effect)) ? runAllEffect(data, effectId, currCb) : (data = asEffect.race(effect)) ? runRaceEffect(data, effectId, currCb) : (data = asEffect.call(effect)) ? runCallEffect(data, effectId, currCb) : (data = asEffect.cps(effect)) ? runCPSEffect(data, currCb) : (data = asEffect.fork(effect)) ? runForkEffect(data, effectId, currCb) : (data = asEffect.join(effect)) ? runJoinEffect(data, currCb) : (data = asEffect.cancel(effect)) ? runCancelEffect(data, currCb) : (data = asEffect.select(effect)) ? runSelectEffect(data, currCb) : (data = asEffect.actionChannel(effect)) ? runChannelEffect(data, currCb) : (data = asEffect.flush(effect)) ? runFlushEffect(data, currCb) : (data = asEffect.cancelled(effect)) ? runCancelledEffect(data, currCb) : (data = asEffect.getContext(effect)) ? runGetContextEffect(data, currCb) : (data = asEffect.setContext(effect)) ? runSetContextEffect(data, currCb) : /* anything else returned as is */currCb(effect)
);
if (is.func(middleware)) {
middleware(function (eff) {
return runEffect(eff, effectId, label, currCb);
})(effect);
return;
}
runEffect(effect, effectId, label, currCb);
}

@@ -473,2 +505,3 @@

var cancelPromise = promise[CANCEL];
if (is.func(cancelPromise)) {

@@ -480,5 +513,4 @@ cb.cancel = cancelPromise;

};
// TODO: add support for the fetch API, whenever they get around to
// adding cancel support
}
promise.then(cb, function (error) {

@@ -490,19 +522,32 @@ return cb(error, true);

function resolveIterator(iterator, effectId, name, cb) {
proc(iterator, subscribe, dispatch, getState, taskContext, options, effectId, name, cb);
proc(iterator, stdChannel, dispatch, getState, taskContext, options, effectId, name, cb);
}
function runTakeEffect(_ref2, cb) {
var channel = _ref2.channel,
var _ref2$channel = _ref2.channel,
channel = _ref2$channel === void 0 ? stdChannel : _ref2$channel,
pattern = _ref2.pattern,
maybe = _ref2.maybe;
channel = channel || stdChannel;
var takeCb = function takeCb(inp) {
return inp instanceof Error ? cb(inp, true) : isEnd(inp) && !maybe ? cb(CHANNEL_END) : cb(inp);
var takeCb = function takeCb(input) {
if (input instanceof Error) {
cb(input, true);
return;
}
if (isEnd(input) && !maybe) {
cb(CHANNEL_END);
return;
}
cb(input);
};
try {
channel.take(takeCb, matcher(pattern));
channel.take(takeCb, is.notUndef(pattern) ? matcher(pattern) : null);
} catch (err) {
return cb(err, true);
cb(err, true);
return;
}
cb.cancel = takeCb.cancel;

@@ -522,9 +567,12 @@ }

asap(function () {
var result = void 0;
var result;
try {
result = (channel ? channel.put : dispatch)(action);
} catch (error) {
// If we have a channel or `put.resolve` was used then bubble up the error.
if (channel || resolve) return cb(error, true);
logError(error);
logError(error); // TODO: should such error here be passed to `onError`?
// or is it already if we dropped error swallowing
cb(error, true);
return;
}

@@ -535,6 +583,6 @@

} else {
return cb(result);
cb(result);
return;
}
});
// Put effects are non cancellables
}); // Put effects are non cancellables
}

@@ -546,10 +594,11 @@

args = _ref4.args;
var result; // catch synchronous failures; see #152
var result = void 0;
// catch synchronous failures; see #152
try {
result = fn.apply(context, args);
} catch (error) {
return cb(error, true);
cb(error, true);
return;
}
return is.promise(result) ? resolvePromise(result, cb) : is.iterator(result) ? resolveIterator(result, effectId, fn.name, cb) : cb(result);

@@ -565,3 +614,2 @@ }

// by setting cancel field on the cb
// catch synchronous failures; see #152

@@ -572,3 +620,5 @@ try {

};
fn.apply(context, args.concat(cpsCb));
if (cpsCb.cancel) {

@@ -580,3 +630,4 @@ cb.cancel = function () {

} catch (error) {
return cb(error, true);
cb(error, true);
return;
}

@@ -590,9 +641,13 @@ }

detached = _ref6.detached;
var taskIterator = createTaskIterator({
context: context,
fn: fn,
args: args
});
var taskIterator = createTaskIterator({ context: context, fn: fn, args: args });
try {
suspend();
var _task = proc(taskIterator, subscribe, dispatch, getState, taskContext, options, effectId, fn.name, detached ? null : noop);
var _task = proc(taskIterator, stdChannel, dispatch, getState, taskContext, options, effectId, fn.name, detached ? null : noop);
if (detached) {

@@ -612,4 +667,4 @@ cb(_task);

flush();
}
// Fork effects are non cancellables
} // Fork effects are non cancellables
}

@@ -619,6 +674,11 @@

if (t.isRunning()) {
var joiner = { task: task, cb: cb };
var joiner = {
task: task,
cb: cb
};
cb.cancel = function () {
return remove(t.joiners, joiner);
};
t.joiners.push(joiner);

@@ -634,7 +694,8 @@ } else {

}
if (taskToCancel.isRunning()) {
taskToCancel.cancel();
}
cb();
// cancel effects are non cancellables
cb(); // cancel effects are non cancellables
}

@@ -646,7 +707,8 @@

if (!keys.length) {
return cb(is.array(effects) ? [] : {});
cb(is.array(effects) ? [] : {});
return;
}
var completedCount = 0;
var completed = void 0;
var completed;
var results = {};

@@ -658,3 +720,5 @@ var childCbs = {};

completed = true;
cb(is.array(effects) ? array.from(_extends({}, results, { length: keys.length })) : results);
cb(is.array(effects) ? array.from(_extends({}, results, {
length: keys.length
})) : results);
}

@@ -668,2 +732,3 @@ }

}
if (isErr || isEnd(res) || res === CHANNEL_END || res === TASK_CANCEL) {

@@ -678,2 +743,3 @@ cb.cancel();

};
chCbAtKey.cancel = noop;

@@ -693,3 +759,3 @@ childCbs[key] = chCbAtKey;

keys.forEach(function (key) {
return runEffect(effects[key], effectId, key, childCbs[key]);
return digestEffect(effects[key], effectId, key, childCbs[key]);
});

@@ -699,6 +765,5 @@ }

function runRaceEffect(effects, effectId, cb) {
var completed = void 0;
var completed;
var keys = Object.keys(effects);
var childCbs = {};
keys.forEach(function (key) {

@@ -720,5 +785,8 @@ var chCbAtKey = function chCbAtKey(res, isErr) {

var response = (_response = {}, _response[key] = res, _response);
cb(is.array(effects) ? [].slice.call(_extends({}, response, { length: keys.length })) : response);
cb(is.array(effects) ? [].slice.call(_extends({}, response, {
length: keys.length
})) : response);
}
};
chCbAtKey.cancel = noop;

@@ -737,2 +805,3 @@ childCbs[key] = chCbAtKey;

};
keys.forEach(function (key) {

@@ -742,3 +811,4 @@ if (completed) {

}
runEffect(effects[key], effectId, key, childCbs[key]);
digestEffect(effects[key], effectId, key, childCbs[key]);
});

@@ -752,3 +822,3 @@ }

try {
var state = selector.apply(undefined, [getState()].concat(args));
var state = selector.apply(void 0, [getState()].concat(args));
cb(state);

@@ -763,6 +833,16 @@ } catch (error) {

buffer = _ref8.buffer;
// TODO: rethink how END is handled
var chan = channel(buffer);
var match = matcher(pattern);
var match = matcher(pattern);
match.pattern = pattern;
cb(eventChannel(subscribe, buffer || buffers.fixed(), match));
var taker = function taker(action) {
if (!isEnd(action)) {
stdChannel.take(taker, match);
}
chan.put(action);
};
stdChannel.take(taker, match);
cb(chan);
}

@@ -788,16 +868,22 @@

function newTask(id, name, iterator, cont) {
var _done, _ref9, _mutatorMap;
var _ref9;
iterator._deferredEnd = null;
return _ref9 = {}, _ref9[TASK] = true, _ref9.id = id, _ref9.name = name, _done = 'done', _mutatorMap = {}, _mutatorMap[_done] = _mutatorMap[_done] || {}, _mutatorMap[_done].get = function () {
return _ref9 = {}, _ref9[TASK] = true, _ref9.id = id, _ref9.name = name, _ref9.toPromise = function toPromise() {
if (iterator._deferredEnd) {
return iterator._deferredEnd.promise;
} else {
var def = deferred();
iterator._deferredEnd = def;
if (!iterator._isRunning) {
iterator._error ? def.reject(iterator._error) : def.resolve(iterator._result);
}
var def = deferred();
iterator._deferredEnd = def;
if (!iterator._isRunning) {
if (iterator._isAborted) {
def.reject(iterator._error);
} else {
def.resolve(iterator._result);
}
return def.promise;
}
return def.promise;
}, _ref9.cont = cont, _ref9.joiners = [], _ref9.cancel = cancel, _ref9.isRunning = function isRunning() {

@@ -814,6 +900,9 @@ return iterator._isRunning;

}, _ref9.setContext = function setContext(props) {
check(props, is.object, createSetContextWarning('task', props));
if (process.env.NODE_ENV === 'development') {
check(props, is.object, createSetContextWarning('task', props));
}
object.assign(taskContext, props);
}, _defineEnumerableProperties(_ref9, _mutatorMap), _ref9;
}, _ref9;
}
}

@@ -1,36 +0,31 @@

import { is, check, uid as nextSagaId, wrapSagaDispatch, noop, log } from './utils';
import { compose } from 'redux';
import { is, check, uid as nextSagaId, wrapSagaDispatch, noop } from './utils';
import proc from './proc';
var RUN_SAGA_SIGNATURE = 'runSaga(storeInterface, saga, ...args)';
var NON_GENERATOR_ERR = RUN_SAGA_SIGNATURE + ': saga argument must be a Generator function!';
export function runSaga(storeInterface, saga) {
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
import { stdChannel } from './channel';
var RUN_SAGA_SIGNATURE = 'runSaga(options, saga, ...args)';
var NON_GENERATOR_ERR = RUN_SAGA_SIGNATURE + ": saga argument must be a Generator function!";
export function runSaga(options, saga) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
var iterator = void 0;
if (is.iterator(storeInterface)) {
if (process.env.NODE_ENV === 'development') {
log('warn', 'runSaga(iterator, storeInterface) has been deprecated in favor of ' + RUN_SAGA_SIGNATURE);
}
iterator = storeInterface;
storeInterface = saga;
} else {
if (process.env.NODE_ENV === 'development') {
check(saga, is.func, NON_GENERATOR_ERR);
iterator = saga.apply(undefined, args);
check(iterator, is.iterator, NON_GENERATOR_ERR);
}
var _storeInterface = storeInterface,
subscribe = _storeInterface.subscribe,
dispatch = _storeInterface.dispatch,
getState = _storeInterface.getState,
context = _storeInterface.context,
sagaMonitor = _storeInterface.sagaMonitor,
logger = _storeInterface.logger,
onError = _storeInterface.onError;
var iterator = saga.apply(void 0, args);
if (process.env.NODE_ENV === 'development') {
check(iterator, is.iterator, NON_GENERATOR_ERR);
}
var _options$channel = options.channel,
channel = _options$channel === void 0 ? stdChannel() : _options$channel,
dispatch = options.dispatch,
getState = options.getState,
context = options.context,
sagaMonitor = options.sagaMonitor,
logger = options.logger,
effectMiddlewares = options.effectMiddlewares,
onError = options.onError;
var effectId = nextSagaId();

@@ -45,7 +40,29 @@

sagaMonitor.actionDispatched = sagaMonitor.actionDispatched || noop;
sagaMonitor.effectTriggered({
effectId: effectId,
root: true,
parentEffectId: 0,
effect: {
root: true,
saga: saga,
args: args
}
});
}
sagaMonitor.effectTriggered({ effectId: effectId, root: true, parentEffectId: 0, effect: { root: true, saga: saga, args: args } });
if ((process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') && is.notUndef(effectMiddlewares)) {
var MIDDLEWARE_TYPE_ERROR = 'effectMiddlewares must be an array of functions';
check(effectMiddlewares, is.array, MIDDLEWARE_TYPE_ERROR);
effectMiddlewares.forEach(function (effectMiddleware) {
return check(effectMiddleware, is.func, MIDDLEWARE_TYPE_ERROR);
});
}
var task = proc(iterator, subscribe, wrapSagaDispatch(dispatch), getState, context, { sagaMonitor: sagaMonitor, logger: logger, onError: onError }, effectId, saga.name);
var middleware = effectMiddlewares && compose.apply(void 0, effectMiddlewares);
var task = proc(iterator, channel, wrapSagaDispatch(dispatch), getState, context, {
sagaMonitor: sagaMonitor,
logger: logger,
onError: onError,
middleware: middleware
}, effectId, saga.name);

@@ -52,0 +69,0 @@ if (sagaMonitor) {

import { is, makeIterator } from '../utils';
var done = { done: true, value: undefined };
var done = {
done: true,
value: undefined
};
export var qEnd = {};
export function safeName(patternOrChannel) {
if (is.channel(patternOrChannel)) {
return 'channel';
} else if (Array.isArray(patternOrChannel)) {
return String(patternOrChannel.map(function (entry) {
return String(entry);
}));
} else {
}
if (is.stringableFunc(patternOrChannel)) {
return String(patternOrChannel);
}
}
export default function fsmIterator(fsm, q0) {
var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'iterator';
if (is.func(patternOrChannel)) {
return patternOrChannel.name;
}
var updateState = void 0,
return String(patternOrChannel);
}
export default function fsmIterator(fsm, q0, name) {
var updateState,
qNext = q0;

@@ -48,3 +50,3 @@

return next(null, error);
}, name, true);
}, name);
}
import takeEveryHelper from './takeEvery';
import takeLatestHelper from './takeLatest';
import throttleHelper from './throttle';
import { deprecate } from '../utils';
var deprecationWarning = function deprecationWarning(helperName) {
return 'import { ' + helperName + ' } from \'redux-saga\' has been deprecated in favor of import { ' + helperName + ' } from \'redux-saga/effects\'.\nThe latter will not work with yield*, as helper effects are wrapped automatically for you in fork effect.\nTherefore yield ' + helperName + ' will return task descriptor to your saga and execute next lines of code.';
};
var takeEvery = /*#__PURE__*/deprecate(takeEveryHelper, /*#__PURE__*/deprecationWarning('takeEvery'));
var takeLatest = /*#__PURE__*/deprecate(takeLatestHelper, /*#__PURE__*/deprecationWarning('takeLatest'));
var throttle = /*#__PURE__*/deprecate(throttleHelper, /*#__PURE__*/deprecationWarning('throttle'));
export { takeEvery, takeLatest, throttle, takeEveryHelper, takeLatestHelper, throttleHelper };
export { takeEveryHelper, takeLatestHelper, throttleHelper };
import fsmIterator, { qEnd, safeName } from './fsmIterator';
import { take, fork } from '../io';
import { END } from '../channel';
export default function takeEvery(patternOrChannel, worker) {
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
var yTake = { done: false, value: take(patternOrChannel) };
var yTake = {
done: false,
value: take(patternOrChannel)
};
var yFork = function yFork(ac) {
return { done: false, value: fork.apply(undefined, [worker].concat(args, [ac])) };
return {
done: false,
value: fork.apply(void 0, [worker].concat(args, [ac]))
};
};
var action = void 0,
var action,
setAction = function setAction(ac) {

@@ -27,3 +33,3 @@ return action = ac;

}
}, 'q1', 'takeEvery(' + safeName(patternOrChannel) + ', ' + worker.name + ')');
}, 'q1', "takeEvery(" + safeName(patternOrChannel) + ", " + worker.name + ")");
}
import fsmIterator, { qEnd, safeName } from './fsmIterator';
import { cancel, take, fork } from '../io';
import { END } from '../channel';
export default function takeLatest(patternOrChannel, worker) {
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
var yTake = { done: false, value: take(patternOrChannel) };
var yTake = {
done: false,
value: take(patternOrChannel)
};
var yFork = function yFork(ac) {
return { done: false, value: fork.apply(undefined, [worker].concat(args, [ac])) };
return {
done: false,
value: fork.apply(void 0, [worker].concat(args, [ac]))
};
};
var yCancel = function yCancel(task) {
return { done: false, value: cancel(task) };
return {
done: false,
value: cancel(task)
};
};
var task = void 0,
action = void 0;
var task, action;
var setTask = function setTask(t) {
return task = t;
};
var setAction = function setAction(ac) {

@@ -37,3 +48,3 @@ return action = ac;

}
}, 'q1', 'takeLatest(' + safeName(patternOrChannel) + ', ' + worker.name + ')');
}, 'q1', "takeLatest(" + safeName(patternOrChannel) + ", " + worker.name + ")");
}
import fsmIterator, { qEnd, safeName } from './fsmIterator';
import { take, fork, actionChannel, call } from '../io';
import { END } from '../channel';
import { buffers } from '../buffers';
import * as buffers from '../buffers';
import { delay } from '../utils';
export default function throttle(delayLength, pattern, worker) {
for (var _len = arguments.length, args = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
args[_key - 3] = arguments[_key];
}
var action = void 0,
channel = void 0;
var action, channel;
var yActionChannel = {
done: false,
value: actionChannel(pattern, buffers.sliding(1))
};
var yActionChannel = { done: false, value: actionChannel(pattern, buffers.sliding(1)) };
var yTake = function yTake() {
return { done: false, value: take(channel) };
return {
done: false,
value: take(channel)
};
};
var yFork = function yFork(ac) {
return { done: false, value: fork.apply(undefined, [worker].concat(args, [ac])) };
return {
done: false,
value: fork.apply(void 0, [worker].concat(args, [ac]))
};
};
var yDelay = { done: false, value: call(delay, delayLength) };
var yDelay = {
done: false,
value: call(delay, delayLength)
};
var setAction = function setAction(ac) {
return action = ac;
};
var setChannel = function setChannel(ch) {

@@ -44,3 +57,3 @@ return channel = ch;

}
}, 'q1', 'throttle(' + safeName(pattern) + ', ' + worker.name + ')');
}, 'q1', "throttle(" + safeName(pattern) + ", " + worker.name + ")");
}

@@ -9,4 +9,4 @@ var queue = [];

**/
var semaphore = 0;
/**

@@ -17,2 +17,3 @@ Executes a task 'atomically'. Tasks scheduled during this execution will be queued

**/
function exec(task) {

@@ -26,6 +27,7 @@ try {

}
/**
Executes or queues a task depending on the state of the scheduler (`suspended` or `released`)
**/
export function asap(task) {

@@ -39,3 +41,2 @@ queue.push(task);

}
/**

@@ -45,20 +46,22 @@ Puts the scheduler in a `suspended` state. Scheduled tasks will be queued until the

**/
export function suspend() {
semaphore++;
}
/**
Puts the scheduler in a `released` state.
**/
function release() {
semaphore--;
}
/**
Releases the current lock. Executes all queued tasks if the scheduler is in the released state.
**/
export function flush() {
release();
var task;
var task = void 0;
while (!semaphore && (task = queue.shift()) !== undefined) {

@@ -65,0 +68,0 @@ exec(task);

@@ -1,15 +0,6 @@

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
export var sym = function sym(id) {
return '@@redux-saga/' + id;
};
export var TASK = /*#__PURE__*/sym('TASK');
export var HELPER = /*#__PURE__*/sym('HELPER');
export var MATCH = /*#__PURE__*/sym('MATCH');
export var CANCEL = /*#__PURE__*/sym('CANCEL_PROMISE');
export var SAGA_ACTION = /*#__PURE__*/sym('SAGA_ACTION');
export var SELF_CANCELLATION = /*#__PURE__*/sym('SELF_CANCELLATION');
import { CANCEL, MULTICAST, SAGA_ACTION, TASK } from './symbols';
export var konst = function konst(v) {

@@ -20,16 +11,17 @@ return function () {

};
export var kTrue = /*#__PURE__*/konst(true);
export var kFalse = /*#__PURE__*/konst(false);
export var kTrue =
/*#__PURE__*/
konst(true);
export var kFalse =
/*#__PURE__*/
konst(false);
export var noop = function noop() {};
export var ident = function ident(v) {
export var identity = function identity(v) {
return v;
};
export function check(value, predicate, error) {
if (!predicate(value)) {
log('error', 'uncaught at check', error);
throw new Error(error);
}
}
var hasOwnProperty = Object.prototype.hasOwnProperty;

@@ -39,3 +31,2 @@ export function hasOwn(object, property) {

}
export var is = {

@@ -59,3 +50,3 @@ undef: function undef(v) {

object: function object(obj) {
return obj && !is.array(obj) && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
return obj && !is.array(obj) && _typeof(obj) === 'object';
},

@@ -81,3 +72,3 @@ promise: function promise(p) {

pattern: function pattern(pat) {
return pat && (is.string(pat) || (typeof pat === 'undefined' ? 'undefined' : _typeof(pat)) === 'symbol' || is.func(pat) || is.array(pat));
return pat && (is.string(pat) || is.symbol(pat) || is.func(pat) || is.array(pat));
},

@@ -87,10 +78,12 @@ channel: function channel(ch) {

},
helper: function helper(it) {
return it && it[HELPER];
},
stringableFunc: function stringableFunc(f) {
return is.func(f) && hasOwn(f, 'toString');
},
symbol: function symbol(sym) {
return _typeof(sym) === 'symbol';
},
multicast: function multicast(ch) {
return is.channel(ch) && ch[MULTICAST];
}
};
export var object = {

@@ -105,5 +98,5 @@ assign: function assign(target, source) {

};
export function remove(array, item) {
var index = array.indexOf(item);
if (index >= 0) {

@@ -113,6 +106,6 @@ array.splice(index, 1);

}
export var array = {
from: function from(obj) {
var arr = Array(obj.length);
for (var i in obj) {

@@ -123,10 +116,24 @@ if (hasOwn(obj, i)) {

}
return arr;
}
};
export function once(fn) {
var called = false;
return function () {
if (called) {
return;
}
export function deferred() {
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
called = true;
fn();
};
}
export function deferred(props) {
if (props === void 0) {
props = {};
}
var def = _extends({}, props);
var promise = new Promise(function (resolve, reject) {

@@ -139,15 +146,17 @@ def.resolve = resolve;

}
export function arrayOfDeferred(length) {
var arr = [];
export function arrayOfDeffered(length) {
var arr = [];
for (var i = 0; i < length; i++) {
arr.push(deferred());
}
return arr;
}
export function delay(ms, val) {
if (val === void 0) {
val = true;
}
export function delay(ms) {
var val = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var timeoutId = void 0;
var timeoutId;
var promise = new Promise(function (resolve) {

@@ -165,3 +174,2 @@ timeoutId = setTimeout(function () {

}
export function createMockTask() {

@@ -171,5 +179,5 @@ var _ref;

var running = true;
var _result = void 0,
_error = void 0;
var _result, _error;
return _ref = {}, _ref[TASK] = true, _ref.isRunning = function isRunning() {

@@ -189,6 +197,7 @@ return running;

}
export function autoInc(seed) {
if (seed === void 0) {
seed = 0;
}
export function autoInc() {
var seed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
return function () {

@@ -198,21 +207,33 @@ return ++seed;

}
export var uid =
/*#__PURE__*/
autoInc();
export var uid = /*#__PURE__*/autoInc();
var kThrow = function kThrow(err) {
throw err;
};
var kReturn = function kReturn(value) {
return { value: value, done: true };
return {
value: value,
done: true
};
};
export function makeIterator(next) {
var thro = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : kThrow;
var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var isHelper = arguments[3];
var iterator = { name: name, next: next, throw: thro, return: kReturn };
export function makeIterator(next, thro, name) {
if (thro === void 0) {
thro = kThrow;
}
if (isHelper) {
iterator[HELPER] = true;
if (name === void 0) {
name = 'iterator';
}
var iterator = {
name: name,
next: next,
throw: thro,
return: kReturn
};
if (typeof Symbol !== 'undefined') {

@@ -223,5 +244,5 @@ iterator[Symbol.iterator] = function () {

}
return iterator;
}
/**

@@ -232,8 +253,11 @@ Print error in a useful way whether in a browser environment

**/
export function log(level, message) {
var error = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
export function log(level, message, error) {
if (error === void 0) {
error = '';
}
/*eslint-disable no-console*/
if (typeof window === 'undefined') {
console.log('redux-saga ' + level + ': ' + message + '\n' + (error && error.stack || error));
console.log("redux-saga " + level + ": " + message + "\n" + (error && error.stack || error));
} else {

@@ -243,31 +267,28 @@ console[level](message, error);

}
export function deprecate(fn, deprecationWarning) {
return function () {
if (process.env.NODE_ENV === 'development') log('warn', deprecationWarning);
return fn.apply(undefined, arguments);
return fn.apply(void 0, arguments);
};
}
export var updateIncentive = function updateIncentive(deprecated, preferred) {
return deprecated + ' has been deprecated in favor of ' + preferred + ', please update your code';
return deprecated + " has been deprecated in favor of " + preferred + ", please update your code";
};
export var internalErr = function internalErr(err) {
return new Error('\n redux-saga: Error checking hooks detected an inconsistent state. This is likely a bug\n in redux-saga code and not yours. Thanks for reporting this in the project\'s github repo.\n Error: ' + err + '\n');
return new Error("\n redux-saga: Error checking hooks detected an inconsistent state. This is likely a bug\n in redux-saga code and not yours. Thanks for reporting this in the project's github repo.\n Error: " + err + "\n");
};
export var createSetContextWarning = function createSetContextWarning(ctx, props) {
return (ctx ? ctx + '.' : '') + 'setContext(props): argument ' + props + ' is not a plain object';
return (ctx ? ctx + '.' : '') + "setContext(props): argument " + props + " is not a plain object";
};
export var wrapSagaDispatch = function wrapSagaDispatch(dispatch) {
return function (action) {
return dispatch(Object.defineProperty(action, SAGA_ACTION, { value: true }));
return dispatch(Object.defineProperty(action, SAGA_ACTION, {
value: true
}));
};
};
export var cloneableGenerator = function cloneableGenerator(generatorFunc) {
var cloneableGenerator = function cloneableGenerator(generatorFunc) {
return function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];

@@ -277,3 +298,3 @@ }

var history = [];
var gen = generatorFunc.apply(undefined, args);
var gen = generatorFunc.apply(void 0, args);
return {

@@ -285,3 +306,3 @@ next: function next(arg) {

clone: function clone() {
var clonedGen = cloneableGenerator(generatorFunc).apply(undefined, args);
var clonedGen = cloneableGenerator(generatorFunc).apply(void 0, args);
history.forEach(function (arg) {

@@ -300,2 +321,4 @@ return clonedGen.next(arg);

};
};
};
export { cloneableGenerator };

@@ -1,3 +0,4 @@

export { TASK, SAGA_ACTION, noop, is, deferred, arrayOfDeffered, createMockTask, cloneableGenerator } from './internal/utils';
export { noop, is, deferred, arrayOfDeferred, createMockTask, cloneableGenerator } from './internal/utils';
export { SAGA_ACTION, TASK } from './internal/symbols';
export { asEffect } from './internal/io';
export { CHANNEL_END } from './internal/proc';

@@ -1,8 +0,5 @@

'use strict';
"use strict";
exports.__esModule = true;
var _io = /*#__PURE__*/require('./internal/io');
Object.defineProperty(exports, 'take', {
Object.defineProperty(exports, "take", {
enumerable: true,

@@ -13,9 +10,9 @@ get: function get() {

});
Object.defineProperty(exports, 'takem', {
Object.defineProperty(exports, "takeMaybe", {
enumerable: true,
get: function get() {
return _io.takem;
return _io.takeMaybe;
}
});
Object.defineProperty(exports, 'put', {
Object.defineProperty(exports, "put", {
enumerable: true,

@@ -26,9 +23,15 @@ get: function get() {

});
Object.defineProperty(exports, 'all', {
Object.defineProperty(exports, "putResolve", {
enumerable: true,
get: function get() {
return _io.putResolve;
}
});
Object.defineProperty(exports, "all", {
enumerable: true,
get: function get() {
return _io.all;
}
});
Object.defineProperty(exports, 'race', {
Object.defineProperty(exports, "race", {
enumerable: true,

@@ -39,3 +42,3 @@ get: function get() {

});
Object.defineProperty(exports, 'call', {
Object.defineProperty(exports, "call", {
enumerable: true,

@@ -46,3 +49,3 @@ get: function get() {

});
Object.defineProperty(exports, 'apply', {
Object.defineProperty(exports, "apply", {
enumerable: true,

@@ -53,3 +56,3 @@ get: function get() {

});
Object.defineProperty(exports, 'cps', {
Object.defineProperty(exports, "cps", {
enumerable: true,

@@ -60,3 +63,3 @@ get: function get() {

});
Object.defineProperty(exports, 'fork', {
Object.defineProperty(exports, "fork", {
enumerable: true,

@@ -67,3 +70,3 @@ get: function get() {

});
Object.defineProperty(exports, 'spawn', {
Object.defineProperty(exports, "spawn", {
enumerable: true,

@@ -74,3 +77,3 @@ get: function get() {

});
Object.defineProperty(exports, 'join', {
Object.defineProperty(exports, "join", {
enumerable: true,

@@ -81,3 +84,3 @@ get: function get() {

});
Object.defineProperty(exports, 'cancel', {
Object.defineProperty(exports, "cancel", {
enumerable: true,

@@ -88,3 +91,3 @@ get: function get() {

});
Object.defineProperty(exports, 'select', {
Object.defineProperty(exports, "select", {
enumerable: true,

@@ -95,3 +98,3 @@ get: function get() {

});
Object.defineProperty(exports, 'actionChannel', {
Object.defineProperty(exports, "actionChannel", {
enumerable: true,

@@ -102,3 +105,3 @@ get: function get() {

});
Object.defineProperty(exports, 'cancelled', {
Object.defineProperty(exports, "cancelled", {
enumerable: true,

@@ -109,3 +112,3 @@ get: function get() {

});
Object.defineProperty(exports, 'flush', {
Object.defineProperty(exports, "flush", {
enumerable: true,

@@ -116,3 +119,3 @@ get: function get() {

});
Object.defineProperty(exports, 'getContext', {
Object.defineProperty(exports, "getContext", {
enumerable: true,

@@ -123,3 +126,3 @@ get: function get() {

});
Object.defineProperty(exports, 'setContext', {
Object.defineProperty(exports, "setContext", {
enumerable: true,

@@ -130,3 +133,3 @@ get: function get() {

});
Object.defineProperty(exports, 'takeEvery', {
Object.defineProperty(exports, "takeEvery", {
enumerable: true,

@@ -137,3 +140,3 @@ get: function get() {

});
Object.defineProperty(exports, 'takeLatest', {
Object.defineProperty(exports, "takeLatest", {
enumerable: true,

@@ -144,3 +147,3 @@ get: function get() {

});
Object.defineProperty(exports, 'throttle', {
Object.defineProperty(exports, "throttle", {
enumerable: true,

@@ -150,2 +153,6 @@ get: function get() {

}
});
});
var _io =
/*#__PURE__*/
require("./internal/io");

@@ -1,9 +0,5 @@

'use strict';
"use strict";
exports.__esModule = true;
exports.utils = exports.effects = exports.detach = exports.CANCEL = exports.delay = exports.throttle = exports.takeLatest = exports.takeEvery = exports.buffers = exports.channel = exports.eventChannel = exports.END = exports.runSaga = undefined;
var _runSaga = /*#__PURE__*/require('./internal/runSaga');
Object.defineProperty(exports, 'runSaga', {
Object.defineProperty(exports, "runSaga", {
enumerable: true,

@@ -14,6 +10,3 @@ get: function get() {

});
var _channel = /*#__PURE__*/require('./internal/channel');
Object.defineProperty(exports, 'END', {
Object.defineProperty(exports, "END", {
enumerable: true,

@@ -24,3 +17,3 @@ get: function get() {

});
Object.defineProperty(exports, 'eventChannel', {
Object.defineProperty(exports, "eventChannel", {
enumerable: true,

@@ -31,3 +24,3 @@ get: function get() {

});
Object.defineProperty(exports, 'channel', {
Object.defineProperty(exports, "channel", {
enumerable: true,

@@ -38,69 +31,84 @@ get: function get() {

});
var _buffers = /*#__PURE__*/require('./internal/buffers');
Object.defineProperty(exports, 'buffers', {
Object.defineProperty(exports, "multicastChannel", {
enumerable: true,
get: function get() {
return _buffers.buffers;
return _channel.multicastChannel;
}
});
var _sagaHelpers = /*#__PURE__*/require('./internal/sagaHelpers');
Object.defineProperty(exports, 'takeEvery', {
Object.defineProperty(exports, "stdChannel", {
enumerable: true,
get: function get() {
return _sagaHelpers.takeEvery;
return _channel.stdChannel;
}
});
Object.defineProperty(exports, 'takeLatest', {
Object.defineProperty(exports, "CANCEL", {
enumerable: true,
get: function get() {
return _sagaHelpers.takeLatest;
return _symbols.CANCEL;
}
});
Object.defineProperty(exports, 'throttle', {
Object.defineProperty(exports, "delay", {
enumerable: true,
get: function get() {
return _sagaHelpers.throttle;
}
});
var _utils = /*#__PURE__*/require('./internal/utils');
Object.defineProperty(exports, 'delay', {
enumerable: true,
get: function get() {
return _utils.delay;
}
});
Object.defineProperty(exports, 'CANCEL', {
Object.defineProperty(exports, "detach", {
enumerable: true,
get: function get() {
return _utils.CANCEL;
return _io.detach;
}
});
exports.buffers = exports.utils = exports.effects = exports.default = void 0;
var _io = /*#__PURE__*/require('./internal/io');
var _middleware =
/*#__PURE__*/
_interopRequireDefault(
/*#__PURE__*/
require("./internal/middleware"));
Object.defineProperty(exports, 'detach', {
enumerable: true,
get: function get() {
return _io.detach;
}
});
var _runSaga =
/*#__PURE__*/
require("./internal/runSaga");
var _middleware = /*#__PURE__*/require('./internal/middleware');
var _channel =
/*#__PURE__*/
require("./internal/channel");
var _middleware2 = /*#__PURE__*/_interopRequireDefault(_middleware);
var _symbols =
/*#__PURE__*/
require("./internal/symbols");
var _effects = /*#__PURE__*/require('./effects');
var _utils =
/*#__PURE__*/
require("./internal/utils");
var effects = /*#__PURE__*/_interopRequireWildcard(_effects);
var _io =
/*#__PURE__*/
require("./internal/io");
var _utils2 = /*#__PURE__*/require('./utils');
var effects =
/*#__PURE__*/
_interopRequireWildcard(
/*#__PURE__*/
require("./effects"));
var utils = /*#__PURE__*/_interopRequireWildcard(_utils2);
exports.effects = effects;
var utils =
/*#__PURE__*/
_interopRequireWildcard(
/*#__PURE__*/
require("./utils"));
exports.utils = utils;
var buffers =
/*#__PURE__*/
_interopRequireWildcard(
/*#__PURE__*/
require("./internal/buffers"));
exports.buffers = buffers;
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -110,4 +118,3 @@

exports.default = _middleware2.default;
exports.effects = effects;
exports.utils = utils;
var _default = _middleware.default;
exports.default = _default;
"use strict";
exports.__esModule = true;
exports.buffers = exports.BUFFER_OVERFLOW = undefined;
exports.expanding = exports.sliding = exports.dropping = exports.fixed = exports.none = void 0;
var _utils = /*#__PURE__*/require("./utils");
var _utils =
/*#__PURE__*/
require("./utils");
var BUFFER_OVERFLOW = exports.BUFFER_OVERFLOW = "Channel's Buffer overflow!";
var BUFFER_OVERFLOW = "Channel's Buffer overflow!";
var ON_OVERFLOW_THROW = 1;

@@ -14,9 +15,13 @@ var ON_OVERFLOW_DROP = 2;

var ON_OVERFLOW_EXPAND = 4;
var zeroBuffer = {
isEmpty: _utils.kTrue,
put: _utils.noop,
take: _utils.noop
};
var zeroBuffer = { isEmpty: _utils.kTrue, put: _utils.noop, take: _utils.noop };
function ringBuffer(limit, overflowAction) {
if (limit === void 0) {
limit = 10;
}
function ringBuffer() {
var limit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
var overflowAction = arguments[1];
var arr = new Array(limit);

@@ -45,5 +50,7 @@ var length = 0;

var items = [];
while (length) {
items.push(take());
}
return items;

@@ -60,6 +67,8 @@ };

} else {
var doubledLimit = void 0;
var doubledLimit;
switch (overflowAction) {
case ON_OVERFLOW_THROW:
throw new Error(BUFFER_OVERFLOW);
case ON_OVERFLOW_SLIDE:

@@ -70,18 +79,16 @@ arr[pushIndex] = it;

break;
case ON_OVERFLOW_EXPAND:
doubledLimit = 2 * limit;
arr = flush();
length = arr.length;
pushIndex = arr.length;
popIndex = 0;
arr.length = doubledLimit;
limit = doubledLimit;
push(it);
break;
default:
// DROP
default: // DROP
}

@@ -95,18 +102,30 @@ }

var buffers = exports.buffers = {
none: function none() {
return zeroBuffer;
},
fixed: function fixed(limit) {
return ringBuffer(limit, ON_OVERFLOW_THROW);
},
dropping: function dropping(limit) {
return ringBuffer(limit, ON_OVERFLOW_DROP);
},
sliding: function sliding(limit) {
return ringBuffer(limit, ON_OVERFLOW_SLIDE);
},
expanding: function expanding(initialSize) {
return ringBuffer(initialSize, ON_OVERFLOW_EXPAND);
}
};
var none = function none() {
return zeroBuffer;
};
exports.none = none;
var fixed = function fixed(limit) {
return ringBuffer(limit, ON_OVERFLOW_THROW);
};
exports.fixed = fixed;
var dropping = function dropping(limit) {
return ringBuffer(limit, ON_OVERFLOW_DROP);
};
exports.dropping = dropping;
var sliding = function sliding(limit) {
return ringBuffer(limit, ON_OVERFLOW_SLIDE);
};
exports.sliding = sliding;
var expanding = function expanding(initialSize) {
return ringBuffer(initialSize, ON_OVERFLOW_EXPAND);
};
exports.expanding = expanding;

@@ -1,62 +0,60 @@

'use strict';
"use strict";
exports.__esModule = true;
exports.UNDEFINED_INPUT_ERROR = exports.INVALID_BUFFER = exports.isEnd = exports.END = undefined;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
exports.emitter = emitter;
exports.channel = channel;
exports.eventChannel = eventChannel;
exports.multicastChannel = multicastChannel;
exports.stdChannel = stdChannel;
exports.isEnd = exports.END = void 0;
var _utils = /*#__PURE__*/require('./utils');
var _symbols =
/*#__PURE__*/
require("./symbols");
var _buffers = /*#__PURE__*/require('./buffers');
var _utils =
/*#__PURE__*/
require("./utils");
var _scheduler = /*#__PURE__*/require('./scheduler');
var buffers =
/*#__PURE__*/
_interopRequireWildcard(
/*#__PURE__*/
require("./buffers"));
var CHANNEL_END_TYPE = '@@redux-saga/CHANNEL_END';
var END = exports.END = { type: CHANNEL_END_TYPE };
var isEnd = exports.isEnd = function isEnd(a) {
return a && a.type === CHANNEL_END_TYPE;
};
var _scheduler =
/*#__PURE__*/
require("./scheduler");
function emitter() {
var subscribers = [];
var matchers =
/*#__PURE__*/
_interopRequireWildcard(
/*#__PURE__*/
require("./matcher"));
function subscribe(sub) {
subscribers.push(sub);
return function () {
return (0, _utils.remove)(subscribers, sub);
};
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function emit(item) {
var arr = subscribers.slice();
for (var i = 0, len = arr.length; i < len; i++) {
arr[i](item);
}
}
var END = {
type: _symbols.CHANNEL_END_TYPE
};
exports.END = END;
return {
subscribe: subscribe,
emit: emit
};
}
var isEnd = function isEnd(a) {
return a && a.type === _symbols.CHANNEL_END_TYPE;
};
var INVALID_BUFFER = exports.INVALID_BUFFER = 'invalid buffer passed to channel factory function';
var UNDEFINED_INPUT_ERROR = exports.UNDEFINED_INPUT_ERROR = 'Saga was provided with an undefined action';
exports.isEnd = isEnd;
var INVALID_BUFFER = 'invalid buffer passed to channel factory function';
var UNDEFINED_INPUT_ERROR = "Saga or channel was provided with an undefined action\nHints:\n - check that your Action Creator returns a non-undefined value\n - if the Saga was started using runSaga, check that your subscribe source provides the action to its listeners";
if (process.env.NODE_ENV !== 'production') {
exports.UNDEFINED_INPUT_ERROR = UNDEFINED_INPUT_ERROR += '\nHints:\n - check that your Action Creator returns a non-undefined value\n - if the Saga was started using runSaga, check that your subscribe source provides the action to its listeners\n ';
}
function channel(buffer) {
if (buffer === void 0) {
buffer = buffers.expanding();
}
function channel() {
var buffer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _buffers.buffers.fixed();
var closed = false;
var takers = [];
(0, _utils.check)(buffer, _utils.is.buffer, INVALID_BUFFER);
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(buffer, _utils.is.buffer, INVALID_BUFFER);
}

@@ -67,2 +65,3 @@ function checkForbiddenStates() {

}
if (takers.length && !buffer.isEmpty()) {

@@ -75,16 +74,18 @@ throw (0, _utils.internalErr)('Cannot have pending takers with non empty buffer');

checkForbiddenStates();
(0, _utils.check)(input, _utils.is.notUndef, UNDEFINED_INPUT_ERROR);
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(input, _utils.is.notUndef, UNDEFINED_INPUT_ERROR);
}
if (closed) {
return;
}
if (!takers.length) {
return buffer.put(input);
}
for (var i = 0; i < takers.length; i++) {
var cb = takers[i];
if (!cb[_utils.MATCH] || cb[_utils.MATCH](input)) {
takers.splice(i, 1);
return cb(input);
}
}
var cb = takers[0];
takers.splice(0, 1);
cb(input);
}

@@ -94,4 +95,7 @@

checkForbiddenStates();
(0, _utils.check)(cb, _utils.is.func, "channel.take's callback must be a function");
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(cb, _utils.is.func, "channel.take's callback must be a function");
}
if (closed && buffer.isEmpty()) {

@@ -103,2 +107,3 @@ cb(END);

takers.push(cb);
cb.cancel = function () {

@@ -112,3 +117,7 @@ return (0, _utils.remove)(takers, cb);

checkForbiddenStates(); // TODO: check if some new state should be forbidden now
(0, _utils.check)(cb, _utils.is.func, "channel.flush' callback must be a function");
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(cb, _utils.is.func, "channel.flush' callback must be a function");
}
if (closed && buffer.isEmpty()) {

@@ -118,2 +127,3 @@ cb(END);

}
cb(buffer.flush());

@@ -124,9 +134,13 @@ }

checkForbiddenStates();
if (!closed) {
closed = true;
if (takers.length) {
var arr = takers;
takers = [];
for (var i = 0, len = arr.length; i < len; i++) {
arr[i](END);
var taker = arr[i];
taker(END);
}

@@ -141,46 +155,32 @@ }

flush: flush,
close: close,
get __takers__() {
return takers;
},
get __closed__() {
return closed;
}
close: close
};
}
function eventChannel(subscribe) {
var buffer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _buffers.buffers.none();
var matcher = arguments[2];
/**
should be if(typeof matcher !== undefined) instead?
see PR #273 for a background discussion
**/
if (arguments.length > 2) {
(0, _utils.check)(matcher, _utils.is.func, 'Invalid match function passed to eventChannel');
function eventChannel(subscribe, buffer) {
if (buffer === void 0) {
buffer = buffers.none();
}
var closed = false;
var unsubscribe;
var chan = channel(buffer);
var close = function close() {
if (!chan.__closed__) {
if (unsubscribe) {
unsubscribe();
}
chan.close();
if (_utils.is.func(unsubscribe)) {
unsubscribe();
}
chan.close();
};
var unsubscribe = subscribe(function (input) {
unsubscribe = subscribe(function (input) {
if (isEnd(input)) {
close();
closed = true;
return;
}
if (matcher && !matcher(input)) {
return;
}
chan.put(input);
});
if (chan.__closed__) {
unsubscribe();
}

@@ -191,2 +191,8 @@ if (!_utils.is.func(unsubscribe)) {

unsubscribe = (0, _utils.once)(unsubscribe);
if (closed) {
unsubscribe();
}
return {

@@ -199,24 +205,92 @@ take: chan.take,

function stdChannel(subscribe) {
var chan = eventChannel(function (cb) {
return subscribe(function (input) {
if (input[_utils.SAGA_ACTION]) {
cb(input);
return;
function multicastChannel() {
var _ref;
var closed = false;
var currentTakers = [];
var nextTakers = currentTakers;
var ensureCanMutateNextTakers = function ensureCanMutateNextTakers() {
if (nextTakers !== currentTakers) {
return;
}
nextTakers = currentTakers.slice();
}; // TODO: check if its possible to extract closing function and reuse it in both unicasts and multicasts
var close = function close() {
closed = true;
var takers = currentTakers = nextTakers;
for (var i = 0; i < takers.length; i++) {
var taker = takers[i];
taker(END);
}
nextTakers = [];
};
return _ref = {}, _ref[_symbols.MULTICAST] = true, _ref.put = function put(input) {
// TODO: should I check forbidden state here? 1 of them is even impossible
// as we do not possibility of buffer here
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(input, _utils.is.notUndef, UNDEFINED_INPUT_ERROR);
}
if (closed) {
return;
}
if (isEnd(input)) {
close();
return;
}
var takers = currentTakers = nextTakers;
for (var i = 0; i < takers.length; i++) {
var taker = takers[i];
if (taker[_symbols.MATCH](input)) {
taker.cancel();
taker(input);
}
(0, _scheduler.asap)(function () {
return cb(input);
});
}
}, _ref.take = function take(cb, matcher) {
if (matcher === void 0) {
matcher = matchers.wildcard;
}
if (closed) {
cb(END);
return;
}
cb[_symbols.MATCH] = matcher;
ensureCanMutateNextTakers();
nextTakers.push(cb);
cb.cancel = (0, _utils.once)(function () {
ensureCanMutateNextTakers();
(0, _utils.remove)(nextTakers, cb);
});
});
}, _ref.close = close, _ref;
}
return _extends({}, chan, {
take: function take(cb, matcher) {
if (arguments.length > 1) {
(0, _utils.check)(matcher, _utils.is.func, "channel.take's matcher argument must be a function");
cb[_utils.MATCH] = matcher;
}
chan.take(cb);
function stdChannel() {
var chan = multicastChannel();
var put = chan.put;
chan.put = function (input) {
if (input[_symbols.SAGA_ACTION]) {
put(input);
return;
}
});
(0, _scheduler.asap)(function () {
return put(input);
});
};
return chan;
}

@@ -1,5 +0,4 @@

'use strict';
"use strict";
exports.__esModule = true;
exports.asEffect = exports.takem = exports.detach = undefined;
exports.take = take;

@@ -25,8 +24,16 @@ exports.put = put;

exports.throttle = throttle;
exports.asEffect = exports.putResolve = exports.takeMaybe = exports.detach = void 0;
var _utils = /*#__PURE__*/require('./utils');
var _symbols =
/*#__PURE__*/
require("./symbols");
var _sagaHelpers = /*#__PURE__*/require('./sagaHelpers');
var _utils =
/*#__PURE__*/
require("./utils");
var IO = /*#__PURE__*/(0, _utils.sym)('IO');
var _sagaHelpers =
/*#__PURE__*/
require("./sagaHelpers");
var TAKE = 'TAKE';

@@ -47,3 +54,2 @@ var PUT = 'PUT';

var SET_CONTEXT = 'SET_CONTEXT';
var TEST_HINT = '\n(HINT: if you are getting this errors in tests, consider using createMockTask from redux-saga/utils)';

@@ -54,7 +60,10 @@

return _ref = {}, _ref[IO] = true, _ref[type] = payload, _ref;
return _ref = {}, _ref[_symbols.IO] = true, _ref[type] = payload, _ref;
};
var detach = exports.detach = function detach(eff) {
(0, _utils.check)(asEffect.fork(eff), _utils.is.object, 'detach(eff): argument must be a fork effect');
var detach = function detach(eff) {
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(asEffect.fork(eff), _utils.is.object, 'detach(eff): argument must be a fork effect');
}
eff[FORK].detached = true;

@@ -64,19 +73,37 @@ return eff;

function take() {
var patternOrChannel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '*';
exports.detach = detach;
if (arguments.length) {
function take(patternOrChannel, multicastPattern) {
if (patternOrChannel === void 0) {
patternOrChannel = '*';
}
if (process.env.NODE_ENV === 'development' && arguments.length) {
(0, _utils.check)(arguments[0], _utils.is.notUndef, 'take(patternOrChannel): patternOrChannel is undefined');
}
if (_utils.is.pattern(patternOrChannel)) {
return effect(TAKE, { pattern: patternOrChannel });
return effect(TAKE, {
pattern: patternOrChannel
});
}
if (_utils.is.multicast(patternOrChannel) && _utils.is.notUndef(multicastPattern) && _utils.is.pattern(multicastPattern)) {
return effect(TAKE, {
channel: patternOrChannel,
pattern: multicastPattern
});
}
if (_utils.is.channel(patternOrChannel)) {
return effect(TAKE, { channel: patternOrChannel });
return effect(TAKE, {
channel: patternOrChannel
});
}
throw new Error('take(patternOrChannel): argument ' + String(patternOrChannel) + ' is not valid channel or a valid pattern');
throw new Error("take(patternOrChannel): argument " + patternOrChannel + " is not valid channel or a valid pattern");
}
take.maybe = function () {
var eff = take.apply(undefined, arguments);
var takeMaybe = function takeMaybe() {
var eff = take.apply(void 0, arguments);
eff[TAKE].maybe = true;

@@ -86,19 +113,28 @@ return eff;

var takem = /*#__PURE__*/exports.takem = (0, _utils.deprecate)(take.maybe, /*#__PURE__*/(0, _utils.updateIncentive)('takem', 'take.maybe'));
exports.takeMaybe = takeMaybe;
function put(channel, action) {
if (arguments.length > 1) {
(0, _utils.check)(channel, _utils.is.notUndef, 'put(channel, action): argument channel is undefined');
(0, _utils.check)(channel, _utils.is.channel, 'put(channel, action): argument ' + channel + ' is not a valid channel');
(0, _utils.check)(action, _utils.is.notUndef, 'put(channel, action): argument action is undefined');
} else {
(0, _utils.check)(channel, _utils.is.notUndef, 'put(action): argument action is undefined');
if (process.env.NODE_ENV === 'development') {
if (arguments.length > 1) {
(0, _utils.check)(channel, _utils.is.notUndef, 'put(channel, action): argument channel is undefined');
(0, _utils.check)(channel, _utils.is.channel, "put(channel, action): argument " + channel + " is not a valid channel");
(0, _utils.check)(action, _utils.is.notUndef, 'put(channel, action): argument action is undefined');
} else {
(0, _utils.check)(channel, _utils.is.notUndef, 'put(action): argument action is undefined');
}
}
if (_utils.is.undef(action)) {
action = channel;
channel = null;
}
return effect(PUT, { channel: channel, action: action });
return effect(PUT, {
channel: channel,
action: action
});
}
put.resolve = function () {
var eff = put.apply(undefined, arguments);
var putResolve = function putResolve() {
var eff = put.apply(void 0, arguments);
eff[PUT].resolve = true;

@@ -108,3 +144,3 @@ return eff;

put.sync = /*#__PURE__*/(0, _utils.deprecate)(put.resolve, /*#__PURE__*/(0, _utils.updateIncentive)('put.sync', 'put.resolve'));
exports.putResolve = putResolve;

@@ -120,5 +156,8 @@ function all(effects) {

function getFnCallDesc(meth, fn, args) {
(0, _utils.check)(fn, _utils.is.notUndef, meth + ': argument fn is undefined');
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(fn, _utils.is.notUndef, meth + ": argument fn is undefined");
}
var context = null;
if (_utils.is.array(fn)) {

@@ -133,12 +172,20 @@ var _fn = fn;

}
if (context && _utils.is.string(fn) && _utils.is.func(context[fn])) {
fn = context[fn];
}
(0, _utils.check)(fn, _utils.is.func, meth + ': argument ' + fn + ' is not a function');
return { context: context, fn: fn, args: args };
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(fn, _utils.is.func, meth + ": argument " + fn + " is not a function");
}
return {
context: context,
fn: fn,
args: args
};
}
function call(fn) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];

@@ -150,10 +197,15 @@ }

function apply(context, fn) {
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
function apply(context, fn, args) {
if (args === void 0) {
args = [];
}
return effect(CALL, getFnCallDesc('apply', { context: context, fn: fn }, args));
return effect(CALL, getFnCallDesc('apply', {
context: context,
fn: fn
}, args));
}
function cps(fn) {
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];

@@ -166,3 +218,3 @@ }

function fork(fn) {
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
args[_key3 - 1] = arguments[_key3];

@@ -175,11 +227,11 @@ }

function spawn(fn) {
for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
args[_key4 - 1] = arguments[_key4];
}
return detach(fork.apply(undefined, [fn].concat(args)));
return detach(fork.apply(void 0, [fn].concat(args)));
}
function join() {
for (var _len5 = arguments.length, tasks = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
for (var _len5 = arguments.length, tasks = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
tasks[_key5] = arguments[_key5];

@@ -193,5 +245,10 @@ }

}
var task = tasks[0];
(0, _utils.check)(task, _utils.is.notUndef, 'join(task): argument task is undefined');
(0, _utils.check)(task, _utils.is.task, 'join(task): argument ' + task + ' is not a valid Task object ' + TEST_HINT);
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(task, _utils.is.notUndef, 'join(task): argument task is undefined');
(0, _utils.check)(task, _utils.is.task, "join(task): argument " + task + " is not a valid Task object " + TEST_HINT);
}
return effect(JOIN, task);

@@ -201,3 +258,3 @@ }

function cancel() {
for (var _len6 = arguments.length, tasks = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
for (var _len6 = arguments.length, tasks = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
tasks[_key6] = arguments[_key6];

@@ -211,34 +268,51 @@ }

}
var task = tasks[0];
if (tasks.length === 1) {
if (process.env.NODE_ENV === 'development' && tasks.length === 1) {
(0, _utils.check)(task, _utils.is.notUndef, 'cancel(task): argument task is undefined');
(0, _utils.check)(task, _utils.is.task, 'cancel(task): argument ' + task + ' is not a valid Task object ' + TEST_HINT);
(0, _utils.check)(task, _utils.is.task, "cancel(task): argument " + task + " is not a valid Task object " + TEST_HINT);
}
return effect(CANCEL, task || _utils.SELF_CANCELLATION);
return effect(CANCEL, task || _symbols.SELF_CANCELLATION);
}
function select(selector) {
for (var _len7 = arguments.length, args = Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
if (selector === void 0) {
selector = _utils.identity;
}
for (var _len7 = arguments.length, args = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
args[_key7 - 1] = arguments[_key7];
}
if (arguments.length === 0) {
selector = _utils.ident;
} else {
(0, _utils.check)(selector, _utils.is.notUndef, 'select(selector,[...]): argument selector is undefined');
(0, _utils.check)(selector, _utils.is.func, 'select(selector,[...]): argument ' + selector + ' is not a function');
if (process.env.NODE_ENV === 'development' && arguments.length) {
(0, _utils.check)(arguments[0], _utils.is.notUndef, 'select(selector, [...]): argument selector is undefined');
(0, _utils.check)(selector, _utils.is.func, "select(selector, [...]): argument " + selector + " is not a function");
}
return effect(SELECT, { selector: selector, args: args });
return effect(SELECT, {
selector: selector,
args: args
});
}
/**
channel(pattern, [buffer]) => creates an event channel for store actions
channel(pattern, [buffer]) => creates a proxy channel for store actions
**/
function actionChannel(pattern, buffer) {
(0, _utils.check)(pattern, _utils.is.notUndef, 'actionChannel(pattern,...): argument pattern is undefined');
if (arguments.length > 1) {
(0, _utils.check)(buffer, _utils.is.notUndef, 'actionChannel(pattern, buffer): argument buffer is undefined');
(0, _utils.check)(buffer, _utils.is.buffer, 'actionChannel(pattern, buffer): argument ' + buffer + ' is not a valid buffer');
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(pattern, _utils.is.notUndef, 'actionChannel(pattern,...): argument pattern is undefined');
if (arguments.length > 1) {
(0, _utils.check)(buffer, _utils.is.notUndef, 'actionChannel(pattern, buffer): argument buffer is undefined');
(0, _utils.check)(buffer, _utils.is.buffer, "actionChannel(pattern, buffer): argument " + buffer + " is not a valid buffer");
}
}
return effect(ACTION_CHANNEL, { pattern: pattern, buffer: buffer });
return effect(ACTION_CHANNEL, {
pattern: pattern,
buffer: buffer
});
}

@@ -251,3 +325,6 @@

function flush(channel) {
(0, _utils.check)(channel, _utils.is.channel, 'flush(channel): argument ' + channel + ' is not valid channel');
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(channel, _utils.is.channel, "flush(channel): argument " + channel + " is not valid channel");
}
return effect(FLUSH, channel);

@@ -257,3 +334,6 @@ }

function getContext(prop) {
(0, _utils.check)(prop, _utils.is.string, 'getContext(prop): argument ' + prop + ' is not a string');
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(prop, _utils.is.string, "getContext(prop): argument " + prop + " is not a string");
}
return effect(GET_CONTEXT, prop);

@@ -263,3 +343,6 @@ }

function setContext(props) {
(0, _utils.check)(props, _utils.is.object, (0, _utils.createSetContextWarning)(null, props));
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(props, _utils.is.object, (0, _utils.createSetContextWarning)(null, props));
}
return effect(SET_CONTEXT, props);

@@ -269,23 +352,23 @@ }

function takeEvery(patternOrChannel, worker) {
for (var _len8 = arguments.length, args = Array(_len8 > 2 ? _len8 - 2 : 0), _key8 = 2; _key8 < _len8; _key8++) {
for (var _len8 = arguments.length, args = new Array(_len8 > 2 ? _len8 - 2 : 0), _key8 = 2; _key8 < _len8; _key8++) {
args[_key8 - 2] = arguments[_key8];
}
return fork.apply(undefined, [_sagaHelpers.takeEveryHelper, patternOrChannel, worker].concat(args));
return fork.apply(void 0, [_sagaHelpers.takeEveryHelper, patternOrChannel, worker].concat(args));
}
function takeLatest(patternOrChannel, worker) {
for (var _len9 = arguments.length, args = Array(_len9 > 2 ? _len9 - 2 : 0), _key9 = 2; _key9 < _len9; _key9++) {
for (var _len9 = arguments.length, args = new Array(_len9 > 2 ? _len9 - 2 : 0), _key9 = 2; _key9 < _len9; _key9++) {
args[_key9 - 2] = arguments[_key9];
}
return fork.apply(undefined, [_sagaHelpers.takeLatestHelper, patternOrChannel, worker].concat(args));
return fork.apply(void 0, [_sagaHelpers.takeLatestHelper, patternOrChannel, worker].concat(args));
}
function throttle(ms, pattern, worker) {
for (var _len10 = arguments.length, args = Array(_len10 > 3 ? _len10 - 3 : 0), _key10 = 3; _key10 < _len10; _key10++) {
for (var _len10 = arguments.length, args = new Array(_len10 > 3 ? _len10 - 3 : 0), _key10 = 3; _key10 < _len10; _key10++) {
args[_key10 - 3] = arguments[_key10];
}
return fork.apply(undefined, [_sagaHelpers.throttleHelper, ms, pattern, worker].concat(args));
return fork.apply(void 0, [_sagaHelpers.throttleHelper, ms, pattern, worker].concat(args));
}

@@ -295,22 +378,53 @@

return function (effect) {
return effect && effect[IO] && effect[type];
return effect && effect[_symbols.IO] && effect[type];
};
};
var asEffect = exports.asEffect = {
take: /*#__PURE__*/createAsEffectType(TAKE),
put: /*#__PURE__*/createAsEffectType(PUT),
all: /*#__PURE__*/createAsEffectType(ALL),
race: /*#__PURE__*/createAsEffectType(RACE),
call: /*#__PURE__*/createAsEffectType(CALL),
cps: /*#__PURE__*/createAsEffectType(CPS),
fork: /*#__PURE__*/createAsEffectType(FORK),
join: /*#__PURE__*/createAsEffectType(JOIN),
cancel: /*#__PURE__*/createAsEffectType(CANCEL),
select: /*#__PURE__*/createAsEffectType(SELECT),
actionChannel: /*#__PURE__*/createAsEffectType(ACTION_CHANNEL),
cancelled: /*#__PURE__*/createAsEffectType(CANCELLED),
flush: /*#__PURE__*/createAsEffectType(FLUSH),
getContext: /*#__PURE__*/createAsEffectType(GET_CONTEXT),
setContext: /*#__PURE__*/createAsEffectType(SET_CONTEXT)
};
var asEffect = {
take:
/*#__PURE__*/
createAsEffectType(TAKE),
put:
/*#__PURE__*/
createAsEffectType(PUT),
all:
/*#__PURE__*/
createAsEffectType(ALL),
race:
/*#__PURE__*/
createAsEffectType(RACE),
call:
/*#__PURE__*/
createAsEffectType(CALL),
cps:
/*#__PURE__*/
createAsEffectType(CPS),
fork:
/*#__PURE__*/
createAsEffectType(FORK),
join:
/*#__PURE__*/
createAsEffectType(JOIN),
cancel:
/*#__PURE__*/
createAsEffectType(CANCEL),
select:
/*#__PURE__*/
createAsEffectType(SELECT),
actionChannel:
/*#__PURE__*/
createAsEffectType(ACTION_CHANNEL),
cancelled:
/*#__PURE__*/
createAsEffectType(CANCELLED),
flush:
/*#__PURE__*/
createAsEffectType(FLUSH),
getContext:
/*#__PURE__*/
createAsEffectType(GET_CONTEXT),
setContext:
/*#__PURE__*/
createAsEffectType(SET_CONTEXT)
};
exports.asEffect = asEffect;

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

'use strict';
"use strict";

@@ -6,56 +6,53 @@ exports.__esModule = true;

var _utils = /*#__PURE__*/require('./utils');
var _utils =
/*#__PURE__*/
require("./utils");
var _channel = /*#__PURE__*/require('./channel');
var _channel =
/*#__PURE__*/
require("./channel");
var _runSaga = /*#__PURE__*/require('./runSaga');
var _runSaga =
/*#__PURE__*/
require("./runSaga");
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function sagaMiddlewareFactory() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
function sagaMiddlewareFactory(_ref) {
if (_ref === void 0) {
_ref = {};
}
var _ref$context = _ref.context,
context = _ref$context === undefined ? {} : _ref$context,
options = _objectWithoutProperties(_ref, ['context']);
var _ref2 = _ref,
_ref2$context = _ref2.context,
context = _ref2$context === void 0 ? {} : _ref2$context,
options = _objectWithoutProperties(_ref2, ["context"]);
var sagaMonitor = options.sagaMonitor,
logger = options.logger,
onError = options.onError;
onError = options.onError,
effectMiddlewares = options.effectMiddlewares;
if (process.env.NODE_ENV === 'development') {
if (_utils.is.notUndef(logger)) {
(0, _utils.check)(logger, _utils.is.func, 'options.logger passed to the Saga middleware is not a function!');
}
if (_utils.is.func(options)) {
if (process.env.NODE_ENV === 'production') {
throw new Error('Saga middleware no longer accept Generator functions. Use sagaMiddleware.run instead');
} else {
throw new Error('You passed a function to the Saga middleware. You are likely trying to start a Saga by directly passing it to the middleware. This is no longer possible starting from 0.10.0. To run a Saga, you must do it dynamically AFTER mounting the middleware into the store.\n Example:\n import createSagaMiddleware from \'redux-saga\'\n ... other imports\n\n const sagaMiddleware = createSagaMiddleware()\n const store = createStore(reducer, applyMiddleware(sagaMiddleware))\n sagaMiddleware.run(saga, ...args)\n ');
if (_utils.is.notUndef(onError)) {
(0, _utils.check)(onError, _utils.is.func, 'options.onError passed to the Saga middleware is not a function!');
}
}
if (logger && !_utils.is.func(logger)) {
throw new Error('`options.logger` passed to the Saga middleware is not a function!');
if (_utils.is.notUndef(options.emitter)) {
(0, _utils.check)(options.emitter, _utils.is.func, 'options.emitter passed to the Saga middleware is not a function!');
}
}
if (process.env.NODE_ENV === 'development' && options.onerror) {
throw new Error('`options.onerror` was removed. Use `options.onError` instead.');
}
if (onError && !_utils.is.func(onError)) {
throw new Error('`options.onError` passed to the Saga middleware is not a function!');
}
if (options.emitter && !_utils.is.func(options.emitter)) {
throw new Error('`options.emitter` passed to the Saga middleware is not a function!');
}
function sagaMiddleware(_ref2) {
var getState = _ref2.getState,
dispatch = _ref2.dispatch;
var sagaEmitter = (0, _channel.emitter)();
sagaEmitter.emit = (options.emitter || _utils.ident)(sagaEmitter.emit);
function sagaMiddleware(_ref3) {
var getState = _ref3.getState,
dispatch = _ref3.dispatch;
var channel = (0, _channel.stdChannel)();
channel.put = (options.emitter || _utils.identity)(channel.put);
sagaMiddleware.run = _runSaga.runSaga.bind(null, {
context: context,
subscribe: sagaEmitter.subscribe,
channel: channel,
dispatch: dispatch,

@@ -65,5 +62,5 @@ getState: getState,

logger: logger,
onError: onError
onError: onError,
effectMiddlewares: effectMiddlewares
});
return function (next) {

@@ -74,4 +71,6 @@ return function (action) {

}
var result = next(action); // hit reducers
sagaEmitter.emit(action);
channel.put(action);
return result;

@@ -87,3 +86,6 @@ };

sagaMiddleware.setContext = function (props) {
(0, _utils.check)(props, _utils.is.object, (0, _utils.createSetContextWarning)('sagaMiddleware', props));
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(props, _utils.is.object, (0, _utils.createSetContextWarning)('sagaMiddleware', props));
}
_utils.object.assign(context, props);

@@ -90,0 +92,0 @@ };

@@ -1,67 +0,52 @@

'use strict';
"use strict";
exports.__esModule = true;
exports.TASK_CANCEL = exports.CHANNEL_END = exports.NOT_ITERATOR_ERROR = undefined;
exports.default = proc;
exports.TASK_CANCEL = exports.CHANNEL_END = void 0;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _symbols =
/*#__PURE__*/
require("./symbols");
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _utils =
/*#__PURE__*/
require("./utils");
exports.default = proc;
var _scheduler =
/*#__PURE__*/
require("./scheduler");
var _utils = /*#__PURE__*/require('./utils');
var _io =
/*#__PURE__*/
require("./io");
var _scheduler = /*#__PURE__*/require('./scheduler');
var _channel =
/*#__PURE__*/
require("./channel");
var _io = /*#__PURE__*/require('./io');
var _matcher =
/*#__PURE__*/
_interopRequireDefault(
/*#__PURE__*/
require("./matcher"));
var _channel = /*#__PURE__*/require('./channel');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _buffers = /*#__PURE__*/require('./buffers');
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _defineEnumerableProperties(obj, descs) { for (var key in descs) { var desc = descs[key]; desc.configurable = desc.enumerable = true; if ("value" in desc) desc.writable = true; Object.defineProperty(obj, key, desc); } return obj; }
var NOT_ITERATOR_ERROR = exports.NOT_ITERATOR_ERROR = 'proc first argument (Saga function result) must be an iterator';
var CHANNEL_END = exports.CHANNEL_END = {
// TODO: check if this hacky toString stuff is needed
// also check again whats the difference between CHANNEL_END and CHANNEL_END_TYPE
// maybe this could become MAYBE_END
// I guess this gets exported so takeMaybe result can be checked
var CHANNEL_END = {
toString: function toString() {
return '@@redux-saga/CHANNEL_END';
return _symbols.CHANNEL_END;
}
};
var TASK_CANCEL = exports.TASK_CANCEL = {
exports.CHANNEL_END = CHANNEL_END;
var TASK_CANCEL = {
toString: function toString() {
return '@@redux-saga/TASK_CANCEL';
return _symbols.TASK_CANCEL;
}
};
var matchers = {
wildcard: function wildcard() {
return _utils.kTrue;
},
default: function _default(pattern) {
return (typeof pattern === 'undefined' ? 'undefined' : _typeof(pattern)) === 'symbol' ? function (input) {
return input.type === pattern;
} : function (input) {
return input.type === String(pattern);
};
},
array: function array(patterns) {
return function (input) {
return patterns.some(function (p) {
return matcher(p)(input);
});
};
},
predicate: function predicate(_predicate) {
return function (input) {
return _predicate(input);
};
}
};
function matcher(pattern) {
// prettier-ignore
return (pattern === '*' ? matchers.wildcard : _utils.is.array(pattern) ? matchers.array : _utils.is.stringableFunc(pattern) ? matchers.default : _utils.is.func(pattern) ? matchers.predicate : matchers.default)(pattern);
}
/**

@@ -82,5 +67,8 @@ Used to track a parent task and its forks

**/
exports.TASK_CANCEL = TASK_CANCEL;
function forkQueue(name, mainTask, cb) {
var tasks = [],
result = void 0,
result,
completed = false;

@@ -96,2 +84,3 @@ addTask(mainTask);

tasks.push(task);
task.cont = function (res, isErr) {

@@ -104,2 +93,3 @@ if (completed) {

task.cont = _utils.noop;
if (isErr) {

@@ -111,2 +101,3 @@ abort(res);

}
if (!tasks.length) {

@@ -117,4 +108,4 @@ completed = true;

}
};
// task.cont.cancel = task.cancel
}; // task.cont.cancel = task.cancel
}

@@ -126,2 +117,3 @@

}
completed = true;

@@ -157,7 +149,7 @@ tasks.forEach(function (t) {

return fn;
}
} // catch synchronous failures; see #152 and #441
// catch synchronous failures; see #152 and #441
var result = void 0,
error = void 0;
var result, error;
try {

@@ -167,19 +159,27 @@ result = fn.apply(context, args);

error = err;
}
} // i.e. a generator function returns an iterator
// i.e. a generator function returns an iterator
if (_utils.is.iterator(result)) {
return result;
}
} // do not bubble up synchronous failures for detached forks
// instead create a failed task. See #152 and #441
// do not bubble up synchronous failures for detached forks
// instead create a failed task. See #152 and #441
return error ? (0, _utils.makeIterator)(function () {
throw error;
}) : (0, _utils.makeIterator)(function () {
var pc = void 0;
var eff = { done: false, value: result };
var pc;
var eff = {
done: false,
value: result
};
var ret = function ret(value) {
return { done: true, value: value };
return {
done: true,
value: value
};
};
return function (arg) {

@@ -196,28 +196,34 @@ if (!pc) {

var wrapHelper = function wrapHelper(helper) {
return { fn: helper };
};
function proc(iterator, stdChannel, dispatch, getState, parentContext, options, parentEffectId, name, cont) {
if (dispatch === void 0) {
dispatch = _utils.noop;
}
function proc(iterator) {
var subscribe = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
return _utils.noop;
};
var dispatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _utils.noop;
var getState = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _utils.noop;
var parentContext = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
var parentEffectId = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
var name = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 'anonymous';
var cont = arguments[8];
if (getState === void 0) {
getState = _utils.noop;
}
(0, _utils.check)(iterator, _utils.is.iterator, NOT_ITERATOR_ERROR);
if (parentContext === void 0) {
parentContext = {};
}
var effectsString = '[...effects]';
var runParallelEffect = (0, _utils.deprecate)(runAllEffect, (0, _utils.updateIncentive)(effectsString, 'all(' + effectsString + ')'));
if (options === void 0) {
options = {};
}
var sagaMonitor = options.sagaMonitor,
logger = options.logger,
onError = options.onError;
if (parentEffectId === void 0) {
parentEffectId = 0;
}
if (name === void 0) {
name = 'anonymous';
}
var _options = options,
sagaMonitor = _options.sagaMonitor,
logger = _options.logger,
onError = _options.onError,
middleware = _options.middleware;
var log = logger || _utils.log;
var logError = function logError(err) {

@@ -227,8 +233,8 @@ var message = err.sagaStack;

if (!message && err.stack) {
message = err.stack.split('\n')[0].indexOf(err.message) !== -1 ? err.stack : 'Error: ' + err.message + '\n' + err.stack;
message = err.stack.split('\n')[0].indexOf(err.message) !== -1 ? err.stack : "Error: " + err.message + "\n" + err.stack;
}
log('error', 'uncaught at ' + name, message || err.message || err);
log('error', "uncaught at " + name, message || err.message || err);
};
var stdChannel = (0, _channel.stdChannel)(subscribe);
var taskContext = Object.create(parentContext);

@@ -240,4 +246,4 @@ /**

**/
next.cancel = _utils.noop;
/**

@@ -247,9 +253,14 @@ Creates a new task descriptor for this generator, We'll also create a main task

**/
var task = newTask(parentEffectId, name, iterator, cont);
var mainTask = { name: name, cancel: cancelMain, isRunning: true };
var mainTask = {
name: name,
cancel: cancelMain,
isRunning: true
};
var taskQueue = forkQueue(name, mainTask, end);
/**
cancellation of the main task. We'll simply resume the Generator with a Cancel
**/
function cancelMain() {

@@ -261,3 +272,2 @@ if (mainTask.isRunning && !mainTask.isCancelled) {

}
/**

@@ -270,2 +280,4 @@ This may be called by a parent generator to trigger/propagate cancellation

**/
function cancel() {

@@ -282,2 +294,3 @@ /**

**/
end(TASK_CANCEL);

@@ -290,13 +303,11 @@ }

**/
cont && (cont.cancel = cancel);
// tracks the running status
iterator._isRunning = true;
// kicks up the generator
next();
cont && (cont.cancel = cancel); // tracks the running status
// then return the task descriptor to the caller
iterator._isRunning = true; // kicks up the generator
next(); // then return the task descriptor to the caller
return task;
/**

@@ -307,2 +318,3 @@ This is the generator driver

**/
function next(arg, isErr) {

@@ -315,3 +327,4 @@ // Preventive measure. If we end up here, then there is really something wrong

try {
var result = void 0;
var result;
if (isErr) {

@@ -330,2 +343,3 @@ result = iterator.throw(arg);

**/
next.cancel();

@@ -336,6 +350,12 @@ /**

**/
result = _utils.is.func(iterator.return) ? iterator.return(TASK_CANCEL) : { done: true, value: TASK_CANCEL };
result = _utils.is.func(iterator.return) ? iterator.return(TASK_CANCEL) : {
done: true,
value: TASK_CANCEL
};
} else if (arg === CHANNEL_END) {
// We get CHANNEL_END by taking from a channel that ended using `take` (and not `takem` used to trap End of channels)
result = _utils.is.func(iterator.return) ? iterator.return() : { done: true };
result = _utils.is.func(iterator.return) ? iterator.return() : {
done: true
};
} else {

@@ -346,3 +366,3 @@ result = iterator.next(arg);

if (!result.done) {
runEffect(result.value, parentEffectId, '', next);
digestEffect(result.value, parentEffectId, '', next);
} else {

@@ -359,2 +379,3 @@ /**

}
mainTask.isMainRunning = false;

@@ -366,4 +387,4 @@ mainTask.cont(error, true);

function end(result, isErr) {
iterator._isRunning = false;
stdChannel.close();
iterator._isRunning = false; // stdChannel.close()
if (!isErr) {

@@ -375,6 +396,7 @@ iterator._result = result;

Object.defineProperty(result, 'sagaStack', {
value: 'at ' + name + ' \n ' + (result.sagaStack || result.stack),
value: "at " + name + " \n " + (result.sagaStack || result.stack),
configurable: true
});
}
if (!task.cont) {

@@ -384,5 +406,7 @@ if (result instanceof Error && onError) {

} else {
// TODO: could we skip this when _deferredEnd is attached?
logError(result);
}
}
iterator._error = result;

@@ -392,2 +416,3 @@ iterator._isAborted = true;

}
task.cont && task.cont(result, isErr);

@@ -400,9 +425,41 @@ task.joiners.forEach(function (j) {

function runEffect(effect, parentEffectId) {
var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var cb = arguments[3];
function runEffect(effect, effectId, label, currCb) {
if (label === void 0) {
label = '';
}
/**
each effect runner must attach its own logic of cancellation to the provided callback
it allows this generator to propagate cancellation downward.
ATTENTION! effect runners must setup the cancel logic by setting cb.cancel = [cancelMethod]
And the setup must occur before calling the callback
This is a sort of inversion of control: called async functions are responsible
of completing the flow by calling the provided continuation; while caller functions
are responsible for aborting the current flow by calling the attached cancel function
Library users can attach their own cancellation logic to promises by defining a
promise[CANCEL] method in their returned promises
ATTENTION! calling cancel must have no effect on an already completed or cancelled effect
**/
var data; // prettier-ignore
return (// Non declarative effect
_utils.is.promise(effect) ? resolvePromise(effect, currCb) : _utils.is.iterator(effect) ? resolveIterator(effect, effectId, name, currCb) // declarative effects
: (data = _io.asEffect.take(effect)) ? runTakeEffect(data, currCb) : (data = _io.asEffect.put(effect)) ? runPutEffect(data, currCb) : (data = _io.asEffect.all(effect)) ? runAllEffect(data, effectId, currCb) : (data = _io.asEffect.race(effect)) ? runRaceEffect(data, effectId, currCb) : (data = _io.asEffect.call(effect)) ? runCallEffect(data, effectId, currCb) : (data = _io.asEffect.cps(effect)) ? runCPSEffect(data, currCb) : (data = _io.asEffect.fork(effect)) ? runForkEffect(data, effectId, currCb) : (data = _io.asEffect.join(effect)) ? runJoinEffect(data, currCb) : (data = _io.asEffect.cancel(effect)) ? runCancelEffect(data, currCb) : (data = _io.asEffect.select(effect)) ? runSelectEffect(data, currCb) : (data = _io.asEffect.actionChannel(effect)) ? runChannelEffect(data, currCb) : (data = _io.asEffect.flush(effect)) ? runFlushEffect(data, currCb) : (data = _io.asEffect.cancelled(effect)) ? runCancelledEffect(data, currCb) : (data = _io.asEffect.getContext(effect)) ? runGetContextEffect(data, currCb) : (data = _io.asEffect.setContext(effect)) ? runSetContextEffect(data, currCb) :
/* anything else returned as is */
currCb(effect)
);
}
function digestEffect(effect, parentEffectId, label, cb) {
if (label === void 0) {
label = '';
}
var effectId = (0, _utils.uid)();
sagaMonitor && sagaMonitor.effectTriggered({ effectId: effectId, parentEffectId: parentEffectId, label: label, effect: effect });
sagaMonitor && sagaMonitor.effectTriggered({
effectId: effectId,
parentEffectId: parentEffectId,
label: label,
effect: effect
});
/**

@@ -413,5 +470,5 @@ completion callback and cancel callback are mutually exclusive

**/
var effectSettled = void 0;
// Completion callback passed to the appropriate effect runner
var effectSettled; // Completion callback passed to the appropriate effect runner
function currCb(res, isErr) {

@@ -424,11 +481,13 @@ if (effectSettled) {

cb.cancel = _utils.noop; // defensive measure
if (sagaMonitor) {
isErr ? sagaMonitor.effectRejected(effectId, res) : sagaMonitor.effectResolved(effectId, res);
}
cb(res, isErr);
}
// tracks down the current cancel
currCb.cancel = _utils.noop;
} // tracks down the current cancel
// setup cancellation logic on the parent cb
currCb.cancel = _utils.noop; // setup cancellation logic on the parent cb
cb.cancel = function () {

@@ -446,2 +505,3 @@ // prevents cancelling an already completed effect

**/
try {

@@ -452,32 +512,25 @@ currCb.cancel();

}
currCb.cancel = _utils.noop; // defensive measure
sagaMonitor && sagaMonitor.effectCancelled(effectId);
};
}; // if one can find a way to decouple runEffect from closure variables
// so it could be the call to it could be referentially transparent
// this potentially could be simplified, finalRunEffect created beforehand
// and this part of the code wouldnt have to know about middleware stuff
/**
each effect runner must attach its own logic of cancellation to the provided callback
it allows this generator to propagate cancellation downward.
ATTENTION! effect runners must setup the cancel logic by setting cb.cancel = [cancelMethod]
And the setup must occur before calling the callback
This is a sort of inversion of control: called async functions are responsible
for completing the flow by calling the provided continuation; while caller functions
are responsible for aborting the current flow by calling the attached cancel function
Library users can attach their own cancellation logic to promises by defining a
promise[CANCEL] method in their returned promises
ATTENTION! calling cancel must have no effect on an already completed or cancelled effect
**/
var data = void 0;
// prettier-ignore
return (
// Non declarative effect
_utils.is.promise(effect) ? resolvePromise(effect, currCb) : _utils.is.helper(effect) ? runForkEffect(wrapHelper(effect), effectId, currCb) : _utils.is.iterator(effect) ? resolveIterator(effect, effectId, name, currCb)
// declarative effects
: _utils.is.array(effect) ? runParallelEffect(effect, effectId, currCb) : (data = _io.asEffect.take(effect)) ? runTakeEffect(data, currCb) : (data = _io.asEffect.put(effect)) ? runPutEffect(data, currCb) : (data = _io.asEffect.all(effect)) ? runAllEffect(data, effectId, currCb) : (data = _io.asEffect.race(effect)) ? runRaceEffect(data, effectId, currCb) : (data = _io.asEffect.call(effect)) ? runCallEffect(data, effectId, currCb) : (data = _io.asEffect.cps(effect)) ? runCPSEffect(data, currCb) : (data = _io.asEffect.fork(effect)) ? runForkEffect(data, effectId, currCb) : (data = _io.asEffect.join(effect)) ? runJoinEffect(data, currCb) : (data = _io.asEffect.cancel(effect)) ? runCancelEffect(data, currCb) : (data = _io.asEffect.select(effect)) ? runSelectEffect(data, currCb) : (data = _io.asEffect.actionChannel(effect)) ? runChannelEffect(data, currCb) : (data = _io.asEffect.flush(effect)) ? runFlushEffect(data, currCb) : (data = _io.asEffect.cancelled(effect)) ? runCancelledEffect(data, currCb) : (data = _io.asEffect.getContext(effect)) ? runGetContextEffect(data, currCb) : (data = _io.asEffect.setContext(effect)) ? runSetContextEffect(data, currCb) : /* anything else returned as is */currCb(effect)
);
if (_utils.is.func(middleware)) {
middleware(function (eff) {
return runEffect(eff, effectId, label, currCb);
})(effect);
return;
}
runEffect(effect, effectId, label, currCb);
}
function resolvePromise(promise, cb) {
var cancelPromise = promise[_utils.CANCEL];
var cancelPromise = promise[_symbols.CANCEL];
if (_utils.is.func(cancelPromise)) {

@@ -489,5 +542,4 @@ cb.cancel = cancelPromise;

};
// TODO: add support for the fetch API, whenever they get around to
// adding cancel support
}
promise.then(cb, function (error) {

@@ -499,19 +551,32 @@ return cb(error, true);

function resolveIterator(iterator, effectId, name, cb) {
proc(iterator, subscribe, dispatch, getState, taskContext, options, effectId, name, cb);
proc(iterator, stdChannel, dispatch, getState, taskContext, options, effectId, name, cb);
}
function runTakeEffect(_ref2, cb) {
var channel = _ref2.channel,
var _ref2$channel = _ref2.channel,
channel = _ref2$channel === void 0 ? stdChannel : _ref2$channel,
pattern = _ref2.pattern,
maybe = _ref2.maybe;
channel = channel || stdChannel;
var takeCb = function takeCb(inp) {
return inp instanceof Error ? cb(inp, true) : (0, _channel.isEnd)(inp) && !maybe ? cb(CHANNEL_END) : cb(inp);
var takeCb = function takeCb(input) {
if (input instanceof Error) {
cb(input, true);
return;
}
if ((0, _channel.isEnd)(input) && !maybe) {
cb(CHANNEL_END);
return;
}
cb(input);
};
try {
channel.take(takeCb, matcher(pattern));
channel.take(takeCb, _utils.is.notUndef(pattern) ? (0, _matcher.default)(pattern) : null);
} catch (err) {
return cb(err, true);
cb(err, true);
return;
}
cb.cancel = takeCb.cancel;

@@ -531,9 +596,12 @@ }

(0, _scheduler.asap)(function () {
var result = void 0;
var result;
try {
result = (channel ? channel.put : dispatch)(action);
} catch (error) {
// If we have a channel or `put.resolve` was used then bubble up the error.
if (channel || resolve) return cb(error, true);
logError(error);
logError(error); // TODO: should such error here be passed to `onError`?
// or is it already if we dropped error swallowing
cb(error, true);
return;
}

@@ -544,6 +612,6 @@

} else {
return cb(result);
cb(result);
return;
}
});
// Put effects are non cancellables
}); // Put effects are non cancellables
}

@@ -555,10 +623,11 @@

args = _ref4.args;
var result; // catch synchronous failures; see #152
var result = void 0;
// catch synchronous failures; see #152
try {
result = fn.apply(context, args);
} catch (error) {
return cb(error, true);
cb(error, true);
return;
}
return _utils.is.promise(result) ? resolvePromise(result, cb) : _utils.is.iterator(result) ? resolveIterator(result, effectId, fn.name, cb) : cb(result);

@@ -574,3 +643,2 @@ }

// by setting cancel field on the cb
// catch synchronous failures; see #152

@@ -581,3 +649,5 @@ try {

};
fn.apply(context, args.concat(cpsCb));
if (cpsCb.cancel) {

@@ -589,3 +659,4 @@ cb.cancel = function () {

} catch (error) {
return cb(error, true);
cb(error, true);
return;
}

@@ -599,9 +670,13 @@ }

detached = _ref6.detached;
var taskIterator = createTaskIterator({
context: context,
fn: fn,
args: args
});
var taskIterator = createTaskIterator({ context: context, fn: fn, args: args });
try {
(0, _scheduler.suspend)();
var _task = proc(taskIterator, subscribe, dispatch, getState, taskContext, options, effectId, fn.name, detached ? null : _utils.noop);
var _task = proc(taskIterator, stdChannel, dispatch, getState, taskContext, options, effectId, fn.name, detached ? null : _utils.noop);
if (detached) {

@@ -621,4 +696,4 @@ cb(_task);

(0, _scheduler.flush)();
}
// Fork effects are non cancellables
} // Fork effects are non cancellables
}

@@ -628,6 +703,11 @@

if (t.isRunning()) {
var joiner = { task: task, cb: cb };
var joiner = {
task: task,
cb: cb
};
cb.cancel = function () {
return (0, _utils.remove)(t.joiners, joiner);
};
t.joiners.push(joiner);

@@ -640,10 +720,11 @@ } else {

function runCancelEffect(taskToCancel, cb) {
if (taskToCancel === _utils.SELF_CANCELLATION) {
if (taskToCancel === _symbols.SELF_CANCELLATION) {
taskToCancel = task;
}
if (taskToCancel.isRunning()) {
taskToCancel.cancel();
}
cb();
// cancel effects are non cancellables
cb(); // cancel effects are non cancellables
}

@@ -655,7 +736,8 @@

if (!keys.length) {
return cb(_utils.is.array(effects) ? [] : {});
cb(_utils.is.array(effects) ? [] : {});
return;
}
var completedCount = 0;
var completed = void 0;
var completed;
var results = {};

@@ -667,3 +749,5 @@ var childCbs = {};

completed = true;
cb(_utils.is.array(effects) ? _utils.array.from(_extends({}, results, { length: keys.length })) : results);
cb(_utils.is.array(effects) ? _utils.array.from(_extends({}, results, {
length: keys.length
})) : results);
}

@@ -677,2 +761,3 @@ }

}
if (isErr || (0, _channel.isEnd)(res) || res === CHANNEL_END || res === TASK_CANCEL) {

@@ -687,2 +772,3 @@ cb.cancel();

};
chCbAtKey.cancel = _utils.noop;

@@ -702,3 +788,3 @@ childCbs[key] = chCbAtKey;

keys.forEach(function (key) {
return runEffect(effects[key], effectId, key, childCbs[key]);
return digestEffect(effects[key], effectId, key, childCbs[key]);
});

@@ -708,6 +794,5 @@ }

function runRaceEffect(effects, effectId, cb) {
var completed = void 0;
var completed;
var keys = Object.keys(effects);
var childCbs = {};
keys.forEach(function (key) {

@@ -729,5 +814,8 @@ var chCbAtKey = function chCbAtKey(res, isErr) {

var response = (_response = {}, _response[key] = res, _response);
cb(_utils.is.array(effects) ? [].slice.call(_extends({}, response, { length: keys.length })) : response);
cb(_utils.is.array(effects) ? [].slice.call(_extends({}, response, {
length: keys.length
})) : response);
}
};
chCbAtKey.cancel = _utils.noop;

@@ -746,2 +834,3 @@ childCbs[key] = chCbAtKey;

};
keys.forEach(function (key) {

@@ -751,3 +840,4 @@ if (completed) {

}
runEffect(effects[key], effectId, key, childCbs[key]);
digestEffect(effects[key], effectId, key, childCbs[key]);
});

@@ -761,3 +851,3 @@ }

try {
var state = selector.apply(undefined, [getState()].concat(args));
var state = selector.apply(void 0, [getState()].concat(args));
cb(state);

@@ -772,6 +862,16 @@ } catch (error) {

buffer = _ref8.buffer;
// TODO: rethink how END is handled
var chan = (0, _channel.channel)(buffer);
var match = (0, _matcher.default)(pattern);
var match = matcher(pattern);
match.pattern = pattern;
cb((0, _channel.eventChannel)(subscribe, buffer || _buffers.buffers.fixed(), match));
var taker = function taker(action) {
if (!(0, _channel.isEnd)(action)) {
stdChannel.take(taker, match);
}
chan.put(action);
};
stdChannel.take(taker, match);
cb(chan);
}

@@ -793,2 +893,3 @@

_utils.object.assign(taskContext, props);
cb();

@@ -798,16 +899,22 @@ }

function newTask(id, name, iterator, cont) {
var _done, _ref9, _mutatorMap;
var _ref9;
iterator._deferredEnd = null;
return _ref9 = {}, _ref9[_utils.TASK] = true, _ref9.id = id, _ref9.name = name, _done = 'done', _mutatorMap = {}, _mutatorMap[_done] = _mutatorMap[_done] || {}, _mutatorMap[_done].get = function () {
return _ref9 = {}, _ref9[_symbols.TASK] = true, _ref9.id = id, _ref9.name = name, _ref9.toPromise = function toPromise() {
if (iterator._deferredEnd) {
return iterator._deferredEnd.promise;
} else {
var def = (0, _utils.deferred)();
iterator._deferredEnd = def;
if (!iterator._isRunning) {
iterator._error ? def.reject(iterator._error) : def.resolve(iterator._result);
}
var def = (0, _utils.deferred)();
iterator._deferredEnd = def;
if (!iterator._isRunning) {
if (iterator._isAborted) {
def.reject(iterator._error);
} else {
def.resolve(iterator._result);
}
return def.promise;
}
return def.promise;
}, _ref9.cont = cont, _ref9.joiners = [], _ref9.cancel = cancel, _ref9.isRunning = function isRunning() {

@@ -824,6 +931,9 @@ return iterator._isRunning;

}, _ref9.setContext = function setContext(props) {
(0, _utils.check)(props, _utils.is.object, (0, _utils.createSetContextWarning)('task', props));
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(props, _utils.is.object, (0, _utils.createSetContextWarning)('task', props));
}
_utils.object.assign(taskContext, props);
}, _defineEnumerableProperties(_ref9, _mutatorMap), _ref9;
}, _ref9;
}
}

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

'use strict';
"use strict";

@@ -6,42 +6,49 @@ exports.__esModule = true;

var _utils = /*#__PURE__*/require('./utils');
var _redux =
/*#__PURE__*/
require("redux");
var _proc = /*#__PURE__*/require('./proc');
var _utils =
/*#__PURE__*/
require("./utils");
var _proc2 = /*#__PURE__*/_interopRequireDefault(_proc);
var _proc =
/*#__PURE__*/
_interopRequireDefault(
/*#__PURE__*/
require("./proc"));
var _channel =
/*#__PURE__*/
require("./channel");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var RUN_SAGA_SIGNATURE = 'runSaga(storeInterface, saga, ...args)';
var NON_GENERATOR_ERR = RUN_SAGA_SIGNATURE + ': saga argument must be a Generator function!';
var RUN_SAGA_SIGNATURE = 'runSaga(options, saga, ...args)';
var NON_GENERATOR_ERR = RUN_SAGA_SIGNATURE + ": saga argument must be a Generator function!";
function runSaga(storeInterface, saga) {
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
function runSaga(options, saga) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
var iterator = void 0;
if (_utils.is.iterator(storeInterface)) {
if (process.env.NODE_ENV === 'development') {
(0, _utils.log)('warn', 'runSaga(iterator, storeInterface) has been deprecated in favor of ' + RUN_SAGA_SIGNATURE);
}
iterator = storeInterface;
storeInterface = saga;
} else {
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(saga, _utils.is.func, NON_GENERATOR_ERR);
iterator = saga.apply(undefined, args);
(0, _utils.check)(iterator, _utils.is.iterator, NON_GENERATOR_ERR);
}
var _storeInterface = storeInterface,
subscribe = _storeInterface.subscribe,
dispatch = _storeInterface.dispatch,
getState = _storeInterface.getState,
context = _storeInterface.context,
sagaMonitor = _storeInterface.sagaMonitor,
logger = _storeInterface.logger,
onError = _storeInterface.onError;
var iterator = saga.apply(void 0, args);
if (process.env.NODE_ENV === 'development') {
(0, _utils.check)(iterator, _utils.is.iterator, NON_GENERATOR_ERR);
}
var _options$channel = options.channel,
channel = _options$channel === void 0 ? (0, _channel.stdChannel)() : _options$channel,
dispatch = options.dispatch,
getState = options.getState,
context = options.context,
sagaMonitor = options.sagaMonitor,
logger = options.logger,
effectMiddlewares = options.effectMiddlewares,
onError = options.onError;
var effectId = (0, _utils.uid)();

@@ -56,8 +63,31 @@

sagaMonitor.actionDispatched = sagaMonitor.actionDispatched || _utils.noop;
sagaMonitor.effectTriggered({
effectId: effectId,
root: true,
parentEffectId: 0,
effect: {
root: true,
saga: saga,
args: args
}
});
}
sagaMonitor.effectTriggered({ effectId: effectId, root: true, parentEffectId: 0, effect: { root: true, saga: saga, args: args } });
if ((process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') && _utils.is.notUndef(effectMiddlewares)) {
var MIDDLEWARE_TYPE_ERROR = 'effectMiddlewares must be an array of functions';
(0, _utils.check)(effectMiddlewares, _utils.is.array, MIDDLEWARE_TYPE_ERROR);
effectMiddlewares.forEach(function (effectMiddleware) {
return (0, _utils.check)(effectMiddleware, _utils.is.func, MIDDLEWARE_TYPE_ERROR);
});
}
var task = (0, _proc2.default)(iterator, subscribe, (0, _utils.wrapSagaDispatch)(dispatch), getState, context, { sagaMonitor: sagaMonitor, logger: logger, onError: onError }, effectId, saga.name);
var middleware = effectMiddlewares && _redux.compose.apply(void 0, effectMiddlewares);
var task = (0, _proc.default)(iterator, channel, (0, _utils.wrapSagaDispatch)(dispatch), getState, context, {
sagaMonitor: sagaMonitor,
logger: logger,
onError: onError,
middleware: middleware
}, effectId, saga.name);
if (sagaMonitor) {

@@ -64,0 +94,0 @@ sagaMonitor.effectResolved(effectId, task);

@@ -1,12 +0,18 @@

'use strict';
"use strict";
exports.__esModule = true;
exports.qEnd = undefined;
exports.safeName = safeName;
exports.default = fsmIterator;
exports.qEnd = void 0;
var _utils = /*#__PURE__*/require('../utils');
var _utils =
/*#__PURE__*/
require("../utils");
var done = { done: true, value: undefined };
var qEnd = exports.qEnd = {};
var done = {
done: true,
value: undefined
};
var qEnd = {};
exports.qEnd = qEnd;

@@ -16,15 +22,17 @@ function safeName(patternOrChannel) {

return 'channel';
} else if (Array.isArray(patternOrChannel)) {
return String(patternOrChannel.map(function (entry) {
return String(entry);
}));
} else {
}
if (_utils.is.stringableFunc(patternOrChannel)) {
return String(patternOrChannel);
}
if (_utils.is.func(patternOrChannel)) {
return patternOrChannel.name;
}
return String(patternOrChannel);
}
function fsmIterator(fsm, q0) {
var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'iterator';
var updateState = void 0,
function fsmIterator(fsm, q0, name) {
var updateState,
qNext = q0;

@@ -56,3 +64,3 @@

return next(null, error);
}, name, true);
}, name);
}

@@ -1,35 +0,41 @@

'use strict';
"use strict";
exports.__esModule = true;
exports.throttleHelper = exports.takeLatestHelper = exports.takeEveryHelper = exports.throttle = exports.takeLatest = exports.takeEvery = undefined;
Object.defineProperty(exports, "takeEveryHelper", {
enumerable: true,
get: function get() {
return _takeEvery.default;
}
});
Object.defineProperty(exports, "takeLatestHelper", {
enumerable: true,
get: function get() {
return _takeLatest.default;
}
});
Object.defineProperty(exports, "throttleHelper", {
enumerable: true,
get: function get() {
return _throttle.default;
}
});
var _takeEvery = /*#__PURE__*/require('./takeEvery');
var _takeEvery =
/*#__PURE__*/
_interopRequireDefault(
/*#__PURE__*/
require("./takeEvery"));
var _takeEvery2 = /*#__PURE__*/_interopRequireDefault(_takeEvery);
var _takeLatest =
/*#__PURE__*/
_interopRequireDefault(
/*#__PURE__*/
require("./takeLatest"));
var _takeLatest = /*#__PURE__*/require('./takeLatest');
var _throttle =
/*#__PURE__*/
_interopRequireDefault(
/*#__PURE__*/
require("./throttle"));
var _takeLatest2 = /*#__PURE__*/_interopRequireDefault(_takeLatest);
var _throttle = /*#__PURE__*/require('./throttle');
var _throttle2 = /*#__PURE__*/_interopRequireDefault(_throttle);
var _utils = /*#__PURE__*/require('../utils');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var deprecationWarning = function deprecationWarning(helperName) {
return 'import { ' + helperName + ' } from \'redux-saga\' has been deprecated in favor of import { ' + helperName + ' } from \'redux-saga/effects\'.\nThe latter will not work with yield*, as helper effects are wrapped automatically for you in fork effect.\nTherefore yield ' + helperName + ' will return task descriptor to your saga and execute next lines of code.';
};
var takeEvery = /*#__PURE__*/(0, _utils.deprecate)(_takeEvery2.default, /*#__PURE__*/deprecationWarning('takeEvery'));
var takeLatest = /*#__PURE__*/(0, _utils.deprecate)(_takeLatest2.default, /*#__PURE__*/deprecationWarning('takeLatest'));
var throttle = /*#__PURE__*/(0, _utils.deprecate)(_throttle2.default, /*#__PURE__*/deprecationWarning('throttle'));
exports.takeEvery = takeEvery;
exports.takeLatest = takeLatest;
exports.throttle = throttle;
exports.takeEveryHelper = _takeEvery2.default;
exports.takeLatestHelper = _takeLatest2.default;
exports.throttleHelper = _throttle2.default;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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

'use strict';
"use strict";

@@ -6,23 +6,36 @@ exports.__esModule = true;

var _fsmIterator = /*#__PURE__*/require('./fsmIterator');
var _fsmIterator =
/*#__PURE__*/
_interopRequireWildcard(
/*#__PURE__*/
require("./fsmIterator"));
var _fsmIterator2 = /*#__PURE__*/_interopRequireDefault(_fsmIterator);
var _io =
/*#__PURE__*/
require("../io");
var _io = /*#__PURE__*/require('../io');
var _channel =
/*#__PURE__*/
require("../channel");
var _channel = /*#__PURE__*/require('../channel');
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function takeEvery(patternOrChannel, worker) {
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
var yTake = { done: false, value: (0, _io.take)(patternOrChannel) };
var yTake = {
done: false,
value: (0, _io.take)(patternOrChannel)
};
var yFork = function yFork(ac) {
return { done: false, value: _io.fork.apply(undefined, [worker].concat(args, [ac])) };
return {
done: false,
value: _io.fork.apply(void 0, [worker].concat(args, [ac]))
};
};
var action = void 0,
var action,
setAction = function setAction(ac) {

@@ -32,3 +45,3 @@ return action = ac;

return (0, _fsmIterator2.default)({
return (0, _fsmIterator.default)({
q1: function q1() {

@@ -40,3 +53,3 @@ return ['q2', yTake, setAction];

}
}, 'q1', 'takeEvery(' + (0, _fsmIterator.safeName)(patternOrChannel) + ', ' + worker.name + ')');
}, 'q1', "takeEvery(" + (0, _fsmIterator.safeName)(patternOrChannel) + ", " + worker.name + ")");
}

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

'use strict';
"use strict";

@@ -6,30 +6,48 @@ exports.__esModule = true;

var _fsmIterator = /*#__PURE__*/require('./fsmIterator');
var _fsmIterator =
/*#__PURE__*/
_interopRequireWildcard(
/*#__PURE__*/
require("./fsmIterator"));
var _fsmIterator2 = /*#__PURE__*/_interopRequireDefault(_fsmIterator);
var _io =
/*#__PURE__*/
require("../io");
var _io = /*#__PURE__*/require('../io');
var _channel =
/*#__PURE__*/
require("../channel");
var _channel = /*#__PURE__*/require('../channel');
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function takeLatest(patternOrChannel, worker) {
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
var yTake = { done: false, value: (0, _io.take)(patternOrChannel) };
var yTake = {
done: false,
value: (0, _io.take)(patternOrChannel)
};
var yFork = function yFork(ac) {
return { done: false, value: _io.fork.apply(undefined, [worker].concat(args, [ac])) };
return {
done: false,
value: _io.fork.apply(void 0, [worker].concat(args, [ac]))
};
};
var yCancel = function yCancel(task) {
return { done: false, value: (0, _io.cancel)(task) };
return {
done: false,
value: (0, _io.cancel)(task)
};
};
var task = void 0,
action = void 0;
var task, action;
var setTask = function setTask(t) {
return task = t;
};
var setAction = function setAction(ac) {

@@ -39,3 +57,3 @@ return action = ac;

return (0, _fsmIterator2.default)({
return (0, _fsmIterator.default)({
q1: function q1() {

@@ -50,3 +68,3 @@ return ['q2', yTake, setAction];

}
}, 'q1', 'takeLatest(' + (0, _fsmIterator.safeName)(patternOrChannel) + ', ' + worker.name + ')');
}, 'q1', "takeLatest(" + (0, _fsmIterator.safeName)(patternOrChannel) + ", " + worker.name + ")");
}

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

'use strict';
"use strict";

@@ -6,36 +6,62 @@ exports.__esModule = true;

var _fsmIterator = /*#__PURE__*/require('./fsmIterator');
var _fsmIterator =
/*#__PURE__*/
_interopRequireWildcard(
/*#__PURE__*/
require("./fsmIterator"));
var _fsmIterator2 = /*#__PURE__*/_interopRequireDefault(_fsmIterator);
var _io =
/*#__PURE__*/
require("../io");
var _io = /*#__PURE__*/require('../io');
var _channel =
/*#__PURE__*/
require("../channel");
var _channel = /*#__PURE__*/require('../channel');
var buffers =
/*#__PURE__*/
_interopRequireWildcard(
/*#__PURE__*/
require("../buffers"));
var _buffers = /*#__PURE__*/require('../buffers');
var _utils =
/*#__PURE__*/
require("../utils");
var _utils = /*#__PURE__*/require('../utils');
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function throttle(delayLength, pattern, worker) {
for (var _len = arguments.length, args = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
args[_key - 3] = arguments[_key];
}
var action = void 0,
channel = void 0;
var action, channel;
var yActionChannel = {
done: false,
value: (0, _io.actionChannel)(pattern, buffers.sliding(1))
};
var yActionChannel = { done: false, value: (0, _io.actionChannel)(pattern, _buffers.buffers.sliding(1)) };
var yTake = function yTake() {
return { done: false, value: (0, _io.take)(channel) };
return {
done: false,
value: (0, _io.take)(channel)
};
};
var yFork = function yFork(ac) {
return { done: false, value: _io.fork.apply(undefined, [worker].concat(args, [ac])) };
return {
done: false,
value: _io.fork.apply(void 0, [worker].concat(args, [ac]))
};
};
var yDelay = { done: false, value: (0, _io.call)(_utils.delay, delayLength) };
var yDelay = {
done: false,
value: (0, _io.call)(_utils.delay, delayLength)
};
var setAction = function setAction(ac) {
return action = ac;
};
var setChannel = function setChannel(ch) {

@@ -45,3 +71,3 @@ return channel = ch;

return (0, _fsmIterator2.default)({
return (0, _fsmIterator.default)({
q1: function q1() {

@@ -59,3 +85,3 @@ return ['q2', yActionChannel, setChannel];

}
}, 'q1', 'throttle(' + (0, _fsmIterator.safeName)(pattern) + ', ' + worker.name + ')');
}, 'q1', "throttle(" + (0, _fsmIterator.safeName)(pattern) + ", " + worker.name + ")");
}

@@ -15,4 +15,4 @@ "use strict";

**/
var semaphore = 0;
/**

@@ -23,2 +23,3 @@ Executes a task 'atomically'. Tasks scheduled during this execution will be queued

**/
function exec(task) {

@@ -32,6 +33,7 @@ try {

}
/**
Executes or queues a task depending on the state of the scheduler (`suspended` or `released`)
**/
function asap(task) {

@@ -45,3 +47,2 @@ queue.push(task);

}
/**

@@ -51,20 +52,24 @@ Puts the scheduler in a `suspended` state. Scheduled tasks will be queued until the

**/
function suspend() {
semaphore++;
}
/**
Puts the scheduler in a `released` state.
**/
function release() {
semaphore--;
}
/**
Releases the current lock. Executes all queued tasks if the scheduler is in the released state.
**/
function flush() {
release();
var task;
var task = void 0;
while (!semaphore && (task = queue.shift()) !== undefined) {

@@ -71,0 +76,0 @@ exec(task);

@@ -1,14 +0,10 @@

'use strict';
"use strict";
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.check = check;
exports.hasOwn = hasOwn;
exports.remove = remove;
exports.once = once;
exports.deferred = deferred;
exports.arrayOfDeffered = arrayOfDeffered;
exports.arrayOfDeferred = arrayOfDeferred;
exports.delay = delay;

@@ -20,13 +16,13 @@ exports.createMockTask = createMockTask;

exports.deprecate = deprecate;
var sym = exports.sym = function sym(id) {
return '@@redux-saga/' + id;
};
exports.cloneableGenerator = exports.wrapSagaDispatch = exports.createSetContextWarning = exports.internalErr = exports.updateIncentive = exports.uid = exports.array = exports.object = exports.is = exports.identity = exports.noop = exports.kFalse = exports.kTrue = exports.konst = void 0;
var TASK = /*#__PURE__*/exports.TASK = sym('TASK');
var HELPER = /*#__PURE__*/exports.HELPER = sym('HELPER');
var MATCH = /*#__PURE__*/exports.MATCH = sym('MATCH');
var CANCEL = /*#__PURE__*/exports.CANCEL = sym('CANCEL_PROMISE');
var SAGA_ACTION = /*#__PURE__*/exports.SAGA_ACTION = sym('SAGA_ACTION');
var SELF_CANCELLATION = /*#__PURE__*/exports.SELF_CANCELLATION = sym('SELF_CANCELLATION');
var konst = exports.konst = function konst(v) {
var _symbols =
/*#__PURE__*/
require("./symbols");
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var konst = function konst(v) {
return function () {

@@ -36,12 +32,25 @@ return v;

};
var kTrue = /*#__PURE__*/exports.kTrue = konst(true);
var kFalse = /*#__PURE__*/exports.kFalse = konst(false);
var noop = exports.noop = function noop() {};
var ident = exports.ident = function ident(v) {
exports.konst = konst;
var kTrue =
/*#__PURE__*/
konst(true);
exports.kTrue = kTrue;
var kFalse =
/*#__PURE__*/
konst(false);
exports.kFalse = kFalse;
var noop = function noop() {};
exports.noop = noop;
var identity = function identity(v) {
return v;
};
exports.identity = identity;
function check(value, predicate, error) {
if (!predicate(value)) {
log('error', 'uncaught at check', error);
throw new Error(error);

@@ -52,2 +61,3 @@ }

var hasOwnProperty = Object.prototype.hasOwnProperty;
function hasOwn(object, property) {

@@ -57,3 +67,3 @@ return is.notUndef(object) && hasOwnProperty.call(object, property);

var is = exports.is = {
var is = {
undef: function undef(v) {

@@ -76,3 +86,3 @@ return v === null || v === undefined;

object: function object(obj) {
return obj && !is.array(obj) && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
return obj && !is.array(obj) && _typeof(obj) === 'object';
},

@@ -89,3 +99,3 @@ promise: function promise(p) {

task: function task(t) {
return t && t[TASK];
return t && t[_symbols.TASK];
},

@@ -99,3 +109,3 @@ observable: function observable(ob) {

pattern: function pattern(pat) {
return pat && (is.string(pat) || (typeof pat === 'undefined' ? 'undefined' : _typeof(pat)) === 'symbol' || is.func(pat) || is.array(pat));
return pat && (is.string(pat) || is.symbol(pat) || is.func(pat) || is.array(pat));
},

@@ -105,11 +115,14 @@ channel: function channel(ch) {

},
helper: function helper(it) {
return it && it[HELPER];
},
stringableFunc: function stringableFunc(f) {
return is.func(f) && hasOwn(f, 'toString');
},
symbol: function symbol(sym) {
return _typeof(sym) === 'symbol';
},
multicast: function multicast(ch) {
return is.channel(ch) && ch[_symbols.MULTICAST];
}
};
var object = exports.object = {
exports.is = is;
var object = {
assign: function assign(target, source) {

@@ -123,5 +136,7 @@ for (var i in source) {

};
exports.object = object;
function remove(array, item) {
var index = array.indexOf(item);
if (index >= 0) {

@@ -132,5 +147,6 @@ array.splice(index, 1);

var array = exports.array = {
var array = {
from: function from(obj) {
var arr = Array(obj.length);
for (var i in obj) {

@@ -141,10 +157,27 @@ if (hasOwn(obj, i)) {

}
return arr;
}
};
exports.array = array;
function deferred() {
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
function once(fn) {
var called = false;
return function () {
if (called) {
return;
}
called = true;
fn();
};
}
function deferred(props) {
if (props === void 0) {
props = {};
}
var def = _extends({}, props);
var promise = new Promise(function (resolve, reject) {

@@ -158,14 +191,18 @@ def.resolve = resolve;

function arrayOfDeffered(length) {
function arrayOfDeferred(length) {
var arr = [];
for (var i = 0; i < length; i++) {
arr.push(deferred());
}
return arr;
}
function delay(ms) {
var val = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
function delay(ms, val) {
if (val === void 0) {
val = true;
}
var timeoutId = void 0;
var timeoutId;
var promise = new Promise(function (resolve) {

@@ -177,3 +214,3 @@ timeoutId = setTimeout(function () {

promise[CANCEL] = function () {
promise[_symbols.CANCEL] = function () {
return clearTimeout(timeoutId);

@@ -189,6 +226,6 @@ };

var running = true;
var _result = void 0,
_error = void 0;
return _ref = {}, _ref[TASK] = true, _ref.isRunning = function isRunning() {
var _result, _error;
return _ref = {}, _ref[_symbols.TASK] = true, _ref.isRunning = function isRunning() {
return running;

@@ -208,4 +245,6 @@ }, _ref.result = function result() {

function autoInc() {
var seed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
function autoInc(seed) {
if (seed === void 0) {
seed = 0;
}

@@ -217,3 +256,6 @@ return function () {

var uid = /*#__PURE__*/exports.uid = autoInc();
var uid =
/*#__PURE__*/
autoInc();
exports.uid = uid;

@@ -223,15 +265,26 @@ var kThrow = function kThrow(err) {

};
var kReturn = function kReturn(value) {
return { value: value, done: true };
return {
value: value,
done: true
};
};
function makeIterator(next) {
var thro = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : kThrow;
var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var isHelper = arguments[3];
var iterator = { name: name, next: next, throw: thro, return: kReturn };
function makeIterator(next, thro, name) {
if (thro === void 0) {
thro = kThrow;
}
if (isHelper) {
iterator[HELPER] = true;
if (name === void 0) {
name = 'iterator';
}
var iterator = {
name: name,
next: next,
throw: thro,
return: kReturn
};
if (typeof Symbol !== 'undefined') {

@@ -242,5 +295,5 @@ iterator[Symbol.iterator] = function () {

}
return iterator;
}
/**

@@ -251,8 +304,12 @@ Print error in a useful way whether in a browser environment

**/
function log(level, message) {
var error = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
function log(level, message, error) {
if (error === void 0) {
error = '';
}
/*eslint-disable no-console*/
if (typeof window === 'undefined') {
console.log('redux-saga ' + level + ': ' + message + '\n' + (error && error.stack || error));
console.log("redux-saga " + level + ": " + message + "\n" + (error && error.stack || error));
} else {

@@ -266,27 +323,37 @@ console[level](message, error);

if (process.env.NODE_ENV === 'development') log('warn', deprecationWarning);
return fn.apply(undefined, arguments);
return fn.apply(void 0, arguments);
};
}
var updateIncentive = exports.updateIncentive = function updateIncentive(deprecated, preferred) {
return deprecated + ' has been deprecated in favor of ' + preferred + ', please update your code';
var updateIncentive = function updateIncentive(deprecated, preferred) {
return deprecated + " has been deprecated in favor of " + preferred + ", please update your code";
};
var internalErr = exports.internalErr = function internalErr(err) {
return new Error('\n redux-saga: Error checking hooks detected an inconsistent state. This is likely a bug\n in redux-saga code and not yours. Thanks for reporting this in the project\'s github repo.\n Error: ' + err + '\n');
exports.updateIncentive = updateIncentive;
var internalErr = function internalErr(err) {
return new Error("\n redux-saga: Error checking hooks detected an inconsistent state. This is likely a bug\n in redux-saga code and not yours. Thanks for reporting this in the project's github repo.\n Error: " + err + "\n");
};
var createSetContextWarning = exports.createSetContextWarning = function createSetContextWarning(ctx, props) {
return (ctx ? ctx + '.' : '') + 'setContext(props): argument ' + props + ' is not a plain object';
exports.internalErr = internalErr;
var createSetContextWarning = function createSetContextWarning(ctx, props) {
return (ctx ? ctx + '.' : '') + "setContext(props): argument " + props + " is not a plain object";
};
var wrapSagaDispatch = exports.wrapSagaDispatch = function wrapSagaDispatch(dispatch) {
exports.createSetContextWarning = createSetContextWarning;
var wrapSagaDispatch = function wrapSagaDispatch(dispatch) {
return function (action) {
return dispatch(Object.defineProperty(action, SAGA_ACTION, { value: true }));
return dispatch(Object.defineProperty(action, _symbols.SAGA_ACTION, {
value: true
}));
};
};
var cloneableGenerator = exports.cloneableGenerator = function cloneableGenerator(generatorFunc) {
exports.wrapSagaDispatch = wrapSagaDispatch;
var cloneableGenerator = function cloneableGenerator(generatorFunc) {
return function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];

@@ -296,3 +363,3 @@ }

var history = [];
var gen = generatorFunc.apply(undefined, args);
var gen = generatorFunc.apply(void 0, args);
return {

@@ -304,3 +371,3 @@ next: function next(arg) {

clone: function clone() {
var clonedGen = cloneableGenerator(generatorFunc).apply(undefined, args);
var clonedGen = cloneableGenerator(generatorFunc).apply(void 0, args);
history.forEach(function (arg) {

@@ -319,2 +386,4 @@ return clonedGen.next(arg);

};
};
};
exports.cloneableGenerator = cloneableGenerator;

@@ -1,59 +0,53 @@

'use strict';
"use strict";
exports.__esModule = true;
var _utils = /*#__PURE__*/require('./internal/utils');
Object.defineProperty(exports, 'TASK', {
Object.defineProperty(exports, "noop", {
enumerable: true,
get: function get() {
return _utils.TASK;
return _utils.noop;
}
});
Object.defineProperty(exports, 'SAGA_ACTION', {
Object.defineProperty(exports, "is", {
enumerable: true,
get: function get() {
return _utils.SAGA_ACTION;
return _utils.is;
}
});
Object.defineProperty(exports, 'noop', {
Object.defineProperty(exports, "deferred", {
enumerable: true,
get: function get() {
return _utils.noop;
return _utils.deferred;
}
});
Object.defineProperty(exports, 'is', {
Object.defineProperty(exports, "arrayOfDeferred", {
enumerable: true,
get: function get() {
return _utils.is;
return _utils.arrayOfDeferred;
}
});
Object.defineProperty(exports, 'deferred', {
Object.defineProperty(exports, "createMockTask", {
enumerable: true,
get: function get() {
return _utils.deferred;
return _utils.createMockTask;
}
});
Object.defineProperty(exports, 'arrayOfDeffered', {
Object.defineProperty(exports, "cloneableGenerator", {
enumerable: true,
get: function get() {
return _utils.arrayOfDeffered;
return _utils.cloneableGenerator;
}
});
Object.defineProperty(exports, 'createMockTask', {
Object.defineProperty(exports, "SAGA_ACTION", {
enumerable: true,
get: function get() {
return _utils.createMockTask;
return _symbols.SAGA_ACTION;
}
});
Object.defineProperty(exports, 'cloneableGenerator', {
Object.defineProperty(exports, "TASK", {
enumerable: true,
get: function get() {
return _utils.cloneableGenerator;
return _symbols.TASK;
}
});
var _io = /*#__PURE__*/require('./internal/io');
Object.defineProperty(exports, 'asEffect', {
Object.defineProperty(exports, "asEffect", {
enumerable: true,

@@ -64,6 +58,3 @@ get: function get() {

});
var _proc = /*#__PURE__*/require('./internal/proc');
Object.defineProperty(exports, 'CHANNEL_END', {
Object.defineProperty(exports, "CHANNEL_END", {
enumerable: true,

@@ -73,2 +64,18 @@ get: function get() {

}
});
});
var _utils =
/*#__PURE__*/
require("./internal/utils");
var _symbols =
/*#__PURE__*/
require("./internal/symbols");
var _io =
/*#__PURE__*/
require("./internal/io");
var _proc =
/*#__PURE__*/
require("./internal/proc");
{
"name": "redux-saga",
"version": "0.16.0",
"version": "1.0.0-beta.0",
"description": "Saga middleware for Redux to handle Side Effects",

@@ -22,3 +22,4 @@ "main": "lib/index.js",

"test-src": "cross-env BABEL_ENV=cjs babel-node test/index.js | tap-spec",
"check:bundlesize": "cross-env BABEL_ENV=es bundlesize",
"prebundlesize": "npm run build:umd:prod",
"bundlesize": "bundlesize",
"clean": "rimraf dist es lib",

@@ -66,3 +67,3 @@ "build:umd:dev": "cross-env BABEL_ENV=es NODE_ENV=development rollup -c -i src/index.js -o dist/redux-saga.js",

"path": "./dist/redux-saga.min.js",
"maxSize": "8 Kb"
"maxSize": "7 Kb"
}

@@ -79,14 +80,16 @@ ],

"homepage": "https://redux-saga.js.org/",
"dependencies": {},
"dependencies": {
"redux": "^3.5.1"
},
"devDependencies": {
"babel-cli": "^6.1.18",
"babel-core": "^6.21.0",
"babel-eslint": "^6.0.3",
"babel-loader": "^6.2.5",
"babel-plugin-annotate-pure-calls": "^0.2.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-polyfill": "^6.7.4",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-2": "^6.13.0",
"@babel/cli": "7.0.0-beta.31",
"@babel/core": "7.0.0-beta.31",
"@babel/node": "7.0.0-beta.31",
"@babel/polyfill": "7.0.0-beta.31",
"@babel/preset-env": "7.0.0-beta.31",
"@babel/preset-react": "7.0.0-beta.31",
"@babel/preset-stage-2": "7.0.0-beta.31",
"babel-eslint": "^8.0.1",
"babel-loader": "8.0.0-beta.0",
"babel-plugin-annotate-pure-calls": "Andarist/babel-plugin-annotate-pure-calls#babel7",
"bundlesize": "^0.11.0",

@@ -101,2 +104,3 @@ "cross-env": "^1.0.8",

"lolex": "^1.5.2",
"mitt": "^1.1.2",
"npm-run-all": "^4.0.2",

@@ -107,6 +111,5 @@ "prettier": "^1.4.1",

"react-redux": "^4.4.5",
"redux": "^3.5.1",
"rimraf": "^2.4.3",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-babel": "4.0.0-beta.0",
"rollup-plugin-node-resolve": "^3.0.0",

@@ -119,5 +122,5 @@ "rollup-plugin-replace": "^1.1.1",

"typings-tester": "^0.2.2",
"webpack": "1.13.0",
"webpack-dev-middleware": "^1.4.0",
"webpack-hot-middleware": "^2.6.0"
"webpack": "^3.8.1",
"webpack-dev-middleware": "^1.12.0",
"webpack-hot-middleware": "^2.19.1"
},

@@ -124,0 +127,0 @@ "typings": "./index.d.ts",

@@ -234,3 +234,3 @@ <img src='https://redux-saga.js.org/logo/0800/Redux-Saga-Logo-Landscape.png' alt='Redux Logo Landscape' width='800px'>

You can find the official Redux-Saga logo with different flavors in the [logo directory](logo).
You can find the official Redux-Saga logo with different flavors in the [logo directory](https://github.com/redux-saga/redux-saga/tree/master/logo).

@@ -237,0 +237,0 @@

Sorry, the diff of this file is too big to display

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