Socket
Socket
Sign inDemoInstall

redux-saga

Package Overview
Dependencies
Maintainers
1
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.4.1 to 0.5.0

README_zh-cn.md

250

dist/redux-saga.js

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

});
exports.storeIO = exports.runSaga = exports.as = exports.cancel = exports.join = exports.fork = exports.cps = exports.apply = exports.call = exports.race = exports.put = exports.take = exports.MANUAL_CANCEL = exports.PARALLEL_AUTO_CANCEL = exports.RACE_AUTO_CANCEL = exports.SagaCancellationException = undefined;
exports.monitorActions = exports.storeIO = exports.runSaga = exports.as = exports.cancel = exports.join = exports.fork = exports.cps = exports.apply = exports.call = exports.race = exports.put = exports.take = exports.is = exports.MANUAL_CANCEL = exports.PARALLEL_AUTO_CANCEL = exports.RACE_AUTO_CANCEL = exports.SagaCancellationException = undefined;

@@ -92,2 +92,11 @@ var _proc = __webpack_require__(2);

var _utils = __webpack_require__(1);
Object.defineProperty(exports, 'is', {
enumerable: true,
get: function get() {
return _utils.is;
}
});
var _io = __webpack_require__(4);

@@ -171,9 +180,16 @@

var _middleware = __webpack_require__(5);
var _middleware = __webpack_require__(6);
var _middleware2 = _interopRequireDefault(_middleware);
var _monitorActions = __webpack_require__(5);
var monitorActions = _interopRequireWildcard(_monitorActions);
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 }; }
exports.default = _middleware2.default;
exports.monitorActions = monitorActions;

@@ -197,5 +213,2 @@ /***/ },

exports.asap = asap;
var _marked = [sampleGen].map(regeneratorRuntime.mark);
var TASK = exports.TASK = Symbol('TASK');

@@ -211,13 +224,2 @@ var kTrue = exports.kTrue = function kTrue() {

function sampleGen() {
return regeneratorRuntime.wrap(function sampleGen$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
case 'end':
return _context.stop();
}
}, _marked[0], this);
}
var genConstructor = sampleGen.constructor;
var is = exports.is = {

@@ -227,2 +229,5 @@ undef: function undef(v) {

},
notUndef: function notUndef(v) {
return v !== null && v !== undefined;
},
func: function func(f) {

@@ -233,12 +238,9 @@ return typeof f === 'function';

promise: function promise(p) {
return p && typeof p.then === 'function';
return p && is.func(p.then);
},
generator: function generator(g) {
return is.func(g) && g.constructor === genConstructor;
},
iterator: function iterator(it) {
return it && typeof it.next === 'function';
return it && is.func(it.next) && is.func(it[Symbol.iterator]);
},
throw: function _throw(it) {
return it && typeof it.throw === 'function';
return it && is.func(it.throw);
},

@@ -305,3 +307,3 @@ task: function task(it) {

var _monitorActions = __webpack_require__(6);
var _monitorActions = __webpack_require__(5);

@@ -314,4 +316,2 @@ var monitorActions = _interopRequireWildcard(_monitorActions);

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -402,3 +402,3 @@

var data = undefined;
var promise = _utils.is.array(effect) ? runParallelEffect(effect, effectId) : _utils.is.iterator(effect) ? proc(effect, subscribe, dispatch, monitor, effectId).done : (data = _io.as.take(effect)) ? runTakeEffect(data) : (data = _io.as.put(effect)) ? runPutEffect(data) : (data = _io.as.race(effect)) ? runRaceEffect(data, effectId) : (data = _io.as.call(effect)) ? runCallEffect(data.context, data.fn, data.args, effectId) : (data = _io.as.cps(effect)) ? runCPSEffect(data.fn, data.args) : (data = _io.as.fork(effect)) ? runForkEffect(data.task, data.args, effectId) : (data = _io.as.join(effect)) ? runJoinEffect(data) : (data = _io.as.cancel(effect)) ? runCancelEffect(data) : /* resolve anything else */Promise.resolve(effect);
var promise = _utils.is.array(effect) ? runParallelEffect(effect, effectId) : _utils.is.iterator(effect) ? proc(effect, subscribe, dispatch, monitor, effectId).done : (data = _io.as.take(effect)) ? runTakeEffect(data) : (data = _io.as.put(effect)) ? runPutEffect(data) : (data = _io.as.race(effect)) ? runRaceEffect(data, effectId) : (data = _io.as.call(effect)) ? runCallEffect(data, effectId) : (data = _io.as.cps(effect)) ? runCPSEffect(data) : (data = _io.as.fork(effect)) ? runForkEffect(data, effectId) : (data = _io.as.join(effect)) ? runJoinEffect(data) : (data = _io.as.cancel(effect)) ? runCancelEffect(data) : /* resolve anything else */Promise.resolve(effect);

@@ -453,3 +453,7 @@ var def = (0, _utils.deferred)();

function runCallEffect(context, fn, args, effectId) {
function runCallEffect(_ref2, effectId) {
var context = _ref2.context;
var fn = _ref2.fn;
var args = _ref2.args;
var result = fn.apply(context, args);

@@ -459,18 +463,25 @@ return !_utils.is.iterator(result) ? Promise.resolve(result) : proc(result, subscribe, dispatch, monitor, effectId, fn.name).done;

function runCPSEffect(fn, args) {
function runCPSEffect(_ref3) {
var context = _ref3.context;
var fn = _ref3.fn;
var args = _ref3.args;
return new Promise(function (resolve, reject) {
fn.apply(undefined, _toConsumableArray(args.concat(function (err, res) {
fn.apply(context, args.concat(function (err, res) {
return _utils.is.undef(err) ? resolve(res) : reject(err);
})));
}));
});
}
function runForkEffect(task, args, effectId) {
function runForkEffect(_ref4, effectId) {
var context = _ref4.context;
var fn = _ref4.fn;
var args = _ref4.args;
var result = undefined,
_iterator = undefined;
var isFunc = _utils.is.func(task);
// we run the function, next we'll check if this is a generator function
// (generator is a function that returns an iterator)
if (isFunc) result = task.apply(undefined, _toConsumableArray(args));
result = fn.apply(context, args);

@@ -481,30 +492,26 @@ // A generator function: i.e. returns an iterator

}
// directly forking an iterator
else if (_utils.is.iterator(task)) {
_iterator = task;
}
//simple effect: wrap in a generator
else {
_iterator = regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return isFunc ? result : task;
case 2:
return _context.abrupt('return', _context.sent);
//simple effect: wrap in a generator
else {
_iterator = regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return result;
case 3:
case 'end':
return _context.stop();
}
case 2:
return _context.abrupt('return', _context.sent);
case 3:
case 'end':
return _context.stop();
}
}, _callee, this);
})();
}
}
}, _callee, this);
})();
}
var name = isFunc ? task.name : 'anonymous';
return Promise.resolve(proc(_iterator, subscribe, dispatch, monitor, effectId, name, true));
return Promise.resolve(proc(_iterator, subscribe, dispatch, monitor, effectId, fn.name, true));
}

@@ -564,11 +571,11 @@

function newTask(id, name, iterator, done, forked) {
var _ref3;
var _ref6;
return _ref3 = {}, _defineProperty(_ref3, _utils.TASK, true), _defineProperty(_ref3, 'id', id), _defineProperty(_ref3, 'name', name), _defineProperty(_ref3, 'done', done), _defineProperty(_ref3, 'forked', forked), _defineProperty(_ref3, 'isRunning', function isRunning() {
return _ref6 = {}, _defineProperty(_ref6, _utils.TASK, true), _defineProperty(_ref6, 'id', id), _defineProperty(_ref6, 'name', name), _defineProperty(_ref6, 'done', done), _defineProperty(_ref6, 'forked', forked), _defineProperty(_ref6, 'isRunning', function isRunning() {
return iterator._isRunning;
}), _defineProperty(_ref3, 'getResult', function getResult() {
}), _defineProperty(_ref6, 'getResult', function getResult() {
return iterator._result;
}), _defineProperty(_ref3, 'getError', function getError() {
}), _defineProperty(_ref6, 'getError', function getError() {
return iterator._error;
}), _ref3;
}), _ref6;
}

@@ -623,6 +630,8 @@

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.as = exports.CANCEL_ARG_ERROR = exports.JOIN_ARG_ERROR = exports.FORK_ARG_ERROR = exports.CPS_FUNCTION_ARG_ERROR = exports.CALL_FUNCTION_ARG_ERROR = undefined;
exports.as = exports.INVALID_PATTERN = exports.CANCEL_ARG_ERROR = exports.JOIN_ARG_ERROR = exports.FORK_ARG_ERROR = exports.CALL_FUNCTION_ARG_ERROR = undefined;
exports.matcher = matcher;

