redux-saga
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -62,120 +62,36 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
}); | ||
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.SagaCancellationException = exports.MANUAL_CANCEL = exports.PARALLEL_AUTO_CANCEL = exports.RACE_AUTO_CANCEL = exports.CANCEL = undefined; | ||
exports.utils = exports.effects = exports.takeLatest = exports.takeEvery = exports.storeIO = exports.runSaga = exports.isCancelError = exports.SagaCancellationException = undefined; | ||
var _proc = __webpack_require__(4); | ||
var _runSaga = __webpack_require__(9); | ||
Object.defineProperty(exports, 'CANCEL', { | ||
Object.defineProperty(exports, 'runSaga', { | ||
enumerable: true, | ||
get: function get() { | ||
return _proc.CANCEL; | ||
return _runSaga.runSaga; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'RACE_AUTO_CANCEL', { | ||
Object.defineProperty(exports, 'storeIO', { | ||
enumerable: true, | ||
get: function get() { | ||
return _proc.RACE_AUTO_CANCEL; | ||
return _runSaga.storeIO; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'PARALLEL_AUTO_CANCEL', { | ||
enumerable: true, | ||
get: function get() { | ||
return _proc.PARALLEL_AUTO_CANCEL; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'MANUAL_CANCEL', { | ||
enumerable: true, | ||
get: function get() { | ||
return _proc.MANUAL_CANCEL; | ||
} | ||
}); | ||
var _utils = __webpack_require__(1); | ||
var _sagaHelpers = __webpack_require__(10); | ||
Object.defineProperty(exports, 'is', { | ||
Object.defineProperty(exports, 'takeEvery', { | ||
enumerable: true, | ||
get: function get() { | ||
return _utils.is; | ||
return _sagaHelpers.takeEvery; | ||
} | ||
}); | ||
var _io = __webpack_require__(6); | ||
Object.defineProperty(exports, 'take', { | ||
Object.defineProperty(exports, 'takeLatest', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.take; | ||
return _sagaHelpers.takeLatest; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'put', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.put; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'race', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.race; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'call', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.call; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'apply', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.apply; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'cps', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.cps; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'fork', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.fork; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'join', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.join; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'cancel', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.cancel; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'as', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.as; | ||
} | ||
}); | ||
var _runSaga = __webpack_require__(8); | ||
var _middleware = __webpack_require__(8); | ||
Object.defineProperty(exports, 'runSaga', { | ||
enumerable: true, | ||
get: function get() { | ||
return _runSaga.runSaga; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'storeIO', { | ||
enumerable: true, | ||
get: function get() { | ||
return _runSaga.storeIO; | ||
} | ||
}); | ||
var _middleware = __webpack_require__(7); | ||
var _middleware2 = _interopRequireDefault(_middleware); | ||
@@ -187,6 +103,10 @@ | ||
var _monitorActions = __webpack_require__(3); | ||
var _effects = __webpack_require__(7); | ||
var monitorActions = _interopRequireWildcard(_monitorActions); | ||
var effects = _interopRequireWildcard(_effects); | ||
var _utils = __webpack_require__(12); | ||
var utils = _interopRequireWildcard(_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; } } | ||
@@ -198,4 +118,8 @@ | ||
var SagaCancellationException = exports.SagaCancellationException = _SagaCancellationException3.default; | ||
var isCancelError = exports.isCancelError = function isCancelError(error) { | ||
return error instanceof SagaCancellationException; | ||
}; | ||
exports.monitorActions = monitorActions; | ||
exports.effects = effects; | ||
exports.utils = utils; | ||
@@ -208,7 +132,8 @@ /***/ }, | ||
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; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: 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; }; | ||
exports.check = check; | ||
@@ -295,3 +220,3 @@ exports.remove = remove; | ||
} | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9))) | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13))) | ||
@@ -333,2 +258,189 @@ /***/ }, | ||
/* 3 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.asEffect = exports.INVALID_PATTERN = exports.CANCEL_ARG_ERROR = exports.JOIN_ARG_ERROR = exports.FORK_ARG_ERROR = exports.CALL_FUNCTION_ARG_ERROR = undefined; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
exports.matcher = matcher; | ||
exports.take = take; | ||
exports.put = put; | ||
exports.race = race; | ||
exports.call = call; | ||
exports.apply = apply; | ||
exports.cps = cps; | ||
exports.fork = fork; | ||
exports.join = join; | ||
exports.cancel = cancel; | ||
var _utils = __webpack_require__(1); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
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)"; | ||
var IO = Symbol('IO'); | ||
var TAKE = 'TAKE'; | ||
var PUT = 'PUT'; | ||
var RACE = 'RACE'; | ||
var CALL = 'CALL'; | ||
var CPS = 'CPS'; | ||
var FORK = 'FORK'; | ||
var JOIN = 'JOIN'; | ||
var CANCEL = 'CANCEL'; | ||
var effect = function effect(type, payload) { | ||
var _ref; | ||
return _ref = {}, _defineProperty(_ref, IO, true), _defineProperty(_ref, type, payload), _ref; | ||
}; | ||
var matchers = { | ||
wildcard: function wildcard() { | ||
return _utils.kTrue; | ||
}, | ||
default: function _default(pattern) { | ||
return function (input) { | ||
return input.type === pattern; | ||
}; | ||
}, | ||
array: function array(patterns) { | ||
return function (input) { | ||
return patterns.some(function (p) { | ||
return p === input.type; | ||
}); | ||
}; | ||
}, | ||
predicate: function predicate(_predicate) { | ||
return function (input) { | ||
return _predicate(input); | ||
}; | ||
} | ||
}; | ||
function matcher(pattern) { | ||
return (pattern === '*' ? matchers.wildcard : _utils.is.array(pattern) ? matchers.array : _utils.is.func(pattern) ? matchers.predicate : matchers.default)(pattern); | ||
} | ||
function take(pattern) { | ||
if (arguments.length > 0 && _utils.is.undef(pattern)) { | ||
throw new Error(INVALID_PATTERN); | ||
} | ||
return effect(TAKE, _utils.is.undef(pattern) ? '*' : pattern); | ||
} | ||
function put(action) { | ||
return effect(PUT, action); | ||
} | ||
function race(effects) { | ||
return effect(RACE, effects); | ||
} | ||
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) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
return effect(CALL, getFnCallDesc(fn, args)); | ||
} | ||
function apply(context, fn) { | ||
var args = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; | ||
return effect(CALL, getFnCallDesc({ 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++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
} | ||
return effect(CPS, getFnCallDesc(fn, args)); | ||
} | ||
function fork(fn) { | ||
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { | ||
args[_key3 - 1] = arguments[_key3]; | ||
} | ||
return effect(FORK, getFnCallDesc(fn, args)); | ||
} | ||
var isForkedTask = function isForkedTask(task) { | ||
return task[_utils.TASK]; | ||
}; | ||
function join(taskDesc) { | ||
if (!isForkedTask(taskDesc)) throw new Error(JOIN_ARG_ERROR); | ||
return effect(JOIN, taskDesc); | ||
} | ||
function cancel(taskDesc) { | ||
if (!isForkedTask(taskDesc)) throw new Error(CANCEL_ARG_ERROR); | ||
return effect(CANCEL, taskDesc); | ||
} | ||
var asEffect = exports.asEffect = { | ||
take: function take(effect) { | ||
return effect && effect[IO] && effect[TAKE]; | ||
}, | ||
put: function put(effect) { | ||
return effect && effect[IO] && effect[PUT]; | ||
}, | ||
race: function race(effect) { | ||
return effect && effect[IO] && effect[RACE]; | ||
}, | ||
call: function call(effect) { | ||
return effect && effect[IO] && effect[CALL]; | ||
}, | ||
cps: function cps(effect) { | ||
return effect && effect[IO] && effect[CPS]; | ||
}, | ||
fork: function fork(effect) { | ||
return effect && effect[IO] && effect[FORK]; | ||
}, | ||
join: function join(effect) { | ||
return effect && effect[IO] && effect[JOIN]; | ||
}, | ||
cancel: function cancel(effect) { | ||
return effect && effect[IO] && effect[CANCEL]; | ||
} | ||
}; | ||
/***/ }, | ||
/* 4 */ | ||
/***/ function(module, exports) { | ||
@@ -371,3 +483,3 @@ | ||
/***/ }, | ||
/* 4 */ | ||
/* 5 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -385,5 +497,5 @@ | ||
var _io = __webpack_require__(6); | ||
var _io = __webpack_require__(3); | ||
var _monitorActions = __webpack_require__(3); | ||
var _monitorActions = __webpack_require__(4); | ||
@@ -423,2 +535,3 @@ var monitorActions = _interopRequireWildcard(_monitorActions); | ||
(0, _utils.check)(iterator, _utils.is.iterator, NOT_ITERATOR_ERROR); | ||
@@ -504,7 +617,10 @@ | ||
} catch (error) { | ||
end(error, true); | ||
/*eslint-disable no-console*/ | ||
if (_utils.isDev) { | ||
console.warn(name + ': uncaught', error); | ||
if (error instanceof _SagaCancellationException2.default) { | ||
if (_utils.isDev) console.warn(name + ': uncaught', error); | ||
} else { | ||
throw error; | ||
} | ||
end(error, true); | ||
} | ||
@@ -595,3 +711,3 @@ } | ||
// declarative effects | ||
: _utils.is.array(effect) ? runParallelEffect(effect, effectId, currCb) : _utils.is.notUndef(data = _io.as.take(effect)) ? runTakeEffect(data, currCb) : _utils.is.notUndef(data = _io.as.put(effect)) ? runPutEffect(data, currCb) : _utils.is.notUndef(data = _io.as.race(effect)) ? runRaceEffect(data, effectId, currCb) : _utils.is.notUndef(data = _io.as.call(effect)) ? runCallEffect(data, effectId, currCb) : _utils.is.notUndef(data = _io.as.cps(effect)) ? runCPSEffect(data, currCb) : _utils.is.notUndef(data = _io.as.fork(effect)) ? runForkEffect(data, effectId, currCb) : _utils.is.notUndef(data = _io.as.join(effect)) ? runJoinEffect(data, currCb) : _utils.is.notUndef(data = _io.as.cancel(effect)) ? runCancelEffect(data, currCb) : /* anything else returned as is */currCb(null, effect) | ||
: _utils.is.array(effect) ? runParallelEffect(effect, effectId, currCb) : _utils.is.notUndef(data = _io.asEffect.take(effect)) ? runTakeEffect(data, currCb) : _utils.is.notUndef(data = _io.asEffect.put(effect)) ? runPutEffect(data, currCb) : _utils.is.notUndef(data = _io.asEffect.race(effect)) ? runRaceEffect(data, effectId, currCb) : _utils.is.notUndef(data = _io.asEffect.call(effect)) ? runCallEffect(data, effectId, currCb) : _utils.is.notUndef(data = _io.asEffect.cps(effect)) ? runCPSEffect(data, currCb) : _utils.is.notUndef(data = _io.asEffect.fork(effect)) ? runForkEffect(data, effectId, currCb) : _utils.is.notUndef(data = _io.asEffect.join(effect)) ? runJoinEffect(data, currCb) : _utils.is.notUndef(data = _io.asEffect.cancel(effect)) ? runCancelEffect(data, currCb) : /* anything else returned as is */currCb(null, effect) | ||
); | ||
@@ -846,3 +962,3 @@ } | ||
/***/ }, | ||
/* 5 */ | ||
/* 6 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -883,189 +999,13 @@ | ||
/***/ }, | ||
/* 6 */ | ||
/* 7 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
'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"); } }; }(); | ||
var _io = __webpack_require__(3); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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; | ||
exports.take = take; | ||
exports.put = put; | ||
exports.race = race; | ||
exports.call = call; | ||
exports.apply = apply; | ||
exports.cps = cps; | ||
exports.fork = fork; | ||
exports.join = join; | ||
exports.cancel = cancel; | ||
module.exports = { take: _io.take, put: _io.put, race: _io.race, call: _io.call, apply: _io.apply, cps: _io.cps, fork: _io.fork, join: _io.join, cancel: _io.cancel }; | ||
var _utils = __webpack_require__(1); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
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)"; | ||
var IO = Symbol('IO'); | ||
var TAKE = 'TAKE'; | ||
var PUT = 'PUT'; | ||
var RACE = 'RACE'; | ||
var CALL = 'CALL'; | ||
var CPS = 'CPS'; | ||
var FORK = 'FORK'; | ||
var JOIN = 'JOIN'; | ||
var CANCEL = 'CANCEL'; | ||
var effect = function effect(type, payload) { | ||
var _ref; | ||
return _ref = {}, _defineProperty(_ref, IO, true), _defineProperty(_ref, type, payload), _ref; | ||
}; | ||
var matchers = { | ||
wildcard: function wildcard() { | ||
return _utils.kTrue; | ||
}, | ||
default: function _default(pattern) { | ||
return function (input) { | ||
return input.type === pattern; | ||
}; | ||
}, | ||
array: function array(patterns) { | ||
return function (input) { | ||
return patterns.some(function (p) { | ||
return p === input.type; | ||
}); | ||
}; | ||
}, | ||
predicate: function predicate(_predicate) { | ||
return function (input) { | ||
return _predicate(input); | ||
}; | ||
} | ||
}; | ||
function matcher(pattern) { | ||
return (pattern === '*' ? matchers.wildcard : _utils.is.array(pattern) ? matchers.array : _utils.is.func(pattern) ? matchers.predicate : matchers.default)(pattern); | ||
} | ||
function take(pattern) { | ||
if (arguments.length > 0 && _utils.is.undef(pattern)) { | ||
throw new Error(INVALID_PATTERN); | ||
} | ||
return effect(TAKE, _utils.is.undef(pattern) ? '*' : pattern); | ||
} | ||
function put(action) { | ||
return effect(PUT, action); | ||
} | ||
function race(effects) { | ||
return effect(RACE, effects); | ||
} | ||
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) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
return effect(CALL, getFnCallDesc(fn, args)); | ||
} | ||
function apply(context, fn) { | ||
var args = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; | ||
return effect(CALL, getFnCallDesc({ 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++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
} | ||
return effect(CPS, getFnCallDesc(fn, args)); | ||
} | ||
function fork(fn) { | ||
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { | ||
args[_key3 - 1] = arguments[_key3]; | ||
} | ||
return effect(FORK, getFnCallDesc(fn, args)); | ||
} | ||
var isForkedTask = function isForkedTask(task) { | ||
return task[_utils.TASK]; | ||
}; | ||
function join(taskDesc) { | ||
if (!isForkedTask(taskDesc)) throw new Error(JOIN_ARG_ERROR); | ||
return effect(JOIN, taskDesc); | ||
} | ||
function cancel(taskDesc) { | ||
if (!isForkedTask(taskDesc)) throw new Error(CANCEL_ARG_ERROR); | ||
return effect(CANCEL, taskDesc); | ||
} | ||
var as = exports.as = { | ||
take: function take(effect) { | ||
return effect && effect[IO] && effect[TAKE]; | ||
}, | ||
put: function put(effect) { | ||
return effect && effect[IO] && effect[PUT]; | ||
}, | ||
race: function race(effect) { | ||
return effect && effect[IO] && effect[RACE]; | ||
}, | ||
call: function call(effect) { | ||
return effect && effect[IO] && effect[CALL]; | ||
}, | ||
cps: function cps(effect) { | ||
return effect && effect[IO] && effect[CPS]; | ||
}, | ||
fork: function fork(effect) { | ||
return effect && effect[IO] && effect[FORK]; | ||
}, | ||
join: function join(effect) { | ||
return effect && effect[IO] && effect[JOIN]; | ||
}, | ||
cancel: function cancel(effect) { | ||
return effect && effect[IO] && effect[CANCEL]; | ||
} | ||
}; | ||
/***/ }, | ||
/* 7 */ | ||
/* 8 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -1083,11 +1023,11 @@ | ||
var _proc = __webpack_require__(4); | ||
var _proc = __webpack_require__(5); | ||
var _proc2 = _interopRequireDefault(_proc); | ||
var _emitter = __webpack_require__(5); | ||
var _emitter = __webpack_require__(6); | ||
var _emitter2 = _interopRequireDefault(_emitter); | ||
var _monitorActions = __webpack_require__(3); | ||
var _monitorActions = __webpack_require__(4); | ||
@@ -1113,2 +1053,3 @@ var _SagaCancellationException = __webpack_require__(2); | ||
var sagaEmitter = (0, _emitter2.default)(); | ||
@@ -1163,3 +1104,3 @@ var monitor = _utils.isDev ? function (action) { | ||
/***/ }, | ||
/* 8 */ | ||
/* 9 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -1178,7 +1119,7 @@ | ||
var _proc = __webpack_require__(4); | ||
var _proc = __webpack_require__(5); | ||
var _proc2 = _interopRequireDefault(_proc); | ||
var _emitter = __webpack_require__(5); | ||
var _emitter = __webpack_require__(6); | ||
@@ -1230,2 +1171,3 @@ var _emitter2 = _interopRequireDefault(_emitter); | ||
(0, _utils.check)(iterator, _utils.is.iterator, NOT_ITERATOR_ERROR); | ||
@@ -1237,3 +1179,189 @@ | ||
/***/ }, | ||
/* 9 */ | ||
/* 10 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
exports.takeEvery = takeEvery; | ||
exports.takeLatest = takeLatest; | ||
var _utils = __webpack_require__(1); | ||
var _io = __webpack_require__(3); | ||
var _SagaCancellationException = __webpack_require__(2); | ||
var _SagaCancellationException2 = _interopRequireDefault(_SagaCancellationException); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var resume = function resume(fnOrValue, arg) { | ||
return _utils.is.func(fnOrValue) ? fnOrValue(arg) : fnOrValue; | ||
}; | ||
var done = { done: true }; | ||
function fsmIterator(fsm, nextState) { | ||
var _iterator; | ||
var aborted = undefined, | ||
updateState = undefined; | ||
function next(arg, error) { | ||
if (aborted) return done; | ||
if (error) { | ||
aborted = true; | ||
if (!(error instanceof _SagaCancellationException2.default)) throw error; | ||
return done; | ||
} else { | ||
if (updateState) updateState(arg); | ||
var _fsm$nextState = _slicedToArray(fsm[nextState], 3); | ||
var output = _fsm$nextState[0]; | ||
var transition = _fsm$nextState[1]; | ||
var _updateState = _fsm$nextState[2]; | ||
updateState = _updateState; | ||
nextState = resume(transition, arg); | ||
return resume(output, arg); | ||
} | ||
} | ||
var iterator = (_iterator = {}, _defineProperty(_iterator, Symbol.iterator, function () { | ||
return iterator; | ||
}), _defineProperty(_iterator, 'next', next), _defineProperty(_iterator, 'throw', function _throw(error) { | ||
return next(null, error); | ||
}), _iterator); | ||
return iterator; | ||
} | ||
function takeEvery(pattern, worker) { | ||
var args = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; | ||
var yieldTake = { done: false, value: (0, _io.take)(pattern) }; | ||
var yieldFork = function yieldFork(action) { | ||
return { done: false, value: _io.fork.apply(undefined, [worker].concat(_toConsumableArray(args), [action])) }; | ||
}; | ||
return fsmIterator({ | ||
'take': [yieldTake, 'fork'], | ||
'fork': [yieldFork, 'take'] | ||
}, 'take'); | ||
} | ||
function takeLatest(pattern, worker) { | ||
var args = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; | ||
var yieldTake = { done: false, value: (0, _io.take)(pattern) }; | ||
var yieldFork = function yieldFork() { | ||
return { done: false, value: _io.fork.apply(undefined, [worker].concat(_toConsumableArray(args), [currentAction])) }; | ||
}; | ||
var yieldCancel = function yieldCancel() { | ||
return { done: false, value: (0, _io.cancel)(currentTask) }; | ||
}; | ||
var forkOrCancel = function forkOrCancel() { | ||
return currentTask ? 'cancel' : 'fork'; | ||
}; | ||
var currentTask = undefined, | ||
currentAction = undefined; | ||
return fsmIterator({ | ||
'take': [yieldTake, forkOrCancel, function (action) { | ||
return currentAction = action; | ||
}], | ||
'cancel': [yieldCancel, 'fork'], | ||
'fork': [yieldFork, 'take', function (task) { | ||
return currentTask = task; | ||
}] | ||
}, 'take'); | ||
} | ||
/***/ }, | ||
/* 11 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createMockTask = createMockTask; | ||
var _utils = __webpack_require__(1); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function createMockTask() { | ||
var _ref; | ||
var running = true; | ||
var result = undefined, | ||
error = undefined; | ||
return _ref = {}, _defineProperty(_ref, _utils.TASK, true), _defineProperty(_ref, 'isRunning', function isRunning() { | ||
return running; | ||
}), _defineProperty(_ref, 'getResult', function getResult() { | ||
return result; | ||
}), _defineProperty(_ref, 'getError', function getError() { | ||
return error; | ||
}), _defineProperty(_ref, 'setRunning', function setRunning(b) { | ||
return running = b; | ||
}), _defineProperty(_ref, 'setResult', function setResult(r) { | ||
return result = r; | ||
}), _defineProperty(_ref, 'setError', function setError(e) { | ||
return error = e; | ||
}), _ref; | ||
} | ||
/***/ }, | ||
/* 12 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var _utils = __webpack_require__(1); | ||
var _io = __webpack_require__(3); | ||
var _proc = __webpack_require__(5); | ||
var _testUtils = __webpack_require__(11); | ||
var _monitorActions = __webpack_require__(4); | ||
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; } } | ||
module.exports = { | ||
TASK: _utils.TASK, | ||
noop: _utils.noop, | ||
is: _utils.is, asEffect: _io.asEffect, | ||
deferred: _utils.deferred, | ||
arrayOfDeffered: _utils.arrayOfDeffered, | ||
asap: _utils.asap, | ||
CANCEL: _proc.CANCEL, | ||
RACE_AUTO_CANCEL: _proc.RACE_AUTO_CANCEL, | ||
PARALLEL_AUTO_CANCEL: _proc.PARALLEL_AUTO_CANCEL, | ||
MANUAL_CANCEL: _proc.MANUAL_CANCEL, | ||
createMockTask: _testUtils.createMockTask, | ||
monitorActions: monitorActions | ||
}; | ||
/***/ }, | ||
/* 13 */ | ||
/***/ function(module, exports) { | ||
@@ -1240,0 +1368,0 @@ |
@@ -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(r){if(t[r])return t[r].exports;var u=t[r]={exports:{},id:r,loaded:!1};return e[r].call(u.exports,u,u.exports,n),u.loaded=!0,u.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,n,t){"use strict";function r(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t]);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.SagaCancellationException=n.MANUAL_CANCEL=n.PARALLEL_AUTO_CANCEL=n.RACE_AUTO_CANCEL=n.CANCEL=void 0;var o=t(4);Object.defineProperty(n,"CANCEL",{enumerable:!0,get:function(){return o.CANCEL}}),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=t(1);Object.defineProperty(n,"is",{enumerable:!0,get:function(){return a.is}});var i=t(6);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=t(8);Object.defineProperty(n,"runSaga",{enumerable:!0,get:function(){return c.runSaga}}),Object.defineProperty(n,"storeIO",{enumerable:!0,get:function(){return c.storeIO}});var f=t(7),s=u(f),l=t(2),d=u(l),p=t(3),g=r(p);n.default=s.default;n.SagaCancellationException=d.default;n.monitorActions=g},function(e,n,t){(function(e){"use strict";function t(e,n,t){if(!n(e))throw new Error(t)}function r(e,n){var t=e.indexOf(n);t>=0&&e.splice(t,1)}function u(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=c({},e),t=new Promise(function(e,t){n.resolve=e,n.reject=t});return n.promise=t,n}function o(e){for(var n=[],t=0;e>t;t++)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 t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e};Object.defineProperty(n,"__esModule",{value:!0}),n.check=t,n.remove=r,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.isDev="undefined"!=typeof e&&e.env&&!1,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]}})}).call(n,t(9))},function(e,n){"use strict";function t(e,n,t){var r="SagaCancellationException; type: "+e+", saga: "+n+", origin: "+t;this.name="SagaCancellationException",this.message=r,this.type=e,this.saga=n,this.origin=t,this.stack=(new Error).stack}Object.defineProperty(n,"__esModule",{value:!0}),n.default=t,t.prototype=Object.create(Error.prototype),t.prototype.constructor=t},function(e,n){"use strict";function t(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function r(e,n,r,u){var o;return o={},t(o,a,!0),t(o,"type",i),t(o,"effectId",e),t(o,"parentEffectId",n),t(o,"label",r),t(o,"effect",u),o}function u(e,n){var r;return r={},t(r,a,!0),t(r,"type",c),t(r,"effectId",e),t(r,"result",n),r}function o(e,n){var r;return r={},t(r,a,!0),t(r,"type",f),t(r,"effectId",e),t(r,"error",n),r}Object.defineProperty(n,"__esModule",{value:!0}),n.effectTriggered=r,n.effectResolved=u,n.effectRejected=o;var a=n.MONITOR_ACTION="MONITOR_ACTION",i=n.EFFECT_TRIGGERED="EFFECT_TRIGGERED",c=n.EFFECT_RESOLVED="EFFECT_RESOLVED",f=n.EFFECT_REJECTED="EFFECT_REJECTED"},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function u(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t]);return n.default=e,n}function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e){function n(u,o){if(!e._isRunning)throw new Error("Trying to resume an already finished generator");try{if(u&&!x)throw u;var a=u?e.throw(u):e.next(o);a.done?t(a.value):r(a.value,I,"",n)}catch(u){i.isDev&&console.warn(k+": uncaught",u),t(u,!0)}}function t(n,t){e._isRunning=!1,t?(e._error=n,M.reject(n)):(e._result=n,M.resolve(n)),F()}function r(e,n){function t(e,n){d||(d=!0,o.cancel=i.noop,P(e?s.effectRejected(a,e):s.effectResolved(a,n)),o(e,n))}var r=arguments.length<=2||void 0===arguments[2]?"":arguments[2],o=arguments[3],a=y();P(s.effectTriggered(a,n,r,e));var d=void 0;t.cancel=i.noop,o.cancel=function(e){if(!d){d=!0;try{t.cancel(e)}catch(n){}t.cancel=i.noop,o(e),P(s.effectRejected(a,e))}};var p=void 0;return i.is.promise(e)?u(e,t):i.is.iterator(e)?f(e,a,k,t):i.is.array(e)?L(e,a,t):i.is.notUndef(p=c.as.take(e))?l(p,t):i.is.notUndef(p=c.as.put(e))?E(p,t):i.is.notUndef(p=c.as.race(e))?T(p,a,t):i.is.notUndef(p=c.as.call(e))?_(p,a,t):i.is.notUndef(p=c.as.cps(e))?R(p,t):i.is.notUndef(p=c.as.fork(e))?O(p,a,t):i.is.notUndef(p=c.as.join(e))?b(p,t):i.is.notUndef(p=c.as.cancel(e))?C(p,t):t(null,e)}function u(e,n){var t=e[v];"function"==typeof t&&(n.cancel=t),e.then(function(e){return n(null,e)},function(e){return n(e)})}function f(e,n,t,r){u(a(e,N,j,P,n,t).done,r)}function l(e,n){var t={match:(0,c.matcher)(e),pattern:e,resolve:function(e){return n(null,e)}};U.push(t),n.cancel=function(){return(0,i.remove)(U,t)}}function E(e,n){(0,i.asap)(function(){return n(null,j(e))})}function _(e,n,t){var r=e.context,o=e.fn,a=e.args,c=o.apply(r,a);return i.is.promise(c)?u(c,t):i.is.iterator(c)?f(c,n,o.name,t):t(null,c)}function R(e,n){var t=e.context,r=e.fn,u=e.args;r.apply(t,u.concat(n))}function O(e,n,t){var r=e.context,u=e.fn,o=e.args,c=void 0,f=void 0;c=u.apply(r,o),f=i.is.iterator(c)?c:regeneratorRuntime.mark(function s(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c;case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},s,this)})(),t(null,a(f,N,j,P,n,u.name,!0))}function b(e,n){u(e.done,n)}function C(e,n){e.done[v](new d.default(h,k,k)),n()}function L(e,n,t){function u(){o===c.length&&(a=!0,t(null,c))}if(!e.length)return void t(null,[]);var o=0,a=void 0,c=Array(e.length),f=e.map(function(e,n){var r=function(e,r){if(!a)if(e){try{t.cancel(new d.default(m,k,k))}catch(e){}t(e)}else c[n]=r,o++,u()};return r.cancel=i.noop,r});t.cancel=function(e){a||(a=!0,f.forEach(function(n){return n.cancel(e)}))},e.forEach(function(e,t){return r(e,n,t,f[t])})}function T(e,n,t){var u=void 0,a=Object.keys(e),c={};a.forEach(function(e){var n=function(n,r){if(!u)if(n){try{t.cancel(new d.default(A,k,k))}catch(n){}t(o({},e,n))}else{try{t.cancel(new d.default(A,k,k))}catch(n){}u=!0,t(null,o({},e,r))}};n.cancel=i.noop,c[e]=n}),t.cancel=function(e){u||(u=!0,a.forEach(function(n){return c[n].cancel(e)}))},a.forEach(function(t){return r(e[t],n,t,c[t])})}function w(e,n,t,r,u){var a;return a={},o(a,i.TASK,!0),o(a,"id",e),o(a,"name",n),o(a,"done",r),o(a,"forked",u),o(a,"cancel",function(e){e instanceof d.default||(e=new d.default(h,n,e)),r[v](e)}),o(a,"isRunning",function(){return t._isRunning}),o(a,"getResult",function(){return t._result}),o(a,"getError",function(){return t._error}),a}var N=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],I=arguments.length<=4||void 0===arguments[4]?0:arguments[4],k=arguments.length<=5||void 0===arguments[5]?"anonymous":arguments[5];(0,i.check)(e,i.is.iterator,p);var S=g(k),U=[],x=i.is.throw(e),M=(0,i.deferred)(),F=N(function(e){if(void 0===e)throw S;for(var n=0;n<U.length;n++){var t=U[n];t.match(e)&&(U=[],t.resolve(e))}});n.cancel=i.noop;var D=w(I,k,e,M.promise);return D.done[v]=function(e){var t=e.type,r=e.origin;n.cancel(new d.default(t,k,r))},e._isRunning=!0,n(),D}Object.defineProperty(n,"__esModule",{value:!0}),n.MANUAL_CANCEL=n.RACE_AUTO_CANCEL=n.PARALLEL_AUTO_CANCEL=n.CANCEL=n.undefindInputError=n.NOT_ITERATOR_ERROR=void 0,n.default=a;var i=t(1),c=t(6),f=t(3),s=u(f),l=t(2),d=r(l),p=n.NOT_ITERATOR_ERROR="proc first argument (Saga function result) must be an iterator",g=n.undefindInputError=function(e){return"\n "+e+" saga was provided with an undefined input action\n Hints :\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"},v=n.CANCEL=Symbol("@@redux-saga/cancelPromise"),m=n.PARALLEL_AUTO_CANCEL="PARALLEL_AUTO_CANCEL",A=n.RACE_AUTO_CANCEL="RACE_AUTO_CANCEL",h=n.MANUAL_CANCEL="MANUAL_CANCEL",y=(0,i.autoInc)()},function(e,n,t){"use strict";function r(){function e(e){return t.push(e),function(){return(0,u.remove)(t,e)}}function n(e){t.slice().forEach(function(n){return n(e)})}var t=[];return{subscribe:e,emit:n}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=r;var u=t(1)},function(e,n,t){"use strict";function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function u(e){return("*"===e?P.wildcard:m.is.array(e)?P.array:m.is.func(e)?P.predicate:P.default)(e)}function o(e){if(arguments.length>0&&m.is.undef(e))throw new Error(E);return j(R,m.is.undef(e)?"*":e)}function a(e){return j(O,e)}function i(e){return j(b,e)}function c(e,n){(0,m.check)(e,m.is.notUndef,A);var t=null;if(m.is.array(e)){var r=e,u=v(r,2);t=u[0],e=u[1]}else if(e.fn){var o=e;t=o.context,e=o.fn}return(0,m.check)(e,m.is.func,A),{context:t,fn:e,args:n}}function f(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];return j(C,c(e,t))}function s(e,n){var t=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];return j(C,c({context:e,fn:n},t))}function l(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];return j(L,c(e,t))}function d(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];return j(T,c(e,t))}function p(e){if(!I(e))throw new Error(h);return j(w,e)}function g(e){if(!I(e))throw new Error(y);return j(N,e)}var v=function(){function e(e,n){var t=[],r=!0,u=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(r=(a=i.next()).done)&&(t.push(a.value),!n||t.length!==n);r=!0);}catch(c){u=!0,o=c}finally{try{!r&&i.return&&i.return()}finally{if(u)throw o}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);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=g;var m=t(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}",h=(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)"),y=n.CANCEL_ARG_ERROR="cancel argument must be a valid task (a result of a fork)",E=n.INVALID_PATTERN="Invalid pattern passed to `take` (HINT: check if you didn't mispell a constant)",_=Symbol("IO"),R="TAKE",O="PUT",b="RACE",C="CALL",L="CPS",T="FORK",w="JOIN",N="CANCEL",j=function(e,n){var t;return t={},r(t,_,!0),r(t,e,n),t},P={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)}}},I=function(e){return e[m.TASK]};n.as={take:function(e){return e&&e[_]&&e[R]},put:function(e){return e&&e[_]&&e[O]},race:function(e){return e&&e[_]&&e[b]},call:function(e){return e&&e[_]&&e[C]},cps:function(e){return e&&e[_]&&e[L]},fork:function(e){return e&&e[_]&&e[T]},join:function(e){return e&&e[_]&&e[w]},cancel:function(e){return e&&e[_]&&e[N]}}},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function u(){function e(e){function n(e){for(var n=arguments.length,t=Array(n>1?n-1:0),u=1;n>u;u++)t[u-1]=arguments[u];return(0,i.default)(e.apply(void 0,[r].concat(t)),c.subscribe,a,l,0,e.name)}var r=e.getState,a=e.dispatch,c=(0,f.default)(),l=o.isDev?function(e){return(0,o.asap)(function(){return a(e)})}:void 0;return u=n,t.forEach(n),function(e){return function(n){var t=e(n);return n[s.MONITOR_ACTION]||c.emit(n),t}}}for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];var u=void 0;return e.run=function(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];if(!u)throw new Error(p);var o=u.apply(void 0,[e].concat(t));return o.done.catch(function(e){if(!(e instanceof d.default))throw e}),o},e}Object.defineProperty(n,"__esModule",{value:!0}),n.RUN_SAGA_DYNAMIC_ERROR=void 0,n.default=u;var o=t(1),a=t(4),i=r(a),c=t(5),f=r(c),s=t(3),l=t(2),d=r(l),p=n.RUN_SAGA_DYNAMIC_ERROR="Before running a Saga dynamically using middleware.run, you must mount the Saga middleware on the Store using applyMiddleware"},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function u(e){if(a.isDev&&console.warn("storeIO is deprecated, to run Saga dynamically, use 'run' method of the middleware"),e[d])return e[d];var n=(0,s.default)(),t=e.dispatch;return e.dispatch=function(e){var r=t(e);return n.emit(e),r},e[d]={subscribe:n.subscribe,dispatch:e.dispatch},e[d]}function o(e,n){var t=n.subscribe,r=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,t,r,u)}Object.defineProperty(n,"__esModule",{value:!0}),n.NOT_ITERATOR_ERROR=void 0,n.storeIO=u,n.runSaga=o;var a=t(1),i=t(4),c=r(i),f=t(5),s=r(f),l=n.NOT_ITERATOR_ERROR="runSaga must be called on an iterator",d=Symbol("IO")},function(e,n){function t(){f=!1,a.length?c=a.concat(c):s=-1,c.length&&r()}function r(){if(!f){var e=setTimeout(t);f=!0;for(var n=c.length;n;){for(a=c,c=[];++s<n;)a&&a[s].run();s=-1,n=c.length}a=null,f=!1,clearTimeout(e)}}function u(e,n){this.fun=e,this.array=n}function o(){}var a,i=e.exports={},c=[],f=!1,s=-1;i.nextTick=function(e){var n=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)n[t-1]=arguments[t];c.push(new u(e,n)),1!==c.length||f||setTimeout(r,0)},u.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=o,i.addListener=o,i.once=o,i.off=o,i.removeListener=o,i.removeAllListeners=o,i.emit=o,i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}}])}); | ||
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ReduxSaga=e():n.ReduxSaga=e()}(this,function(){return function(n){function e(r){if(t[r])return t[r].exports;var u=t[r]={exports:{},id:r,loaded:!1};return n[r].call(u.exports,u,u.exports,e),u.loaded=!0,u.exports}var t={};return e.m=n,e.c=t,e.p="",e(0)}([function(n,e,t){"use strict";function r(n){if(n&&n.__esModule)return n;var e={};if(null!=n)for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e.default=n,e}function u(n){return n&&n.__esModule?n:{"default":n}}Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.effects=e.takeLatest=e.takeEvery=e.storeIO=e.runSaga=e.isCancelError=e.SagaCancellationException=void 0;var o=t(9);Object.defineProperty(e,"runSaga",{enumerable:!0,get:function(){return o.runSaga}}),Object.defineProperty(e,"storeIO",{enumerable:!0,get:function(){return o.storeIO}});var a=t(10);Object.defineProperty(e,"takeEvery",{enumerable:!0,get:function(){return a.takeEvery}}),Object.defineProperty(e,"takeLatest",{enumerable:!0,get:function(){return a.takeLatest}});var i=t(8),c=u(i),f=t(2),s=u(f),l=t(7),d=r(l),v=t(12),p=r(v);e.default=c.default;var g=e.SagaCancellationException=s.default;e.isCancelError=function(n){return n instanceof g};e.effects=d,e.utils=p},function(n,e,t){(function(n){"use strict";function t(n,e,t){if(!e(n))throw new Error(t)}function r(n,e){var t=n.indexOf(e);t>=0&&n.splice(t,1)}function u(){var n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=c({},n),t=new Promise(function(n,t){e.resolve=n,e.reject=t});return e.promise=t,e}function o(n){for(var e=[],t=0;n>t;t++)e.push(u());return e}function a(){var n=arguments.length<=0||void 0===arguments[0]?0:arguments[0];return function(){return++n}}function i(n){return Promise.resolve(1).then(function(){return n()})}Object.defineProperty(e,"__esModule",{value:!0});var c=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n};e.check=t,e.remove=r,e.deferred=u,e.arrayOfDeffered=o,e.autoInc=a,e.asap=i;var f=e.TASK=Symbol("TASK"),s=(e.kTrue=function(){return!0},e.noop=function(){},e.isDev="undefined"!=typeof n&&n.env&&!1,e.is={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},array:Array.isArray,promise:function(n){return n&&s.func(n.then)},iterator:function(n){return n&&s.func(n.next)&&s.func(n[Symbol.iterator])},"throw":function(n){return n&&s.func(n.throw)},task:function(n){return n&&n[f]}})}).call(e,t(13))},function(n,e){"use strict";function t(n,e,t){var r="SagaCancellationException; type: "+n+", saga: "+e+", origin: "+t;this.name="SagaCancellationException",this.message=r,this.type=n,this.saga=e,this.origin=t,this.stack=(new Error).stack}Object.defineProperty(e,"__esModule",{value:!0}),e.default=t,t.prototype=Object.create(Error.prototype),t.prototype.constructor=t},function(n,e,t){"use strict";function r(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function u(n){return("*"===n?j.wildcard:m.is.array(n)?j.array:m.is.func(n)?j.predicate:j.default)(n)}function o(n){if(arguments.length>0&&m.is.undef(n))throw new Error(A);return N(R,m.is.undef(n)?"*":n)}function a(n){return N(O,n)}function i(n){return N(b,n)}function c(n,e){(0,m.check)(n,m.is.notUndef,h);var t=null;if(m.is.array(n)){var r=n,u=g(r,2);t=u[0],n=u[1]}else if(n.fn){var o=n;t=o.context,n=o.fn}return(0,m.check)(n,m.is.func,h),{context:t,fn:n,args:e}}function f(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;e>r;r++)t[r-1]=arguments[r];return N(C,c(n,t))}function s(n,e){var t=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];return N(C,c({context:n,fn:e},t))}function l(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;e>r;r++)t[r-1]=arguments[r];return N(T,c(n,t))}function d(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;e>r;r++)t[r-1]=arguments[r];return N(w,c(n,t))}function v(n){if(!I(n))throw new Error(y);return N(k,n)}function p(n){if(!I(n))throw new Error(E);return N(L,n)}Object.defineProperty(e,"__esModule",{value:!0}),e.asEffect=e.INVALID_PATTERN=e.CANCEL_ARG_ERROR=e.JOIN_ARG_ERROR=e.FORK_ARG_ERROR=e.CALL_FUNCTION_ARG_ERROR=void 0;var g=function(){function n(n,e){var t=[],r=!0,u=!1,o=void 0;try{for(var a,i=n[Symbol.iterator]();!(r=(a=i.next()).done)&&(t.push(a.value),!e||t.length!==e);r=!0);}catch(c){u=!0,o=c}finally{try{!r&&i.return&&i.return()}finally{if(u)throw o}}return t}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return n(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();e.matcher=u,e.take=o,e.put=a,e.race=i,e.call=f,e.apply=s,e.cps=l,e.fork=d,e.join=v,e.cancel=p;var m=t(1),h=e.CALL_FUNCTION_ARG_ERROR="call/cps/fork first argument must be a function, an array [context, function] or an object {context, fn}",y=(e.FORK_ARG_ERROR="fork first argument must be a generator function or an iterator",e.JOIN_ARG_ERROR="join argument must be a valid task (a result of a fork)"),E=e.CANCEL_ARG_ERROR="cancel argument must be a valid task (a result of a fork)",A=e.INVALID_PATTERN="Invalid pattern passed to `take` (HINT: check if you didn't mispell a constant)",_=Symbol("IO"),R="TAKE",O="PUT",b="RACE",C="CALL",T="CPS",w="FORK",k="JOIN",L="CANCEL",N=function(n,e){var t;return t={},r(t,_,!0),r(t,n,e),t},j={wildcard:function(){return m.kTrue},"default":function(n){return function(e){return e.type===n}},array:function(n){return function(e){return n.some(function(n){return n===e.type})}},predicate:function(n){return function(e){return n(e)}}},I=function(n){return n[m.TASK]};e.asEffect={take:function(n){return n&&n[_]&&n[R]},put:function(n){return n&&n[_]&&n[O]},race:function(n){return n&&n[_]&&n[b]},call:function(n){return n&&n[_]&&n[C]},cps:function(n){return n&&n[_]&&n[T]},fork:function(n){return n&&n[_]&&n[w]},join:function(n){return n&&n[_]&&n[k]},cancel:function(n){return n&&n[_]&&n[L]}}},function(n,e){"use strict";function t(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function r(n,e,r,u){var o;return o={},t(o,a,!0),t(o,"type",i),t(o,"effectId",n),t(o,"parentEffectId",e),t(o,"label",r),t(o,"effect",u),o}function u(n,e){var r;return r={},t(r,a,!0),t(r,"type",c),t(r,"effectId",n),t(r,"result",e),r}function o(n,e){var r;return r={},t(r,a,!0),t(r,"type",f),t(r,"effectId",n),t(r,"error",e),r}Object.defineProperty(e,"__esModule",{value:!0}),e.effectTriggered=r,e.effectResolved=u,e.effectRejected=o;var a=e.MONITOR_ACTION="MONITOR_ACTION",i=e.EFFECT_TRIGGERED="EFFECT_TRIGGERED",c=e.EFFECT_RESOLVED="EFFECT_RESOLVED",f=e.EFFECT_REJECTED="EFFECT_REJECTED"},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function u(n){if(n&&n.__esModule)return n;var e={};if(null!=n)for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e.default=n,e}function o(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function a(n){function e(u,o){if(!n._isRunning)throw new Error("Trying to resume an already finished generator");try{if(u&&!M)throw u;var a=u?n.throw(u):n.next(o);a.done?t(a.value):r(a.value,I,"",e)}catch(u){if(t(u,!0),!(u instanceof d.default))throw u;i.isDev&&console.warn(S+": uncaught",u)}}function t(e,t){n._isRunning=!1,t?(n._error=e,U.reject(e)):(n._result=e,U.resolve(e)),D()}function r(n,e){function t(n,e){d||(d=!0,o.cancel=i.noop,j(n?s.effectRejected(a,n):s.effectResolved(a,e)),o(n,e))}var r=arguments.length<=2||void 0===arguments[2]?"":arguments[2],o=arguments[3],a=E();j(s.effectTriggered(a,e,r,n));var d=void 0;t.cancel=i.noop,o.cancel=function(n){if(!d){d=!0;try{t.cancel(n)}catch(e){}t.cancel=i.noop,o(n),j(s.effectRejected(a,n))}};var v=void 0;return i.is.promise(n)?u(n,t):i.is.iterator(n)?f(n,a,S,t):i.is.array(n)?T(n,a,t):i.is.notUndef(v=c.asEffect.take(n))?l(v,t):i.is.notUndef(v=c.asEffect.put(n))?A(v,t):i.is.notUndef(v=c.asEffect.race(n))?w(v,a,t):i.is.notUndef(v=c.asEffect.call(n))?_(v,a,t):i.is.notUndef(v=c.asEffect.cps(n))?R(v,t):i.is.notUndef(v=c.asEffect.fork(n))?O(v,a,t):i.is.notUndef(v=c.asEffect.join(n))?b(v,t):i.is.notUndef(v=c.asEffect.cancel(n))?C(v,t):t(null,n)}function u(n,e){var t=n[g];"function"==typeof t&&(e.cancel=t),n.then(function(n){return e(null,n)},function(n){return e(n)})}function f(n,e,t,r){u(a(n,L,N,j,e,t).done,r)}function l(n,e){var t={match:(0,c.matcher)(n),pattern:n,resolve:function(n){return e(null,n)}};P.push(t),e.cancel=function(){return(0,i.remove)(P,t)}}function A(n,e){(0,i.asap)(function(){return e(null,N(n))})}function _(n,e,t){var r=n.context,o=n.fn,a=n.args,c=o.apply(r,a);return i.is.promise(c)?u(c,t):i.is.iterator(c)?f(c,e,o.name,t):t(null,c)}function R(n,e){var t=n.context,r=n.fn,u=n.args;r.apply(t,u.concat(e))}function O(n,e,t){var r=n.context,u=n.fn,o=n.args,c=void 0,f=void 0;c=u.apply(r,o),f=i.is.iterator(c)?c:regeneratorRuntime.mark(function s(){return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,c;case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},s,this)})(),t(null,a(f,L,N,j,e,u.name,!0))}function b(n,e){u(n.done,e)}function C(n,e){n.done[g](new d.default(y,S,S)),e()}function T(n,e,t){function u(){o===c.length&&(a=!0,t(null,c))}if(!n.length)return void t(null,[]);var o=0,a=void 0,c=Array(n.length),f=n.map(function(n,e){var r=function(n,r){if(!a)if(n){try{t.cancel(new d.default(m,S,S))}catch(n){}t(n)}else c[e]=r,o++,u()};return r.cancel=i.noop,r});t.cancel=function(n){a||(a=!0,f.forEach(function(e){return e.cancel(n)}))},n.forEach(function(n,t){return r(n,e,t,f[t])})}function w(n,e,t){var u=void 0,a=Object.keys(n),c={};a.forEach(function(n){var e=function(e,r){if(!u)if(e){try{t.cancel(new d.default(h,S,S))}catch(e){}t(o({},n,e))}else{try{t.cancel(new d.default(h,S,S))}catch(e){}u=!0,t(null,o({},n,r))}};e.cancel=i.noop,c[n]=e}),t.cancel=function(n){u||(u=!0,a.forEach(function(e){return c[e].cancel(n)}))},a.forEach(function(t){return r(n[t],e,t,c[t])})}function k(n,e,t,r,u){var a;return a={},o(a,i.TASK,!0),o(a,"id",n),o(a,"name",e),o(a,"done",r),o(a,"forked",u),o(a,"cancel",function(n){n instanceof d.default||(n=new d.default(y,e,n)),r[g](n)}),o(a,"isRunning",function(){return t._isRunning}),o(a,"getResult",function(){return t._result}),o(a,"getError",function(){return t._error}),a}var L=arguments.length<=1||void 0===arguments[1]?function(){return i.noop}:arguments[1],N=arguments.length<=2||void 0===arguments[2]?i.noop:arguments[2],j=arguments.length<=3||void 0===arguments[3]?i.noop:arguments[3],I=arguments.length<=4||void 0===arguments[4]?0:arguments[4],S=arguments.length<=5||void 0===arguments[5]?"anonymous":arguments[5];(0,i.check)(n,i.is.iterator,v);var x=p(S),P=[],M=i.is.throw(n),U=(0,i.deferred)(),D=L(function(n){if(void 0===n)throw x;for(var e=0;e<P.length;e++){var t=P[e];t.match(n)&&(P=[],t.resolve(n))}});e.cancel=i.noop;var F=k(I,S,n,U.promise);return F.done[g]=function(n){var t=n.type,r=n.origin;e.cancel(new d.default(t,S,r))},n._isRunning=!0,e(),F}Object.defineProperty(e,"__esModule",{value:!0}),e.MANUAL_CANCEL=e.RACE_AUTO_CANCEL=e.PARALLEL_AUTO_CANCEL=e.CANCEL=e.undefindInputError=e.NOT_ITERATOR_ERROR=void 0,e.default=a;var i=t(1),c=t(3),f=t(4),s=u(f),l=t(2),d=r(l),v=e.NOT_ITERATOR_ERROR="proc first argument (Saga function result) must be an iterator",p=e.undefindInputError=function(n){return"\n "+n+" saga was provided with an undefined input action\n Hints :\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"},g=e.CANCEL=Symbol("@@redux-saga/cancelPromise"),m=e.PARALLEL_AUTO_CANCEL="PARALLEL_AUTO_CANCEL",h=e.RACE_AUTO_CANCEL="RACE_AUTO_CANCEL",y=e.MANUAL_CANCEL="MANUAL_CANCEL",E=(0,i.autoInc)()},function(n,e,t){"use strict";function r(){function n(n){return t.push(n),function(){return(0,u.remove)(t,n)}}function e(n){t.slice().forEach(function(e){return e(n)})}var t=[];return{subscribe:n,emit:e}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var u=t(1)},function(n,e,t){"use strict";var r=t(3);n.exports={take:r.take,put:r.put,race:r.race,call:r.call,apply:r.apply,cps:r.cps,fork:r.fork,join:r.join,cancel:r.cancel}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function u(){function n(n){function e(n){for(var e=arguments.length,t=Array(e>1?e-1:0),u=1;e>u;u++)t[u-1]=arguments[u];return(0,i.default)(n.apply(void 0,[r].concat(t)),c.subscribe,a,l,0,n.name)}var r=n.getState,a=n.dispatch,c=(0,f.default)(),l=o.isDev?function(n){return(0,o.asap)(function(){return a(n)})}:void 0;return u=e,t.forEach(e),function(n){return function(e){var t=n(e);return e[s.MONITOR_ACTION]||c.emit(e),t}}}for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];var u=void 0;return n.run=function(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;e>r;r++)t[r-1]=arguments[r];if(!u)throw new Error(v);var o=u.apply(void 0,[n].concat(t));return o.done.catch(function(n){if(!(n instanceof d.default))throw n}),o},n}Object.defineProperty(e,"__esModule",{value:!0}),e.RUN_SAGA_DYNAMIC_ERROR=void 0,e.default=u;var o=t(1),a=t(5),i=r(a),c=t(6),f=r(c),s=t(4),l=t(2),d=r(l),v=e.RUN_SAGA_DYNAMIC_ERROR="Before running a Saga dynamically using middleware.run, you must mount the Saga middleware on the Store using applyMiddleware"},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function u(n){if(a.isDev&&console.warn("storeIO is deprecated, to run Saga dynamically, use 'run' method of the middleware"),n[d])return n[d];var e=(0,s.default)(),t=n.dispatch;return n.dispatch=function(n){var r=t(n);return e.emit(n),r},n[d]={subscribe:e.subscribe,dispatch:n.dispatch},n[d]}function o(n,e){var t=e.subscribe,r=e.dispatch,u=arguments.length<=2||void 0===arguments[2]?a.noop:arguments[2];return(0,a.check)(n,a.is.iterator,l),(0,c.default)(n,t,r,u)}Object.defineProperty(e,"__esModule",{value:!0}),e.NOT_ITERATOR_ERROR=void 0,e.storeIO=u,e.runSaga=o;var a=t(1),i=t(5),c=r(i),f=t(6),s=r(f),l=e.NOT_ITERATOR_ERROR="runSaga must be called on an iterator",d=Symbol("IO")},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function u(n){if(Array.isArray(n)){for(var e=0,t=Array(n.length);e<n.length;e++)t[e]=n[e];return t}return Array.from(n)}function o(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function a(n,e){function t(t,r){if(u)return g;if(r){if(u=!0,!(r instanceof v.default))throw r;return g}a&&a(t);var o=f(n[e],3),i=o[0],c=o[1],s=o[2];return a=s,e=p(c,t),p(i,t)}var r,u=void 0,a=void 0,i=(r={},o(r,Symbol.iterator,function(){return i}),o(r,"next",t),o(r,"throw",function(n){return t(null,n)}),r);return i}function i(n,e){var t=arguments.length<=2||void 0===arguments[2]?[]:arguments[2],r={done:!1,value:(0,l.take)(n)},o=function(n){return{done:!1,value:l.fork.apply(void 0,[e].concat(u(t),[n]))}};return a({take:[r,"fork"],fork:[o,"take"]},"take")}function c(n,e){var t=arguments.length<=2||void 0===arguments[2]?[]:arguments[2],r={done:!1,value:(0,l.take)(n)},o=function(){return{done:!1,value:l.fork.apply(void 0,[e].concat(u(t),[s]))}},i=function(){return{done:!1,value:(0,l.cancel)(f)}},c=function(){return f?"cancel":"fork"},f=void 0,s=void 0;return a({take:[r,c,function(n){return s=n}],cancel:[i,"fork"],fork:[o,"take",function(n){return f=n}]},"take")}Object.defineProperty(e,"__esModule",{value:!0});var f=function(){function n(n,e){var t=[],r=!0,u=!1,o=void 0;try{for(var a,i=n[Symbol.iterator]();!(r=(a=i.next()).done)&&(t.push(a.value),!e||t.length!==e);r=!0);}catch(c){u=!0,o=c}finally{try{!r&&i.return&&i.return()}finally{if(u)throw o}}return t}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return n(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();e.takeEvery=i,e.takeLatest=c;var s=t(1),l=t(3),d=t(2),v=r(d),p=function(n,e){return s.is.func(n)?n(e):n},g={done:!0}},function(n,e,t){"use strict";function r(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function u(){var n,e=!0,t=void 0,u=void 0;return n={},r(n,o.TASK,!0),r(n,"isRunning",function(){return e}),r(n,"getResult",function(){return t}),r(n,"getError",function(){return u}),r(n,"setRunning",function(n){return e=n}),r(n,"setResult",function(n){return t=n}),r(n,"setError",function(n){return u=n}),n}Object.defineProperty(e,"__esModule",{value:!0}),e.createMockTask=u;var o=t(1)},function(n,e,t){"use strict";function r(n){if(n&&n.__esModule)return n;var e={};if(null!=n)for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e.default=n,e}var u=t(1),o=t(3),a=t(5),i=t(11),c=t(4),f=r(c);n.exports={TASK:u.TASK,noop:u.noop,is:u.is,asEffect:o.asEffect,deferred:u.deferred,arrayOfDeffered:u.arrayOfDeffered,asap:u.asap,CANCEL:a.CANCEL,RACE_AUTO_CANCEL:a.RACE_AUTO_CANCEL,PARALLEL_AUTO_CANCEL:a.PARALLEL_AUTO_CANCEL,MANUAL_CANCEL:a.MANUAL_CANCEL,createMockTask:i.createMockTask,monitorActions:f}},function(n,e){function t(){f=!1,a.length?c=a.concat(c):s=-1,c.length&&r()}function r(){if(!f){var n=setTimeout(t);f=!0;for(var e=c.length;e;){for(a=c,c=[];++s<e;)a&&a[s].run();s=-1,e=c.length}a=null,f=!1,clearTimeout(n)}}function u(n,e){this.fun=n,this.array=e}function o(){}var a,i=n.exports={},c=[],f=!1,s=-1;i.nextTick=function(n){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];c.push(new u(n,e)),1!==c.length||f||setTimeout(r,0)},u.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=o,i.addListener=o,i.once=o,i.off=o,i.removeListener=o,i.removeAllListeners=o,i.emit=o,i.binding=function(n){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(n){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}}])}); |
124
lib/index.js
@@ -6,130 +6,50 @@ 'use strict'; | ||
}); | ||
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.SagaCancellationException = exports.MANUAL_CANCEL = exports.PARALLEL_AUTO_CANCEL = exports.RACE_AUTO_CANCEL = exports.CANCEL = undefined; | ||
exports.utils = exports.effects = exports.takeLatest = exports.takeEvery = exports.storeIO = exports.runSaga = exports.isCancelError = exports.SagaCancellationException = undefined; | ||
var _proc = require('./proc'); | ||
var _runSaga = require('./internal/runSaga'); | ||
Object.defineProperty(exports, 'CANCEL', { | ||
Object.defineProperty(exports, 'runSaga', { | ||
enumerable: true, | ||
get: function get() { | ||
return _proc.CANCEL; | ||
return _runSaga.runSaga; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'RACE_AUTO_CANCEL', { | ||
Object.defineProperty(exports, 'storeIO', { | ||
enumerable: true, | ||
get: function get() { | ||
return _proc.RACE_AUTO_CANCEL; | ||
return _runSaga.storeIO; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'PARALLEL_AUTO_CANCEL', { | ||
enumerable: true, | ||
get: function get() { | ||
return _proc.PARALLEL_AUTO_CANCEL; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'MANUAL_CANCEL', { | ||
enumerable: true, | ||
get: function get() { | ||
return _proc.MANUAL_CANCEL; | ||
} | ||
}); | ||
var _utils = require('./utils'); | ||
var _sagaHelpers = require('./internal/sagaHelpers'); | ||
Object.defineProperty(exports, 'is', { | ||
Object.defineProperty(exports, 'takeEvery', { | ||
enumerable: true, | ||
get: function get() { | ||
return _utils.is; | ||
return _sagaHelpers.takeEvery; | ||
} | ||
}); | ||
var _io = require('./io'); | ||
Object.defineProperty(exports, 'take', { | ||
Object.defineProperty(exports, 'takeLatest', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.take; | ||
return _sagaHelpers.takeLatest; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'put', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.put; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'race', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.race; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'call', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.call; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'apply', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.apply; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'cps', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.cps; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'fork', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.fork; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'join', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.join; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'cancel', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.cancel; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'as', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.as; | ||
} | ||
}); | ||
var _runSaga = require('./runSaga'); | ||
var _middleware = require('./internal/middleware'); | ||
Object.defineProperty(exports, 'runSaga', { | ||
enumerable: true, | ||
get: function get() { | ||
return _runSaga.runSaga; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'storeIO', { | ||
enumerable: true, | ||
get: function get() { | ||
return _runSaga.storeIO; | ||
} | ||
}); | ||
var _middleware = require('./middleware'); | ||
var _middleware2 = _interopRequireDefault(_middleware); | ||
var _SagaCancellationException2 = require('./SagaCancellationException'); | ||
var _SagaCancellationException2 = require('./internal/SagaCancellationException'); | ||
var _SagaCancellationException3 = _interopRequireDefault(_SagaCancellationException2); | ||
var _monitorActions = require('./monitorActions'); | ||
var _effects = require('./effects'); | ||
var monitorActions = _interopRequireWildcard(_monitorActions); | ||
var effects = _interopRequireWildcard(_effects); | ||
var _utils = require('./utils'); | ||
var utils = _interopRequireWildcard(_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; } } | ||
@@ -141,3 +61,7 @@ | ||
var SagaCancellationException = exports.SagaCancellationException = _SagaCancellationException3.default; | ||
var isCancelError = exports.isCancelError = function isCancelError(error) { | ||
return error instanceof SagaCancellationException; | ||
}; | ||
exports.monitorActions = monitorActions; | ||
exports.effects = effects; | ||
exports.utils = utils; |
'use strict'; | ||
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 _utils = require('./internal/utils'); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.check = check; | ||
exports.remove = remove; | ||
exports.deferred = deferred; | ||
exports.arrayOfDeffered = arrayOfDeffered; | ||
exports.autoInc = autoInc; | ||
exports.asap = asap; | ||
var TASK = exports.TASK = Symbol('TASK'); | ||
var kTrue = exports.kTrue = function kTrue() { | ||
return true; | ||
}; | ||
var noop = exports.noop = function noop() {}; | ||
var _io = require('./internal/io'); | ||
var isDev = exports.isDev = typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'development'; | ||
var _proc = require('./internal/proc'); | ||
function check(value, predicate, error) { | ||
if (!predicate(value)) throw new Error(error); | ||
} | ||
var _testUtils = require('./internal/testUtils'); | ||
var is = exports.is = { | ||
undef: function undef(v) { | ||
return v === null || v === undefined; | ||
}, | ||
notUndef: function notUndef(v) { | ||
return v !== null && v !== undefined; | ||
}, | ||
func: function func(f) { | ||
return typeof f === 'function'; | ||
}, | ||
array: Array.isArray, | ||
promise: function promise(p) { | ||
return p && is.func(p.then); | ||
}, | ||
iterator: function iterator(it) { | ||
return it && is.func(it.next) && is.func(it[Symbol.iterator]); | ||
}, | ||
throw: function _throw(it) { | ||
return it && is.func(it.throw); | ||
}, | ||
task: function task(it) { | ||
return it && it[TASK]; | ||
} | ||
}; | ||
var _monitorActions = require('./internal/monitorActions'); | ||
function remove(array, item) { | ||
var index = array.indexOf(item); | ||
if (index >= 0) array.splice(index, 1); | ||
} | ||
var monitorActions = _interopRequireWildcard(_monitorActions); | ||
function deferred() { | ||
var props = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
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; } } | ||
var def = _extends({}, props); | ||
var promise = new Promise(function (resolve, reject) { | ||
def.resolve = resolve; | ||
def.reject = reject; | ||
}); | ||
def.promise = promise; | ||
return def; | ||
} | ||
module.exports = { | ||
TASK: _utils.TASK, | ||
noop: _utils.noop, | ||
is: _utils.is, asEffect: _io.asEffect, | ||
deferred: _utils.deferred, | ||
arrayOfDeffered: _utils.arrayOfDeffered, | ||
asap: _utils.asap, | ||
function arrayOfDeffered(length) { | ||
var arr = []; | ||
for (var i = 0; i < length; i++) { | ||
arr.push(deferred()); | ||
} | ||
return arr; | ||
} | ||
CANCEL: _proc.CANCEL, | ||
RACE_AUTO_CANCEL: _proc.RACE_AUTO_CANCEL, | ||
PARALLEL_AUTO_CANCEL: _proc.PARALLEL_AUTO_CANCEL, | ||
MANUAL_CANCEL: _proc.MANUAL_CANCEL, | ||
function autoInc() { | ||
var seed = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0]; | ||
createMockTask: _testUtils.createMockTask, | ||
return function () { | ||
return ++seed; | ||
}; | ||
} | ||
function asap(action) { | ||
return Promise.resolve(1).then(function () { | ||
return action(); | ||
}); | ||
} | ||
monitorActions: monitorActions | ||
}; |
{ | ||
"name": "redux-saga", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "Saga middleware for Redux to handle Side Effects", | ||
@@ -16,2 +16,3 @@ "main": "lib/index.js", | ||
"counter": "node examples/counter/server.js", | ||
"cancellable-counter": "node examples/cancellable-counter/server.js", | ||
"test-counter": "babel-node examples/counter/test/sagas.js | tap-spec", | ||
@@ -21,3 +22,3 @@ "shop": "node examples/shopping-cart/server.js", | ||
"async": "node examples/async/server.js", | ||
"real-world": "node examples/real-world/server.js", | ||
"real-world": "npm --prefix examples/real-world install examples/real-world && node examples/real-world/server.js", | ||
"docs:clean": "rimraf _book", | ||
@@ -64,3 +65,3 @@ "docs:prepare": "gitbook install", | ||
"react-redux": "^4.0.0", | ||
"redux": "^3.0.4", | ||
"redux": "^3.3.1", | ||
"redux-logger": "^2.0.4", | ||
@@ -67,0 +68,0 @@ "rimraf": "^2.4.3", |
155
README.md
@@ -5,5 +5,5 @@ # redux-saga | ||
An alternative Side Effect model for Redux applications. Instead of dispatching thunks | ||
which get handled by the redux-thunk middleware, you create *Sagas* to gather all your | ||
Side Effects logic in a central place. | ||
An alternative Side Effects middleware (aka Asynchronous Actions) for Redux applications. | ||
Instead of dispatching Thunks which get handled by the `redux-thunk` middleware, you | ||
create *Sagas* to gather all your Side Effects logic in a central place. | ||
@@ -16,32 +16,115 @@ This means the logic of the application lives in 2 places: | ||
Sagas are created using Generator functions. | ||
Sagas are created using Generator functions. If you're not familiar with them you may find | ||
[some useful links here](http://yelouafi.github.io/redux-saga/docs/ExternalResources.html) | ||
> As you'll see in the docs, Generators, while seemingly more low-level than ES7 async | ||
functions, allow some features like declarative effects and cancellation which are harder—if not | ||
impossible—to implement with simple async functions. | ||
Unlike Thunks which get invoked on every action by Action Creators. Sagas are fired only | ||
once at the start of the application (but startup Sagas may fire other Sagas dynamically). | ||
They can be seen as Processes running in the background. Sagas watch the actions dispatched | ||
to the Store, then decide what to do based on dispatched actions : Either making an asynchronous | ||
call (like an AJAX request), dispatching other actions to the Store or even starting other | ||
Sagas dynamically. | ||
In `redux-saga` all the above tasks are achieved by yielding **Effects**. Effects are simply | ||
JavaScript Objects containing instructions to be executed by the Saga middleware (As an analogy, | ||
you can see Redux actions as Objects containing instructions to be executed by the Store). | ||
`redux-saga` provides Effect creators for various tasks like calling an asynchronous function, | ||
dispatching an action to the Store, starting a background task or waiting for a future action | ||
that satisfies a certain condition. | ||
What this middleware proposes is: | ||
Using Generators, `redux-saga` allows you to write your asynchronous code in a simple | ||
synchronous style. Just like you can do with `async/await` functions. But Generators | ||
allows some things that aren't possible with `async` functions. | ||
- A composable abstraction **Effect**: waiting for an action, triggering state updates (by dispatching | ||
actions to the store), and calling a remote service are all different forms of Effects. A Saga composes those | ||
Effects using familiar control flow constructs (if, while, for, try/catch). | ||
The fact that Sagas yield plain Objects make it easy to test all the logic inside your Generator | ||
by simply iterating over the yielded Objects and doing simple equality tests. | ||
- The Saga is itself an Effect. It can be combined with other Effects using combinators. | ||
It can also be called from inside other Sagas, providing the full power of Subroutines and | ||
[Structured Programming](https://en.wikipedia.org/wiki/Structured_programming) | ||
Furthermore, tasks started in `redux-saga` can be cancelled at any moment either manually | ||
or automatically by putting them in a race with other Effects. | ||
- Effects may be yielded declaratively. You yield a description of the Effect which will be | ||
executed by the middleware. This makes your operational logic inside Generators fully testable. | ||
# Getting started | ||
- You can implement complex operations with logic that spans across multiple actions (e.g. User onboarding, wizard | ||
dialogs, complex Game rules, etc.), which are non-trivial to express using other effects middlewares. | ||
## Install | ||
``` | ||
npm install --save redux-saga | ||
``` | ||
# Install | ||
Alternatively, you may use the provided UMD builds directly in the `<script>` tag of | ||
an HTML page. See [this section](#using-umd-build-in-the-browser) | ||
## Usage Example | ||
Suppose we have an UI to fetch some user data from a remote server when a button is clicked | ||
(For brevity, we'll just show the action triggering code). | ||
```javascript | ||
class UserComponent extends React.Component { | ||
... | ||
onSomeButtonClicked() { | ||
const { userId, dispatch } = this.props | ||
dispatch({type: 'USER_FETCH_REQUESTED', payload: {userId}}) | ||
} | ||
... | ||
} | ||
``` | ||
npm install redux-saga | ||
The Component dispatches a plain Object action to the Store. We'll create a Saga that | ||
watches for all `USER_FETCH_REQUESTED` actions and triggers an API call to fetch the | ||
user data | ||
#### `sagas.js` | ||
```javascript | ||
import { takeEvery, takeLatest } from 'redux-saga' | ||
import { call, put } from 'redux-saga/effects' | ||
import Api from '...' | ||
// worker Saga : will be fired on USER_FETCH_REQUESTED actions | ||
function* fetchUser(action) { | ||
try { | ||
const user = yield call(Api.fetchUser, action.payload.userId); | ||
yield put({type: "USER_FETCH_SUCCEEDED", user: user}); | ||
} catch (e) { | ||
yield put({type: "USER_FETCH_FAILED",message: e.message}); | ||
} | ||
} | ||
/* | ||
starts fetchUser on each dispatched `USER_FETCH_REQUESTED` action | ||
Allow concurrent fetches of user | ||
*/ | ||
function* mySaga() { | ||
yield* takeEvery("USER_FETCH_REQUESTED", fetchUser); | ||
} | ||
/* | ||
Alternatively you may use takeLatest | ||
Do not allow concurrent fetches of user, If "USER_FETCH_REQUESTED" gets | ||
dispatched while a fetch is already pending, that pending fetch is cancelled | ||
and only the latest one will be run | ||
*/ | ||
function* mySaga() { | ||
yield* takeLatest("USER_FETCH_REQUESTED", fetchUser); | ||
} | ||
``` | ||
To run our Saga, we'll have to connect it to the Redux Store using the `redux-saga` middleware | ||
#### `main.js` | ||
```javascript | ||
import { createStore, applyMiddleware } from 'redux' | ||
import createSagaMiddleware from `redux-saga` | ||
import reducer from './reducers' | ||
import mySaga from './sagas' | ||
const sagaMiddleware = createSagaMiddleware(mySaga) | ||
const store = createStore( | ||
reducer, | ||
applyMiddleware(sagaMiddleware) | ||
) | ||
// render the application | ||
``` | ||
# Documentation | ||
@@ -92,4 +175,20 @@ | ||
### Counter example | ||
### Counter examples | ||
There are 3 counter examples | ||
#### counter-vanilla | ||
Demo using vanilla JavaScript and UMD builds. All source is inlined in `index.html` | ||
To launch the example, just open `index.html` in your browser | ||
>Important | ||
Your browser must support Generators. Latest versions of Chrome/Firefox/Edge are suitable. | ||
#### counter | ||
Demo using webpack and high level API `takeEvery` | ||
``` | ||
@@ -102,2 +201,10 @@ npm run counter | ||
#### cancellable-counter | ||
Demo using low level API. Demonstrate task cancellation | ||
``` | ||
npm run cancellable-counter | ||
``` | ||
### Shopping Cart example | ||
@@ -123,5 +230,5 @@ | ||
``` | ||
cd examples/real-world | ||
npm install | ||
npm start | ||
npm run real-world | ||
//sorry, no tests yet | ||
``` |
@@ -1,20 +0,19 @@ | ||
import middleware from './middleware' | ||
import middleware from './internal/middleware' | ||
export default middleware | ||
export { | ||
CANCEL, | ||
RACE_AUTO_CANCEL, | ||
PARALLEL_AUTO_CANCEL, | ||
MANUAL_CANCEL | ||
} from './proc' | ||
import _SagaCancellationException from './SagaCancellationException' | ||
import _SagaCancellationException from './internal/SagaCancellationException' | ||
export const SagaCancellationException = _SagaCancellationException | ||
export const isCancelError = error => error instanceof SagaCancellationException | ||
export { is } from './utils' | ||
export { take, put, race, call, apply, cps, fork, join, cancel, as } from './io' | ||
export { runSaga, storeIO } from './runSaga' | ||
export { runSaga, storeIO } from './internal/runSaga' | ||
import * as monitorActions from './monitorActions' | ||
export { monitorActions } | ||
export { takeEvery, takeLatest } from './internal/sagaHelpers' | ||
import * as effects from './effects' | ||
import * as utils from './utils' | ||
export { | ||
effects, | ||
utils | ||
} |
@@ -1,53 +0,41 @@ | ||
export const TASK = Symbol('TASK') | ||
export const kTrue = () => true | ||
export const noop = () => {} | ||
export const isDev = typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'development' | ||
import { | ||
TASK, | ||
noop, | ||
is, | ||
deferred, | ||
arrayOfDeffered, | ||
asap | ||
} from './internal/utils' | ||
export function check(value, predicate, error) { | ||
if(! predicate(value) ) | ||
throw new Error(error) | ||
} | ||
import { asEffect } from './internal/io' | ||
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 && 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] | ||
} | ||
import { | ||
CANCEL, | ||
RACE_AUTO_CANCEL, | ||
PARALLEL_AUTO_CANCEL, | ||
MANUAL_CANCEL | ||
} from './internal/proc' | ||
export function remove(array, item) { | ||
const index = array.indexOf(item) | ||
if(index >= 0) | ||
array.splice(index, 1) | ||
} | ||
import { createMockTask } from './internal/testUtils' | ||
export function deferred(props = {}) { | ||
let def = {...props} | ||
const promise = new Promise((resolve, reject) => { | ||
def.resolve = resolve | ||
def.reject = reject | ||
}) | ||
def.promise = promise | ||
return def | ||
} | ||
import * as monitorActions from './internal/monitorActions' | ||
export function arrayOfDeffered(length) { | ||
const arr = [] | ||
for (var i = 0; i < length; i++) { | ||
arr.push(deferred()) | ||
} | ||
return arr | ||
} | ||
export function autoInc(seed = 0) { | ||
return () => ++seed | ||
} | ||
module.exports = { | ||
TASK, | ||
noop, | ||
is, asEffect, | ||
deferred, | ||
arrayOfDeffered, | ||
asap, | ||
export function asap(action) { | ||
return Promise.resolve(1).then( () => action() ) | ||
CANCEL, | ||
RACE_AUTO_CANCEL, | ||
PARALLEL_AUTO_CANCEL, | ||
MANUAL_CANCEL, | ||
createMockTask, | ||
monitorActions | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
202525
38
2944
230
1