@@ -643,7 +652,7 @@ exports.take = take;

var CALL_FUNCTION_ARG_ERROR = exports.CALL_FUNCTION_ARG_ERROR = "call first argument must be a function";
var CPS_FUNCTION_ARG_ERROR = exports.CPS_FUNCTION_ARG_ERROR = "cps first argument must be a function";
var CALL_FUNCTION_ARG_ERROR = exports.CALL_FUNCTION_ARG_ERROR = "call/cps/fork first argument must be a function, an array [context, function] or an object {context, fn}";
var FORK_ARG_ERROR = exports.FORK_ARG_ERROR = "fork first argument must be a generator function or an iterator";
var JOIN_ARG_ERROR = exports.JOIN_ARG_ERROR = "join argument must be a valid task (a result of a fork)";
var CANCEL_ARG_ERROR = exports.CANCEL_ARG_ERROR = "cancel argument must be a valid task (a result of a fork)";
var INVALID_PATTERN = exports.INVALID_PATTERN = "Invalid pattern passed to `take` (HINT: check if you didn't mispell a constant)";

@@ -694,2 +703,6 @@ var IO = Symbol('IO');

function take(pattern) {
if (arguments.length > 0 && _utils.is.undef(pattern)) {
throw new Error(INVALID_PATTERN);
}
return effect(TAKE, _utils.is.undef(pattern) ? '*' : pattern);

@@ -706,2 +719,23 @@ }

function getFnCallDesc(fn, args) {
(0, _utils.check)(fn, _utils.is.notUndef, CALL_FUNCTION_ARG_ERROR);
var context = null;
if (_utils.is.array(fn)) {
var _fn = fn;
var _fn2 = _slicedToArray(_fn, 2);
context = _fn2[0];
fn = _fn2[1];
} else if (fn.fn) {
var _fn3 = fn;
context = _fn3.context;
fn = _fn3.fn;
}
(0, _utils.check)(fn, _utils.is.func, CALL_FUNCTION_ARG_ERROR);
return { context: context, fn: fn, args: args };
}
function call(fn) {

@@ -712,3 +746,3 @@ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

return apply(null, fn, args);
return effect(CALL, getFnCallDesc(fn, args));
}

@@ -719,4 +753,3 @@

(0, _utils.check)(fn, _utils.is.func, CALL_FUNCTION_ARG_ERROR);
return effect(CALL, { context: context, fn: fn, args: args });
return effect(CALL, getFnCallDesc({ context: context, fn: fn }, args));
}

@@ -729,7 +762,6 @@

(0, _utils.check)(fn, _utils.is.func, CPS_FUNCTION_ARG_ERROR);
return effect(CPS, { fn: fn, args: args });
return effect(CPS, getFnCallDesc(fn, args));
}
function fork(task) {
function fork(fn) {
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {

@@ -739,3 +771,3 @@ args[_key3 - 1] = arguments[_key3];

return effect(FORK, { task: task, args: args });
return effect(FORK, getFnCallDesc(fn, args));
}

@@ -788,2 +820,39 @@

/* 5 */
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.effectTriggered = effectTriggered;
exports.effectResolved = effectResolved;
exports.effectRejected = effectRejected;
var EFFECT_TRIGGERED = exports.EFFECT_TRIGGERED = 'EFFECT_TRIGGERED';
var EFFECT_RESOLVED = exports.EFFECT_RESOLVED = 'EFFECT_RESOLVED';
var EFFECT_REJECTED = exports.EFFECT_REJECTED = 'EFFECT_REJECTED';
function effectTriggered(effectId, parentEffectId, label, effect) {
return {
type: EFFECT_TRIGGERED,
effectId: effectId, parentEffectId: parentEffectId, label: label, effect: effect
};
}
function effectResolved(effectId, result) {
return {
type: EFFECT_RESOLVED,
effectId: effectId, result: result
};
}
function effectRejected(effectId, error) {
return {
type: EFFECT_REJECTED,
effectId: effectId, error: error
};
}
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {

@@ -839,39 +908,2 @@

/***/ },
/* 6 */
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.effectTriggered = effectTriggered;
exports.effectResolved = effectResolved;
exports.effectRejected = effectRejected;
var EFFECT_TRIGGERED = exports.EFFECT_TRIGGERED = 'EFFECT_TRIGGERED';
var EFFECT_RESOLVED = exports.EFFECT_RESOLVED = 'EFFECT_RESOLVED';
var EFFECT_REJECTED = exports.EFFECT_REJECTED = 'EFFECT_REJECTED';
function effectTriggered(effectId, parentEffectId, label, effect) {
return {
type: EFFECT_TRIGGERED,
effectId: effectId, parentEffectId: parentEffectId, label: label, effect: effect
};
}
function effectResolved(effectId, result) {
return {
type: EFFECT_RESOLVED,
effectId: effectId, result: result
};
}
function effectRejected(effectId, error) {
return {
type: EFFECT_REJECTED,
effectId: effectId, error: error
};
}
/***/ },
/* 7 */

@@ -878,0 +910,0 @@ /***/ function(module, exports, __webpack_require__) {

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

!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.ReduxSaga=n():e.ReduxSaga=n()}(this,function(){return function(e){function n(t){if(r[t])return r[t].exports;var u=r[t]={exports:{},id:t,loaded:!1};return e[t].call(u.exports,u,u.exports,n),u.loaded=!0,u.exports}var r={};return n.m=e,n.c=r,n.p="",n(0)}([function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0}),n.storeIO=n.runSaga=n.as=n.cancel=n.join=n.fork=n.cps=n.apply=n.call=n.race=n.put=n.take=n.MANUAL_CANCEL=n.PARALLEL_AUTO_CANCEL=n.RACE_AUTO_CANCEL=n.SagaCancellationException=void 0;var u=r(2);Object.defineProperty(n,"SagaCancellationException",{enumerable:!0,get:function(){return u.SagaCancellationException}}),Object.defineProperty(n,"RACE_AUTO_CANCEL",{enumerable:!0,get:function(){return u.RACE_AUTO_CANCEL}}),Object.defineProperty(n,"PARALLEL_AUTO_CANCEL",{enumerable:!0,get:function(){return u.PARALLEL_AUTO_CANCEL}}),Object.defineProperty(n,"MANUAL_CANCEL",{enumerable:!0,get:function(){return u.MANUAL_CANCEL}});var o=r(4);Object.defineProperty(n,"take",{enumerable:!0,get:function(){return o.take}}),Object.defineProperty(n,"put",{enumerable:!0,get:function(){return o.put}}),Object.defineProperty(n,"race",{enumerable:!0,get:function(){return o.race}}),Object.defineProperty(n,"call",{enumerable:!0,get:function(){return o.call}}),Object.defineProperty(n,"apply",{enumerable:!0,get:function(){return o.apply}}),Object.defineProperty(n,"cps",{enumerable:!0,get:function(){return o.cps}}),Object.defineProperty(n,"fork",{enumerable:!0,get:function(){return o.fork}}),Object.defineProperty(n,"join",{enumerable:!0,get:function(){return o.join}}),Object.defineProperty(n,"cancel",{enumerable:!0,get:function(){return o.cancel}}),Object.defineProperty(n,"as",{enumerable:!0,get:function(){return o.as}});var a=r(7);Object.defineProperty(n,"runSaga",{enumerable:!0,get:function(){return a.runSaga}}),Object.defineProperty(n,"storeIO",{enumerable:!0,get:function(){return a.storeIO}});var i=r(5),c=t(i);n.default=c.default},function(e,n){"use strict";function r(e,n,r){if(!n(e))throw new Error(r)}function t(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},s[0],this)}function u(e,n){var r=e.indexOf(n);r>=0&&e.splice(r,1)}function o(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=f({},e),r=new Promise(function(e,r){n.resolve=e,n.reject=r});return n.promise=r,n}function a(e){for(var n=[],r=0;e>r;r++)n.push(o());return n}function i(){var e=arguments.length<=0||void 0===arguments[0]?0:arguments[0];return function(){return++e}}function c(e){return Promise.resolve(1).then(function(){return e()})}var f=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e};Object.defineProperty(n,"__esModule",{value:!0}),n.check=r,n.remove=u,n.deferred=o,n.arrayOfDeffered=a,n.autoInc=i,n.asap=c;var s=[t].map(regeneratorRuntime.mark),l=n.TASK=Symbol("TASK"),d=(n.kTrue=function(){return!0},n.noop=function(){},t.constructor),p=n.is={undef:function(e){return null===e||void 0===e},func:function(e){return"function"==typeof e},array:Array.isArray,promise:function(e){return e&&"function"==typeof e.then},generator:function(e){return p.func(e)&&e.constructor===d},iterator:function(e){return e&&"function"==typeof e.next},"throw":function(e){return e&&"function"==typeof e.throw},task:function(e){return e&&e[l]}}},function(e,n,r){"use strict";function t(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n.default=e,n}function u(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function o(e){if(Array.isArray(e)){for(var n=0,r=Array(e.length);n<e.length;n++)r[n]=e[n];return r}return Array.from(e)}function a(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function i(e){function n(u,o){if(e._isRunning)try{if(o&&!x)throw u;var a=o?e.throw(u):e.next(u);if(a.done)r(a.value);else{var i=t(a.value,k);I.promise[R]=i[R],i.then(n,function(e){return n(e,!0)})}}catch(c){console.warn(w+": uncaught",c),r(c,!0)}}function r(n,r){e._isRunning=!1,r?(e._error=n,I.reject(n)):(e._result=n,I.resolve(n)),U()}function t(e,n){var r=arguments.length<=2||void 0===arguments[2]?"":arguments[2],t=v();N(l.effectTriggered(t,n,r,e));var u=void 0,o=c.is.array(e)?C(e,t):c.is.iterator(e)?i(e,T,j,N,t).done:(u=f.as.take(e))?a(u):(u=f.as.put(e))?s(u):(u=f.as.race(e))?h(u,t):(u=f.as.call(e))?A(u.context,u.fn,u.args,t):(u=f.as.cps(e))?E(u.fn,u.args):(u=f.as.fork(e))?O(u.task,u.args,t):(u=f.as.join(e))?b(u):(u=f.as.cancel(e))?y(u):Promise.resolve(e),d=(0,c.deferred)(),p=!0,m=function(e){return function(n){p&&(p=!1,e(n))}};return o.then(m(d.resolve),m(d.reject)),d.promise[R]=function(e){var n=e.type,r=e.origin;if(p){p=!1;var t=new _(n,w,r);P(o,t),d.reject(t)}},d.promise.then(function(e){return N(l.effectResolved(t,e))},function(e){return N(l.effectRejected(t,e))}),d.promise}function a(e){var n=(0,c.deferred)({match:(0,f.matcher)(e),pattern:e});S.push(n);var r=function(){return(0,c.remove)(S,n)};return n.promise.then(r,r),n.promise[R]=r,n.promise}function s(e){return(0,c.asap)(function(){return j(e)})}function A(e,n,r,t){var u=n.apply(e,r);return c.is.iterator(u)?i(u,T,j,N,t,n.name).done:Promise.resolve(u)}function E(e,n){return new Promise(function(r,t){e.apply(void 0,o(n.concat(function(e,n){return c.is.undef(e)?r(n):t(e)})))})}function O(e,n,r){var t=void 0,u=void 0,a=c.is.func(e);a&&(t=e.apply(void 0,o(n))),u=c.is.iterator(t)?t:c.is.iterator(e)?e:regeneratorRuntime.mark(function s(){return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,a?t:e;case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},s,this)})();var f=a?e.name:"anonymous";return Promise.resolve(i(u,T,j,N,r,f,!0))}function b(e){return e.done}function y(e){return e.done[R](new _(g,"",w)),Promise.resolve()}function C(e,n){var r=e.map(function(e){return t(e,n)}),u=Promise.all(r);return u[R]=function(e){r.forEach(function(n){return P(n,e)})},u.catch(function(){u[R](new _(p,w,w))}),u}function h(e,n){var r=[],o=Promise.race(Object.keys(e).map(function(o){var a=t(e[o],n,o);return r.push(a),a.then(function(e){return u({},o,e)},function(e){return Promise.reject(u({},o,e))})}));o[R]=function(e){r.forEach(function(n){return P(n,e)})};var a=function(){return o[R](new _(m,w,w))};return o.then(a,a),o}function L(e,n,r,t,o){var a;return a={},u(a,c.TASK,!0),u(a,"id",e),u(a,"name",n),u(a,"done",t),u(a,"forked",o),u(a,"isRunning",function(){return r._isRunning}),u(a,"getResult",function(){return r._result}),u(a,"getError",function(){return r._error}),a}function P(e,n){e[R]&&e[R](n)}var T=arguments.length<=1||void 0===arguments[1]?function(){return c.noop}:arguments[1],j=arguments.length<=2||void 0===arguments[2]?c.noop:arguments[2],N=arguments.length<=3||void 0===arguments[3]?c.noop:arguments[3],k=arguments.length<=4||void 0===arguments[4]?0:arguments[4],w=arguments.length<=5||void 0===arguments[5]?"anonymous":arguments[5];(0,c.check)(e,c.is.iterator,d);var S=[],x=c.is.throw(e),I=(0,c.deferred)(),U=T(function(e){S.forEach(function(n){n.match(e)&&n.resolve(e)})});return e._isRunning=!0,n(),L(k,w,e,I.promise)}Object.defineProperty(n,"__esModule",{value:!0}),n.SagaCancellationException=n.CANCEL=n.MANUAL_CANCEL=n.RACE_AUTO_CANCEL=n.PARALLEL_AUTO_CANCEL=n.NOT_ITERATOR_ERROR=void 0,n.default=i;var c=r(1),f=r(4),s=r(6),l=t(s),d=n.NOT_ITERATOR_ERROR="proc first argument (Saga function result) must be an iterator",p=n.PARALLEL_AUTO_CANCEL="PARALLEL_AUTO_CANCEL",m=n.RACE_AUTO_CANCEL="RACE_AUTO_CANCEL",g=n.MANUAL_CANCEL="MANUAL_CANCEL",v=(0,c.autoInc)(),R=n.CANCEL=Symbol("@@redux-saga/cancelPromise"),_=n.SagaCancellationException=function A(e,n,r){a(this,A),this.type=e,this.saga=n,this.origin=r}},function(e,n,r){"use strict";function t(){function e(e){return r.push(e),function(){return(0,u.remove)(r,e)}}function n(e){r.slice().forEach(function(n){return n(e)})}var r=[];return{subscribe:e,emit:n}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=t;var u=r(1)},function(e,n,r){"use strict";function t(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function u(e){return("*"===e?j.wildcard:m.is.array(e)?j.array:m.is.func(e)?j.predicate:j.default)(e)}function o(e){return T(E,m.is.undef(e)?"*":e)}function a(e){return T(O,e)}function i(e){return T(b,e)}function c(e){for(var n=arguments.length,r=Array(n>1?n-1:0),t=1;n>t;t++)r[t-1]=arguments[t];return f(null,e,r)}function f(e,n){var r=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];return(0,m.check)(n,m.is.func,g),T(y,{context:e,fn:n,args:r})}function s(e){for(var n=arguments.length,r=Array(n>1?n-1:0),t=1;n>t;t++)r[t-1]=arguments[t];return(0,m.check)(e,m.is.func,v),T(C,{fn:e,args:r})}function l(e){for(var n=arguments.length,r=Array(n>1?n-1:0),t=1;n>t;t++)r[t-1]=arguments[t];return T(h,{task:e,args:r})}function d(e){if(!N(e))throw new Error(R);return T(L,e)}function p(e){if(!N(e))throw new Error(_);return T(P,e)}Object.defineProperty(n,"__esModule",{value:!0}),n.as=n.CANCEL_ARG_ERROR=n.JOIN_ARG_ERROR=n.FORK_ARG_ERROR=n.CPS_FUNCTION_ARG_ERROR=n.CALL_FUNCTION_ARG_ERROR=void 0,n.matcher=u,n.take=o,n.put=a,n.race=i,n.call=c,n.apply=f,n.cps=s,n.fork=l,n.join=d,n.cancel=p;var m=r(1),g=n.CALL_FUNCTION_ARG_ERROR="call first argument must be a function",v=n.CPS_FUNCTION_ARG_ERROR="cps first argument must be a function",R=(n.FORK_ARG_ERROR="fork first argument must be a generator function or an iterator",n.JOIN_ARG_ERROR="join argument must be a valid task (a result of a fork)"),_=n.CANCEL_ARG_ERROR="cancel argument must be a valid task (a result of a fork)",A=Symbol("IO"),E="TAKE",O="PUT",b="RACE",y="CALL",C="CPS",h="FORK",L="JOIN",P="CANCEL",T=function(e,n){var r;return r={},t(r,A,!0),t(r,e,n),r},j={wildcard:function(){return m.kTrue},"default":function(e){return function(n){return n.type===e}},array:function(e){return function(n){return e.some(function(e){return e===n.type})}},predicate:function(e){return function(n){return e(n)}}},N=function(e){return e[m.TASK]};n.as={take:function(e){return e&&e[A]&&e[E]},put:function(e){return e&&e[A]&&e[O]},race:function(e){return e&&e[A]&&e[b]},call:function(e){return e&&e[A]&&e[y]},cps:function(e){return e&&e[A]&&e[C]},fork:function(e){return e&&e[A]&&e[h]},join:function(e){return e&&e[A]&&e[L]},cancel:function(e){return e&&e[A]&&e[P]}}},function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var u=r(1),o=r(2),a=t(o),i=r(3),c=t(i);n.default=function(){for(var e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];return function(e){var r=e.getState,t=e.dispatch,o=(0,c.default)();return n.forEach(function(e){(0,a.default)(e(r),o.subscribe,t,function(e){return(0,u.asap)(function(){return t(e)})},0,e.name)}),function(e){return function(n){var r=e(n);return o.emit(n),r}}}}},function(e,n){"use strict";function r(e,n,r,t){return{type:o,effectId:e,parentEffectId:n,label:r,effect:t}}function t(e,n){return{type:a,effectId:e,result:n}}function u(e,n){return{type:i,effectId:e,error:n}}Object.defineProperty(n,"__esModule",{value:!0}),n.effectTriggered=r,n.effectResolved=t,n.effectRejected=u;var o=n.EFFECT_TRIGGERED="EFFECT_TRIGGERED",a=n.EFFECT_RESOLVED="EFFECT_RESOLVED",i=n.EFFECT_REJECTED="EFFECT_REJECTED"},function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{"default":e}}function u(e){if(e[d])return e[d];var n=(0,s.default)(),r=e.dispatch;return e.dispatch=function(e){var t=r(e);return n.emit(e),t},e[d]={subscribe:n.subscribe,dispatch:e.dispatch},e[d]}function o(e,n){var r=n.subscribe,t=n.dispatch,u=arguments.length<=2||void 0===arguments[2]?a.noop:arguments[2];return(0,a.check)(e,a.is.iterator,l),(0,c.default)(e,r,t,u)}Object.defineProperty(n,"__esModule",{value:!0}),n.NOT_ITERATOR_ERROR=void 0,n.storeIO=u,n.runSaga=o;var a=r(1),i=r(2),c=t(i),f=r(3),s=t(f),l=n.NOT_ITERATOR_ERROR="runSaga must be called on an iterator",d=Symbol("IO")}])});
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.ReduxSaga=n():e.ReduxSaga=n()}(this,function(){return function(e){function n(t){if(r[t])return r[t].exports;var u=r[t]={exports:{},id:t,loaded:!1};return e[t].call(u.exports,u,u.exports,n),u.loaded=!0,u.exports}var r={};return n.m=e,n.c=r,n.p="",n(0)}([function(e,n,r){"use strict";function t(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n.default=e,n}function u(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0}),n.monitorActions=n.storeIO=n.runSaga=n.as=n.cancel=n.join=n.fork=n.cps=n.apply=n.call=n.race=n.put=n.take=n.is=n.MANUAL_CANCEL=n.PARALLEL_AUTO_CANCEL=n.RACE_AUTO_CANCEL=n.SagaCancellationException=void 0;var o=r(2);Object.defineProperty(n,"SagaCancellationException",{enumerable:!0,get:function(){return o.SagaCancellationException}}),Object.defineProperty(n,"RACE_AUTO_CANCEL",{enumerable:!0,get:function(){return o.RACE_AUTO_CANCEL}}),Object.defineProperty(n,"PARALLEL_AUTO_CANCEL",{enumerable:!0,get:function(){return o.PARALLEL_AUTO_CANCEL}}),Object.defineProperty(n,"MANUAL_CANCEL",{enumerable:!0,get:function(){return o.MANUAL_CANCEL}});var a=r(1);Object.defineProperty(n,"is",{enumerable:!0,get:function(){return a.is}});var i=r(4);Object.defineProperty(n,"take",{enumerable:!0,get:function(){return i.take}}),Object.defineProperty(n,"put",{enumerable:!0,get:function(){return i.put}}),Object.defineProperty(n,"race",{enumerable:!0,get:function(){return i.race}}),Object.defineProperty(n,"call",{enumerable:!0,get:function(){return i.call}}),Object.defineProperty(n,"apply",{enumerable:!0,get:function(){return i.apply}}),Object.defineProperty(n,"cps",{enumerable:!0,get:function(){return i.cps}}),Object.defineProperty(n,"fork",{enumerable:!0,get:function(){return i.fork}}),Object.defineProperty(n,"join",{enumerable:!0,get:function(){return i.join}}),Object.defineProperty(n,"cancel",{enumerable:!0,get:function(){return i.cancel}}),Object.defineProperty(n,"as",{enumerable:!0,get:function(){return i.as}});var c=r(7);Object.defineProperty(n,"runSaga",{enumerable:!0,get:function(){return c.runSaga}}),Object.defineProperty(n,"storeIO",{enumerable:!0,get:function(){return c.storeIO}});var f=r(6),s=u(f),l=r(5),d=t(l);n.default=s.default,n.monitorActions=d},function(e,n){"use strict";function r(e,n,r){if(!n(e))throw new Error(r)}function t(e,n){var r=e.indexOf(n);r>=0&&e.splice(r,1)}function u(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=c({},e),r=new Promise(function(e,r){n.resolve=e,n.reject=r});return n.promise=r,n}function o(e){for(var n=[],r=0;e>r;r++)n.push(u());return n}function a(){var e=arguments.length<=0||void 0===arguments[0]?0:arguments[0];return function(){return++e}}function i(e){return Promise.resolve(1).then(function(){return e()})}var c=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e};Object.defineProperty(n,"__esModule",{value:!0}),n.check=r,n.remove=t,n.deferred=u,n.arrayOfDeffered=o,n.autoInc=a,n.asap=i;var f=n.TASK=Symbol("TASK"),s=(n.kTrue=function(){return!0},n.noop=function(){},n.is={undef:function(e){return null===e||void 0===e},notUndef:function(e){return null!==e&&void 0!==e},func:function(e){return"function"==typeof e},array:Array.isArray,promise:function(e){return e&&s.func(e.then)},iterator:function(e){return e&&s.func(e.next)&&s.func(e[Symbol.iterator])},"throw":function(e){return e&&s.func(e.throw)},task:function(e){return e&&e[f]}})},function(e,n,r){"use strict";function t(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n.default=e,n}function u(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function o(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function a(e){function n(u,o){if(e._isRunning)try{if(o&&!x)throw u;var a=o?e.throw(u):e.next(u);if(a.done)r(a.value);else{var i=t(a.value,N);I.promise[v]=i[v],i.then(n,function(e){return n(e,!0)})}}catch(c){console.warn(w+": uncaught",c),r(c,!0)}}function r(n,r){e._isRunning=!1,r?(e._error=n,I.reject(n)):(e._result=n,I.resolve(n)),S()}function t(e,n){var r=arguments.length<=2||void 0===arguments[2]?"":arguments[2],t=g();P(s.effectTriggered(t,n,r,e));var u=void 0,l=i.is.array(e)?y(e,t):i.is.iterator(e)?a(e,T,j,P,t).done:(u=c.as.take(e))?o(u):(u=c.as.put(e))?f(u):(u=c.as.race(e))?h(u,t):(u=c.as.call(e))?E(u,t):(u=c.as.cps(e))?_(u):(u=c.as.fork(e))?R(u,t):(u=c.as.join(e))?b(u):(u=c.as.cancel(e))?O(u):Promise.resolve(e),d=(0,i.deferred)(),p=!0,m=function(e){return function(n){p&&(p=!1,e(n))}};return l.then(m(d.resolve),m(d.reject)),d.promise[v]=function(e){var n=e.type,r=e.origin;if(p){p=!1;var t=new A(n,w,r);L(l,t),d.reject(t)}},d.promise.then(function(e){return P(s.effectResolved(t,e))},function(e){return P(s.effectRejected(t,e))}),d.promise}function o(e){var n=(0,i.deferred)({match:(0,c.matcher)(e),pattern:e});k.push(n);var r=function(){return(0,i.remove)(k,n)};return n.promise.then(r,r),n.promise[v]=r,n.promise}function f(e){return(0,i.asap)(function(){return j(e)})}function E(e,n){var r=e.context,t=e.fn,u=e.args,o=t.apply(r,u);return i.is.iterator(o)?a(o,T,j,P,n,t.name).done:Promise.resolve(o)}function _(e){var n=e.context,r=e.fn,t=e.args;return new Promise(function(e,u){r.apply(n,t.concat(function(n,r){return i.is.undef(n)?e(r):u(n)}))})}function R(e,n){var r=e.context,t=e.fn,u=e.args,o=void 0,c=void 0;return o=t.apply(r,u),c=i.is.iterator(o)?o:regeneratorRuntime.mark(function f(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o;case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},f,this)})(),Promise.resolve(a(c,T,j,P,n,t.name,!0))}function b(e){return e.done}function O(e){return e.done[v](new A(m,"",w)),Promise.resolve()}function y(e,n){var r=e.map(function(e){return t(e,n)}),u=Promise.all(r);return u[v]=function(e){r.forEach(function(n){return L(n,e)})},u.catch(function(){u[v](new A(d,w,w))}),u}function h(e,n){var r=[],o=Promise.race(Object.keys(e).map(function(o){var a=t(e[o],n,o);return r.push(a),a.then(function(e){return u({},o,e)},function(e){return Promise.reject(u({},o,e))})}));o[v]=function(e){r.forEach(function(n){return L(n,e)})};var a=function(){return o[v](new A(p,w,w))};return o.then(a,a),o}function C(e,n,r,t,o){var a;return a={},u(a,i.TASK,!0),u(a,"id",e),u(a,"name",n),u(a,"done",t),u(a,"forked",o),u(a,"isRunning",function(){return r._isRunning}),u(a,"getResult",function(){return r._result}),u(a,"getError",function(){return r._error}),a}function L(e,n){e[v]&&e[v](n)}var T=arguments.length<=1||void 0===arguments[1]?function(){return i.noop}:arguments[1],j=arguments.length<=2||void 0===arguments[2]?i.noop:arguments[2],P=arguments.length<=3||void 0===arguments[3]?i.noop:arguments[3],N=arguments.length<=4||void 0===arguments[4]?0:arguments[4],w=arguments.length<=5||void 0===arguments[5]?"anonymous":arguments[5];(0,i.check)(e,i.is.iterator,l);var k=[],x=i.is.throw(e),I=(0,i.deferred)(),S=T(function(e){k.forEach(function(n){n.match(e)&&n.resolve(e)})});return e._isRunning=!0,n(),C(N,w,e,I.promise)}Object.defineProperty(n,"__esModule",{value:!0}),n.SagaCancellationException=n.CANCEL=n.MANUAL_CANCEL=n.RACE_AUTO_CANCEL=n.PARALLEL_AUTO_CANCEL=n.NOT_ITERATOR_ERROR=void 0,n.default=a;var i=r(1),c=r(4),f=r(5),s=t(f),l=n.NOT_ITERATOR_ERROR="proc first argument (Saga function result) must be an iterator",d=n.PARALLEL_AUTO_CANCEL="PARALLEL_AUTO_CANCEL",p=n.RACE_AUTO_CANCEL="RACE_AUTO_CANCEL",m=n.MANUAL_CANCEL="MANUAL_CANCEL",g=(0,i.autoInc)(),v=n.CANCEL=Symbol("@@redux-saga/cancelPromise"),A=n.SagaCancellationException=function E(e,n,r){o(this,E),this.type=e,this.saga=n,this.origin=r}},function(e,n,r){"use strict";function t(){function e(e){return r.push(e),function(){return(0,u.remove)(r,e)}}function n(e){r.slice().forEach(function(n){return n(e)})}var r=[];return{subscribe:e,emit:n}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=t;var u=r(1)},function(e,n,r){"use strict";function t(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function u(e){return("*"===e?w.wildcard:v.is.array(e)?w.array:v.is.func(e)?w.predicate:w.default)(e)}function o(e){if(arguments.length>0&&v.is.undef(e))throw new Error(R);return N(O,v.is.undef(e)?"*":e)}function a(e){return N(y,e)}function i(e){return N(h,e)}function c(e,n){(0,v.check)(e,v.is.notUndef,A);var r=null;if(v.is.array(e)){var t=e,u=g(t,2);r=u[0],e=u[1]}else if(e.fn){var o=e;r=o.context,e=o.fn}return(0,v.check)(e,v.is.func,A),{context:r,fn:e,args:n}}function f(e){for(var n=arguments.length,r=Array(n>1?n-1:0),t=1;n>t;t++)r[t-1]=arguments[t];return N(C,c(e,r))}function s(e,n){var r=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];return N(C,c({context:e,fn:n},r))}function l(e){for(var n=arguments.length,r=Array(n>1?n-1:0),t=1;n>t;t++)r[t-1]=arguments[t];return N(L,c(e,r))}function d(e){for(var n=arguments.length,r=Array(n>1?n-1:0),t=1;n>t;t++)r[t-1]=arguments[t];return N(T,c(e,r))}function p(e){if(!k(e))throw new Error(E);return N(j,e)}function m(e){if(!k(e))throw new Error(_);return N(P,e)}var g=function(){function e(e,n){var r=[],t=!0,u=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(t=(a=i.next()).done)&&(r.push(a.value),!n||r.length!==n);t=!0);}catch(c){u=!0,o=c}finally{try{!t&&i.return&&i.return()}finally{if(u)throw o}}return r}return function(n,r){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();Object.defineProperty(n,"__esModule",{value:!0}),n.as=n.INVALID_PATTERN=n.CANCEL_ARG_ERROR=n.JOIN_ARG_ERROR=n.FORK_ARG_ERROR=n.CALL_FUNCTION_ARG_ERROR=void 0,n.matcher=u,n.take=o,n.put=a,n.race=i,n.call=f,n.apply=s,n.cps=l,n.fork=d,n.join=p,n.cancel=m;var v=r(1),A=n.CALL_FUNCTION_ARG_ERROR="call/cps/fork first argument must be a function, an array [context, function] or an object {context, fn}",E=(n.FORK_ARG_ERROR="fork first argument must be a generator function or an iterator",n.JOIN_ARG_ERROR="join argument must be a valid task (a result of a fork)"),_=n.CANCEL_ARG_ERROR="cancel argument must be a valid task (a result of a fork)",R=n.INVALID_PATTERN="Invalid pattern passed to `take` (HINT: check if you didn't mispell a constant)",b=Symbol("IO"),O="TAKE",y="PUT",h="RACE",C="CALL",L="CPS",T="FORK",j="JOIN",P="CANCEL",N=function(e,n){var r;return r={},t(r,b,!0),t(r,e,n),r},w={wildcard:function(){return v.kTrue},"default":function(e){return function(n){return n.type===e}},array:function(e){return function(n){return e.some(function(e){return e===n.type})}},predicate:function(e){return function(n){return e(n)}}},k=function(e){return e[v.TASK]};n.as={take:function(e){return e&&e[b]&&e[O]},put:function(e){return e&&e[b]&&e[y]},race:function(e){return e&&e[b]&&e[h]},call:function(e){return e&&e[b]&&e[C]},cps:function(e){return e&&e[b]&&e[L]},fork:function(e){return e&&e[b]&&e[T]},join:function(e){return e&&e[b]&&e[j]},cancel:function(e){return e&&e[b]&&e[P]}}},function(e,n){"use strict";function r(e,n,r,t){return{type:o,effectId:e,parentEffectId:n,label:r,effect:t}}function t(e,n){return{type:a,effectId:e,result:n}}function u(e,n){return{type:i,effectId:e,error:n}}Object.defineProperty(n,"__esModule",{value:!0}),n.effectTriggered=r,n.effectResolved=t,n.effectRejected=u;var o=n.EFFECT_TRIGGERED="EFFECT_TRIGGERED",a=n.EFFECT_RESOLVED="EFFECT_RESOLVED",i=n.EFFECT_REJECTED="EFFECT_REJECTED"},function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var u=r(1),o=r(2),a=t(o),i=r(3),c=t(i);n.default=function(){for(var e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];return function(e){var r=e.getState,t=e.dispatch,o=(0,c.default)();return n.forEach(function(e){(0,a.default)(e(r),o.subscribe,t,function(e){return(0,u.asap)(function(){return t(e)})},0,e.name)}),function(e){return function(n){var r=e(n);return o.emit(n),r}}}}},function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{"default":e}}function u(e){if(e[d])return e[d];var n=(0,s.default)(),r=e.dispatch;return e.dispatch=function(e){var t=r(e);return n.emit(e),t},e[d]={subscribe:n.subscribe,dispatch:e.dispatch},e[d]}function o(e,n){var r=n.subscribe,t=n.dispatch,u=arguments.length<=2||void 0===arguments[2]?a.noop:arguments[2];return(0,a.check)(e,a.is.iterator,l),(0,c.default)(e,r,t,u)}Object.defineProperty(n,"__esModule",{value:!0}),n.NOT_ITERATOR_ERROR=void 0,n.storeIO=u,n.runSaga=o;var a=r(1),i=r(2),c=t(i),f=r(3),s=t(f),l=n.NOT_ITERATOR_ERROR="runSaga must be called on an iterator",d=Symbol("IO")}])});

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

});
exports.storeIO = exports.runSaga = exports.as = exports.cancel = exports.join = exports.fork = exports.cps = exports.apply = exports.call = exports.race = exports.put = exports.take = exports.MANUAL_CANCEL = exports.PARALLEL_AUTO_CANCEL = exports.RACE_AUTO_CANCEL = exports.SagaCancellationException = undefined;
exports.monitorActions = exports.storeIO = exports.runSaga = exports.as = exports.cancel = exports.join = exports.fork = exports.cps = exports.apply = exports.call = exports.race = exports.put = exports.take = exports.is = exports.MANUAL_CANCEL = exports.PARALLEL_AUTO_CANCEL = exports.RACE_AUTO_CANCEL = exports.SagaCancellationException = undefined;

@@ -36,2 +36,11 @@ var _proc = require('./proc');

var _utils = require('./utils');
Object.defineProperty(exports, 'is', {
enumerable: true,
get: function get() {
return _utils.is;
}
});
var _io = require('./io');

@@ -119,4 +128,11 @@

var _monitorActions = require('./monitorActions');
var monitorActions = _interopRequireWildcard(_monitorActions);
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 }; }
exports.default = _middleware2.default;
exports.default = _middleware2.default;
exports.monitorActions = monitorActions;
"use strict";
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.as = exports.CANCEL_ARG_ERROR = exports.JOIN_ARG_ERROR = exports.FORK_ARG_ERROR = exports.CPS_FUNCTION_ARG_ERROR = exports.CALL_FUNCTION_ARG_ERROR = undefined;
exports.as = exports.INVALID_PATTERN = exports.CANCEL_ARG_ERROR = exports.JOIN_ARG_ERROR = exports.FORK_ARG_ERROR = exports.CALL_FUNCTION_ARG_ERROR = undefined;
exports.matcher = matcher;

@@ -22,7 +24,7 @@ exports.take = take;

var CALL_FUNCTION_ARG_ERROR = exports.CALL_FUNCTION_ARG_ERROR = "call first argument must be a function";
var CPS_FUNCTION_ARG_ERROR = exports.CPS_FUNCTION_ARG_ERROR = "cps first argument must be a function";
var CALL_FUNCTION_ARG_ERROR = exports.CALL_FUNCTION_ARG_ERROR = "call/cps/fork first argument must be a function, an array [context, function] or an object {context, fn}";
var FORK_ARG_ERROR = exports.FORK_ARG_ERROR = "fork first argument must be a generator function or an iterator";
var JOIN_ARG_ERROR = exports.JOIN_ARG_ERROR = "join argument must be a valid task (a result of a fork)";
var CANCEL_ARG_ERROR = exports.CANCEL_ARG_ERROR = "cancel argument must be a valid task (a result of a fork)";
var INVALID_PATTERN = exports.INVALID_PATTERN = "Invalid pattern passed to `take` (HINT: check if you didn't mispell a constant)";

@@ -73,2 +75,6 @@ var IO = Symbol('IO');

function take(pattern) {
if (arguments.length > 0 && _utils.is.undef(pattern)) {
throw new Error(INVALID_PATTERN);
}
return effect(TAKE, _utils.is.undef(pattern) ? '*' : pattern);

@@ -85,2 +91,23 @@ }

function getFnCallDesc(fn, args) {
(0, _utils.check)(fn, _utils.is.notUndef, CALL_FUNCTION_ARG_ERROR);
var context = null;
if (_utils.is.array(fn)) {
var _fn = fn;
var _fn2 = _slicedToArray(_fn, 2);
context = _fn2[0];
fn = _fn2[1];
} else if (fn.fn) {
var _fn3 = fn;
context = _fn3.context;
fn = _fn3.fn;
}
(0, _utils.check)(fn, _utils.is.func, CALL_FUNCTION_ARG_ERROR);
return { context: context, fn: fn, args: args };
}
function call(fn) {

@@ -91,3 +118,3 @@ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

return apply(null, fn, args);
return effect(CALL, getFnCallDesc(fn, args));
}

@@ -98,4 +125,3 @@

(0, _utils.check)(fn, _utils.is.func, CALL_FUNCTION_ARG_ERROR);
return effect(CALL, { context: context, fn: fn, args: args });
return effect(CALL, getFnCallDesc({ context: context, fn: fn }, args));
}

@@ -108,7 +134,6 @@

(0, _utils.check)(fn, _utils.is.func, CPS_FUNCTION_ARG_ERROR);
return effect(CPS, { fn: fn, args: args });
return effect(CPS, getFnCallDesc(fn, args));
}
function fork(task) {
function fork(fn) {
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {

@@ -118,3 +143,3 @@ args[_key3 - 1] = arguments[_key3];

return effect(FORK, { task: task, args: args });
return effect(FORK, getFnCallDesc(fn, args));
}

@@ -121,0 +146,0 @@

@@ -21,4 +21,2 @@ 'use strict';

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -109,3 +107,3 @@

var data = undefined;
var promise = _utils.is.array(effect) ? runParallelEffect(effect, effectId) : _utils.is.iterator(effect) ? proc(effect, subscribe, dispatch, monitor, effectId).done : (data = _io.as.take(effect)) ? runTakeEffect(data) : (data = _io.as.put(effect)) ? runPutEffect(data) : (data = _io.as.race(effect)) ? runRaceEffect(data, effectId) : (data = _io.as.call(effect)) ? runCallEffect(data.context, data.fn, data.args, effectId) : (data = _io.as.cps(effect)) ? runCPSEffect(data.fn, data.args) : (data = _io.as.fork(effect)) ? runForkEffect(data.task, data.args, effectId) : (data = _io.as.join(effect)) ? runJoinEffect(data) : (data = _io.as.cancel(effect)) ? runCancelEffect(data) : /* resolve anything else */Promise.resolve(effect);
var promise = _utils.is.array(effect) ? runParallelEffect(effect, effectId) : _utils.is.iterator(effect) ? proc(effect, subscribe, dispatch, monitor, effectId).done : (data = _io.as.take(effect)) ? runTakeEffect(data) : (data = _io.as.put(effect)) ? runPutEffect(data) : (data = _io.as.race(effect)) ? runRaceEffect(data, effectId) : (data = _io.as.call(effect)) ? runCallEffect(data, effectId) : (data = _io.as.cps(effect)) ? runCPSEffect(data) : (data = _io.as.fork(effect)) ? runForkEffect(data, effectId) : (data = _io.as.join(effect)) ? runJoinEffect(data) : (data = _io.as.cancel(effect)) ? runCancelEffect(data) : /* resolve anything else */Promise.resolve(effect);

@@ -160,3 +158,7 @@ var def = (0, _utils.deferred)();

function runCallEffect(context, fn, args, effectId) {
function runCallEffect(_ref2, effectId) {
var context = _ref2.context;
var fn = _ref2.fn;
var args = _ref2.args;
var result = fn.apply(context, args);

@@ -166,18 +168,25 @@ return !_utils.is.iterator(result) ? Promise.resolve(result) : proc(result, subscribe, dispatch, monitor, effectId, fn.name).done;

function runCPSEffect(fn, args) {
function runCPSEffect(_ref3) {
var context = _ref3.context;
var fn = _ref3.fn;
var args = _ref3.args;
return new Promise(function (resolve, reject) {
fn.apply(undefined, _toConsumableArray(args.concat(function (err, res) {
fn.apply(context, args.concat(function (err, res) {
return _utils.is.undef(err) ? resolve(res) : reject(err);
})));
}));
});
}
function runForkEffect(task, args, effectId) {
function runForkEffect(_ref4, effectId) {
var context = _ref4.context;
var fn = _ref4.fn;
var args = _ref4.args;
var result = undefined,
_iterator = undefined;
var isFunc = _utils.is.func(task);
// we run the function, next we'll check if this is a generator function
// (generator is a function that returns an iterator)
if (isFunc) result = task.apply(undefined, _toConsumableArray(args));
result = fn.apply(context, args);

@@ -188,30 +197,26 @@ // A generator function: i.e. returns an iterator

}
// directly forking an iterator
else if (_utils.is.iterator(task)) {
_iterator = task;
}
//simple effect: wrap in a generator
else {
_iterator = regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return isFunc ? result : task;
case 2:
return _context.abrupt('return', _context.sent);
//simple effect: wrap in a generator
else {
_iterator = regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return result;
case 3:
case 'end':
return _context.stop();
}
case 2:
return _context.abrupt('return', _context.sent);
case 3:
case 'end':
return _context.stop();
}
}, _callee, this);
})();
}
}
}, _callee, this);
})();
}
var name = isFunc ? task.name : 'anonymous';
return Promise.resolve(proc(_iterator, subscribe, dispatch, monitor, effectId, name, true));
return Promise.resolve(proc(_iterator, subscribe, dispatch, monitor, effectId, fn.name, true));
}

@@ -271,11 +276,11 @@

function newTask(id, name, iterator, done, forked) {
var _ref3;
var _ref6;
return _ref3 = {}, _defineProperty(_ref3, _utils.TASK, true), _defineProperty(_ref3, 'id', id), _defineProperty(_ref3, 'name', name), _defineProperty(_ref3, 'done', done), _defineProperty(_ref3, 'forked', forked), _defineProperty(_ref3, 'isRunning', function isRunning() {
return _ref6 = {}, _defineProperty(_ref6, _utils.TASK, true), _defineProperty(_ref6, 'id', id), _defineProperty(_ref6, 'name', name), _defineProperty(_ref6, 'done', done), _defineProperty(_ref6, 'forked', forked), _defineProperty(_ref6, 'isRunning', function isRunning() {
return iterator._isRunning;
}), _defineProperty(_ref3, 'getResult', function getResult() {
}), _defineProperty(_ref6, 'getResult', function getResult() {
return iterator._result;
}), _defineProperty(_ref3, 'getError', function getError() {
}), _defineProperty(_ref6, 'getError', function getError() {
return iterator._error;
}), _ref3;
}), _ref6;
}

@@ -282,0 +287,0 @@

@@ -14,5 +14,2 @@ 'use strict';

exports.asap = asap;
var _marked = [sampleGen].map(regeneratorRuntime.mark);
var TASK = exports.TASK = Symbol('TASK');

@@ -28,13 +25,2 @@ var kTrue = exports.kTrue = function kTrue() {

function sampleGen() {
return regeneratorRuntime.wrap(function sampleGen$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
case 'end':
return _context.stop();
}
}, _marked[0], this);
}
var genConstructor = sampleGen.constructor;
var is = exports.is = {

@@ -44,2 +30,5 @@ undef: function undef(v) {

},
notUndef: function notUndef(v) {
return v !== null && v !== undefined;
},
func: function func(f) {

@@ -50,12 +39,9 @@ return typeof f === 'function';

promise: function promise(p) {
return p && typeof p.then === 'function';
return p && is.func(p.then);
},
generator: function generator(g) {
return is.func(g) && g.constructor === genConstructor;
},
iterator: function iterator(it) {
return it && typeof it.next === 'function';
return it && is.func(it.next) && is.func(it[Symbol.iterator]);
},
throw: function _throw(it) {
return it && typeof it.throw === 'function';
return it && is.func(it.throw);
},

@@ -62,0 +48,0 @@ task: function task(it) {

{
"name": "redux-saga",
"version": "0.4.1",
"version": "0.5.0",
"description": "Saga middleware for Redux to handle Side Effects",

@@ -15,12 +15,7 @@ "main": "lib/index.js",

"prepublish": "npm run check && npm run compile && npm run build:umd",
"counter": "budo examples/counter/src/main.js:build.js --dir examples/counter --verbose --live -- -t babelify",
"build-counter": "browserify --debug examples/counter/src/main.js -t babelify --outfile examples/counter/build.js",
"counter": "node examples/counter/server.js",
"test-counter": "babel-node examples/counter/test/sagas.js | tap-spec",
"shop": "budo examples/shopping-cart/src/main.js:build.js --dir examples/shopping-cart --verbose --live -- -t babelify",
"build-shop": "browserify --debug examples/shopping-cart/src/main.js -t babelify --outfile examples/shopping-cart/build.js",
"shop": "node examples/shopping-cart/server.js",
"test-shop": "babel-node examples/shopping-cart/test/sagas.js | tap-spec",
"async": "budo examples/async/src/main.js:build.js --dir examples/async --verbose --live -- -t babelify",
"build-async": "browserify --debug examples/async/src/main.js -t babelify --outfile examples/async/build.js",
"build-examples": "npm run build-counter && npm run build-shop && npm run build-async",
"test-examples": "npm run test-counter && npm run test-shop",
"async": "node examples/async/server.js",
"real-world": "node examples/real-world/server.js"

@@ -56,4 +51,4 @@ },

"babel-preset-stage-2": "^6.1.18",
"babelify": "^7.2.0",
"eslint": "^1.9.0",
"express": "^4.13.3",
"isomorphic-fetch": "^2.2.0",

@@ -68,3 +63,5 @@ "react": "^0.14.3",

"tape": "^4.2.2",
"webpack": "1.12.10"
"webpack": "1.12.10",
"webpack-dev-middleware": "^1.4.0",
"webpack-hot-middleware": "^2.6.0"
},

@@ -71,0 +68,0 @@ "npmName": "redux-saga",

@@ -17,5 +17,7 @@ # redux-saga

>This middleware is not only about handling asynchronous flow. If all what matters is simplifying
asynchronous control flow, one could simply use async/await functions with some promise middleware.
> As you'll in the rest of this README. Generators, while they seem lower level than ES7 async
functions, allow some features like declarative effects, cancellation. Which are harder, if Not
impossible, to implement with simple async functions.
What this middleware proposes is

@@ -39,3 +41,5 @@

- [Getting started](#getting-started)
- [How is this different from other asynchronous middlewares](#how-is-this-different-from-the-others)
- [Waiting for future actions](#waiting-for-future-actions)
- [Dispatching actions to the store](#dispatching-actions-to-the-store)
- [A common abstraction: Effect](#a-common-abstraction-effect)
- [Declarative Effects](#declarative-effects)

@@ -100,5 +104,5 @@ - [Error handling](#error-handling)

#How is this different from the others
#Waiting for future actions
In the previous example we created an `incrementAsync` Saga. The call `yield take(action)` is a
In the previous example we created an `incrementAsync` Saga. The call `yield take(INCREMENT_ASYNC)` is a
typical illustration of how Sagas work.

@@ -119,6 +123,23 @@

Above, we used the form `take(INCREMENT_ASYNC)`, which means we're waiting for an action whose type
is `INCREMENT_ASYNC`.
`take` support some more patterns to constrain future actions matching. A call of `yield take(PATTERN)` will be
handled using the following rules
- If PATTERN is undefined or `'*'`. All incoming actions are matched (e.g. `take()` will match all actions)
- If PATTERN is a function, the action is matched if PATTERN(action) is true (e.g. `take(action => action.entities)`
will match all actions having a (truthy) `entities`field.
- If PATTERN is a string, the action is matched if action.type === PATTERN (as used above `take(INCREMENT_ASYNC)`
- If PATTERN is an array, action.type is matched against all items in the array (e.g. `take([INCREMENT, DECREMENT])` will
match either actions of type `INCREMENT` or `DECREMENT`.
#Dispatching actions to the store
After receiving the queried action, the Saga triggers a call to `delay(1000)`, which in our example
returns a Promise that will be resolved after 1 second. Again, this is a blocking call, so the Saga
will wait for 1 second before continuing on (a better way is `call(delay, 1000)`, as we'll see in
the section on declarative Effects).
returns a Promise that will be resolved after 1 second. This is a blocking call, so the Saga
will wait for 1 second before continuing on.

@@ -130,11 +151,20 @@ After the delay, the Saga dispatches an `INCREMENT_COUNTER` action using the `put(action)`

To generalize, waiting for a future action (`yield take(MY_ACTION)`), waiting for the future result of
a function call (`yield delay(1000)`) or waiting for the result of a dispatch (`yield put(myAction())`)
all are the same concept. In all cases, we are yielding some form of side effects.
#A common abstraction: Effect
Note also how `incrementAsync` uses an infinite loop `while(true)` which means it will stay alive
for all the application lifetime. You can also create Sagas that last only for a limited amount of
time. For example, the following Saga waits for the first 3 `INCREMENT_COUNTER` actions,
triggers a `showCongratulation()` action and then finishes.
To generalize, waiting for a future action, waiting for the future result of a function call like
`yield delay(1000)`, or waiting for the result of a dispatch all are the same concept. In all cases,
we are yielding some form of Effects.
What a Saga does is actually composing all those effects together to implement the desired control flow.
The simplest is to sequence yielded Effects by just putting the yields one after another. You can also use the
familiar control flow operators (if, while, for) to implement more sophisticated control flows. Or you
you can use the provided Effects combinators to express concurrency (yield race) and parallelism (yield [...]).
You can even yield calls to other Sagas, allowing the powerful routine/subroutine pattern.
For example, `incrementAsync` uses an infinite loop `while(true)` which means it will stay alive
for all the application lifetime.
You can also create Sagas that last only for a limited amount of time. For example, the following Saga
waits for the first 3 `INCREMENT_COUNTER` actions, triggers a `showCongratulation()` action and then finishes.
```javascript

@@ -228,8 +258,15 @@ function* onBoarding() {

Besides `call`, the `apply` effect allows you to provide a `this` context to the invoked functions
To invoke methods of some object (i.e. created with `new`), you can provide a `this` context to the
invoked functions using the following form
```javascript
yield apply(context, myfunc, [arg1, arg2, ...])
yield call([obj, obj.method], arg1, arg2, ...) // as if we did obj.method(arg1, arg2 ...)
```
`apply` is an alias for the method invocation form
```javascript
yield apply(obj, obj.method, [arg1, arg2, ...])
```
`call` and `apply` are well suited for functions that return Promise results. Another function

@@ -254,2 +291,4 @@ `cps` can be used to handle Node style functions (e.g. `fn(...args, callback)` where `callback`

`cps` supports also the same method invocation form as `call`
#Error handling

@@ -510,3 +549,2 @@

yield fork(generator, ...args) // Generator functions
yield fork( put(someActions) ) // Simple effects
```

@@ -686,7 +724,7 @@

import serverSaga from 'somewhere'
import {runSaga, storeIO} from 'reduc-saga'
import {runSaga, storeIO} from 'redux-saga'
import configureStore from 'somewhere'
import rootReducer from 'somewhere'
const store = createStore(rootReducer)
const store = configureStore(rootReducer)
runSaga(

@@ -698,2 +736,4 @@ serverSaga(store.getState),

`runSaga` returns a task object. Just like the one returned from a `fork` effect.
Besides taking and dispatching actions to the store `runSaga` can also be connected to

@@ -730,13 +770,5 @@ other input/output sources. This allows you to exploit all the features of sagas to implement

The `subscribe` argument is used to fulfill `take(action)` effects. Each time `subscribe` emits an action
to its callbacks, all sagas blocked on `take(PATTERN)`. And whose take pattern matches the currently incoming action
to its callbacks, all sagas blocked on `take(PATTERN)`, and whose take pattern matches the currently incoming action
are resumed with that action.
The matching works as follows
- If `PATTERN` is undefined or '*'. All actions are matched
- If `PATTERN` is a function, the action is matched if `PATTERN(action)` is true
- If `PATTERN` is a string, the action is matched if `action.type === PATTERN`
- If `PATTERN` is an array, `action.type` is matched against all items in the array.
#Building examples from sources

@@ -747,3 +779,2 @@

- browserify
- [budo](https://github.com/mattdesl/budo) to serve with live-reload `npm i -g budo`

@@ -809,5 +840,6 @@ You can also build the examples manually, and open `index.html` at the root of each example

The following builds are available:
[https://npmcdn.com/redux-saga/dist/redux-saga.js](https://npmcdn.com/redux-saga/dist/redux-saga.js)
[https://npmcdn.com/redux-saga/dist/redux-saga.min.js](https://npmcdn.com/redux-saga/dist/redux-saga.min.js)
- [https://npmcdn.com/redux-saga/dist/redux-saga.js](https://npmcdn.com/redux-saga/dist/redux-saga.js)
- [https://npmcdn.com/redux-saga/dist/redux-saga.min.js](https://npmcdn.com/redux-saga/dist/redux-saga.min.js)
**Important!** If the browser you are targeting doesn't support _es2015 generators_ you must provide a valid polyfill, for example the one provided by *babel*: [browser-polyfill.min.js](https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.25/browser-polyfill.min.js). The polyfill must be imported before **redux-saga**.

@@ -11,3 +11,7 @@ import middleware from './middleware'

export { is } from './utils'
export { take, put, race, call, apply, cps, fork, join, cancel, as } from './io'
export { runSaga, storeIO } from './runSaga'
import * as monitorActions from './monitorActions'
export { monitorActions }
import { is, kTrue, check, TASK } from './utils'
export const CALL_FUNCTION_ARG_ERROR = "call first argument must be a function"
export const CPS_FUNCTION_ARG_ERROR = "cps first argument must be a function"
export const CALL_FUNCTION_ARG_ERROR = "call/cps/fork first argument must be a function, an array [context, function] or an object {context, fn}"
export const FORK_ARG_ERROR = "fork first argument must be a generator function or an iterator"
export const JOIN_ARG_ERROR = "join argument must be a valid task (a result of a fork)"
export const CANCEL_ARG_ERROR = "cancel argument must be a valid task (a result of a fork)"
export const INVALID_PATTERN = "Invalid pattern passed to `take` (HINT: check if you didn't mispell a constant)"

@@ -40,2 +40,6 @@

export function take(pattern){
if (arguments.length > 0 && is.undef(pattern)) {
throw new Error(INVALID_PATTERN)
}
return effect(TAKE, is.undef(pattern) ? '*' : pattern)

@@ -52,18 +56,30 @@ }

function getFnCallDesc(fn, args) {
check(fn, is.notUndef, CALL_FUNCTION_ARG_ERROR)
let context = null
if(is.array(fn)) {
[context, fn] = fn
} else if(fn.fn) {
({context, fn} = fn)
}
check(fn, is.func, CALL_FUNCTION_ARG_ERROR)
return {context, fn, args}
}
export function call(fn, ...args) {
return apply(null, fn, args)
return effect(CALL, getFnCallDesc(fn, args))
}
export function apply(context, fn, args = []) {
check(fn, is.func, CALL_FUNCTION_ARG_ERROR)
return effect(CALL, { context, fn, args })
return effect(CALL, getFnCallDesc({context, fn}, args))
}
export function cps(fn, ...args) {
check(fn, is.func, CPS_FUNCTION_ARG_ERROR)
return effect(CPS,{ fn, args })
return effect(CPS, getFnCallDesc(fn, args))
}
export function fork(task, ...args) {
return effect(FORK, { task, args })
export function fork(fn, ...args) {
return effect(FORK, getFnCallDesc(fn, args))
}

@@ -70,0 +86,0 @@

@@ -97,5 +97,5 @@ import { noop, is, check, remove, deferred, autoInc, asap, TASK } from './utils'

: (data = as.race(effect)) ? runRaceEffect(data, effectId)
: (data = as.call(effect)) ? runCallEffect(data.context, data.fn, data.args, effectId)
: (data = as.cps(effect)) ? runCPSEffect(data.fn, data.args)
: (data = as.fork(effect)) ? runForkEffect(data.task, data.args, effectId)
: (data = as.call(effect)) ? runCallEffect(data, effectId)
: (data = as.cps(effect)) ? runCPSEffect(data)
: (data = as.fork(effect)) ? runForkEffect(data, effectId)
: (data = as.join(effect)) ? runJoinEffect(data)

@@ -146,3 +146,3 @@ : (data = as.cancel(effect)) ? runCancelEffect(data)

function runCallEffect(context, fn, args, effectId) {
function runCallEffect({context, fn, args}, effectId) {
const result = fn.apply(context, args)

@@ -154,5 +154,5 @@ return !is.iterator(result)

function runCPSEffect(fn, args) {
function runCPSEffect({context, fn, args}) {
return new Promise((resolve, reject) => {
fn(...args.concat(
fn.apply(context, args.concat(
(err, res) => is.undef(err) ? resolve(res) : reject(err)

@@ -163,10 +163,8 @@ ))

function runForkEffect(task, args, effectId) {
function runForkEffect({context, fn, args}, effectId) {
let result, _iterator
const isFunc = is.func(task)
// we run the function, next we'll check if this is a generator function
// (generator is a function that returns an iterator)
if(isFunc)
result = task(...args)
result = fn.apply(context, args)

@@ -177,16 +175,12 @@ // A generator function: i.e. returns an iterator

}
// directly forking an iterator
else if(is.iterator(task)) {
_iterator = task
}
//simple effect: wrap in a generator
else {
_iterator = function*() {
return ( yield isFunc ? result : task )
return (yield result)
}()
}
const name = isFunc ? task.name : 'anonymous'
return Promise.resolve(
proc(_iterator, subscribe, dispatch, monitor, effectId, name, true)
proc(_iterator, subscribe, dispatch, monitor, effectId, fn.name, true)
)

@@ -193,0 +187,0 @@ }

@@ -10,13 +10,10 @@ export const TASK = Symbol('TASK')

function* sampleGen() {}
const genConstructor = sampleGen.constructor
export const is = {
undef : v => v === null || v === undefined,
notUndef : v => v !== null && v !== undefined,
func : f => typeof f === 'function',
array : Array.isArray,
promise : p => p && typeof p.then === 'function',
generator : g => is.func(g) && g.constructor === genConstructor,
iterator : it => it && typeof it.next === 'function',
throw : it => it && typeof it.throw === 'function',
promise : p => p && is.func(p.then),
iterator : it => it && is.func(it.next) && is.func(it[Symbol.iterator]),
throw : it => it && is.func(it.throw),
task : it => it && it[TASK]

@@ -23,0 +20,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc