Socket
Socket
Sign inDemoInstall

redux

Package Overview
Dependencies
3
Maintainers
3
Versions
85
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.7.2 to 4.0.0-beta.1

es/redux.js

379

dist/redux.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.Redux = global.Redux || {})));
(factory((global.Redux = {})));
}(this, (function (exports) { 'use strict';
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
function symbolObservablePonyfill(root) {
var result;
var Symbol = root.Symbol;
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
if (typeof Symbol === 'function') {
if (Symbol.observable) {
result = Symbol.observable;
} else {
result = Symbol('observable');
Symbol.observable = result;
}
} else {
result = '@@observable';
}
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
return result;
}
/** Built-in value references. */
var Symbol = root.Symbol;
/* global window */
var root;
/** Used for built-in method references. */
var objectProto$1 = Object.prototype;
if (typeof self !== 'undefined') {
root = self;
} else if (typeof window !== 'undefined') {
root = window;
} else if (typeof global !== 'undefined') {
root = global;
} else if (typeof module !== 'undefined') {
root = module;
} else {
root = Function('return this')();
}
/** Used to check objects for own properties. */
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
var result = symbolObservablePonyfill(root);
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
* These are private action types reserved by Redux.
* For any unknown actions, you must return the current state.
* If the current state is undefined, you must return the initial state.
* Do not reference these action types directly in your code.
*/
var nativeObjectToString = objectProto$1.toString;
var ActionTypes = {
INIT: '@@redux/INIT' + Math.random().toString(36).substring(7).split('').join('.'),
REPLACE: '@@redux/REPLACE' + Math.random().toString(36).substring(7).split('').join('.')
};
/** Built-in value references. */
var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
/**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/
function getRawTag(value) {
var isOwn = hasOwnProperty$1.call(value, symToStringTag$1),
tag = value[symToStringTag$1];
try {
value[symToStringTag$1] = undefined;
var unmasked = true;
} catch (e) {}
var result = nativeObjectToString.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag$1] = tag;
} else {
delete value[symToStringTag$1];
}
}
return result;
}
/** Used for built-in method references. */
var objectProto$2 = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString$1 = objectProto$2.toString;
/**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/
function objectToString(value) {
return nativeObjectToString$1.call(value);
}
/** `Object#toString` result references. */
var nullTag = '[object Null]';
var undefinedTag = '[object Undefined]';
/** Built-in value references. */
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
/**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
return (symToStringTag && symToStringTag in Object(value))
? getRawTag(value)
: objectToString(value);
}
/**
* Creates a unary function that invokes `func` with its argument transformed.
*
* @private
* @param {Function} func The function to wrap.
* @param {Function} transform The argument transform.
* @returns {Function} Returns the new function.
*/
function overArg(func, transform) {
return function(arg) {
return func(transform(arg));
};
}
/** Built-in value references. */
var getPrototype = overArg(Object.getPrototypeOf, Object);
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return value != null && typeof value == 'object';
}
/** `Object#toString` result references. */
var objectTag = '[object Object]';
/** Used for built-in method references. */
var funcProto = Function.prototype;
var objectProto = Object.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/** Used to infer the `Object` constructor. */
var objectCtorString = funcToString.call(Object);
/**
* Checks if `value` is a plain object, that is, an object created by the
* `Object` constructor or one with a `[[Prototype]]` of `null`.
*
* @static
* @memberOf _
* @since 0.8.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
* @example
*
* function Foo() {
* this.a = 1;
* }
*
* _.isPlainObject(new Foo);
* // => false
*
* _.isPlainObject([1, 2, 3]);
* // => false
*
* _.isPlainObject({ 'x': 0, 'y': 0 });
* // => true
*
* _.isPlainObject(Object.create(null));
* // => true
*/
function isPlainObject(value) {
if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
return false;
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];
}
}
}
var proto = getPrototype(value);
if (proto === null) {
return true;
}
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
return typeof Ctor == 'function' && Ctor instanceof Ctor &&
funcToString.call(Ctor) == objectCtorString;
}
function symbolObservablePonyfill(root) {
var result;
var Symbol = root.Symbol;
return target;
};
if (typeof Symbol === 'function') {
if (Symbol.observable) {
result = Symbol.observable;
} else {
result = Symbol('observable');
Symbol.observable = result;
}
} else {
result = '@@observable';
}
/**
* @param {any} obj The object to inspect.
* @returns {boolean} True if the argument appears to be a plain object.
*/
function isPlainObject(obj) {
if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) return false;
return result;
}
var proto = obj;
while (Object.getPrototypeOf(proto) !== null) {
proto = Object.getPrototypeOf(proto);
}
/* global window */
var root$2;
if (typeof self !== 'undefined') {
root$2 = self;
} else if (typeof window !== 'undefined') {
root$2 = window;
} else if (typeof global !== 'undefined') {
root$2 = global;
} else if (typeof module !== 'undefined') {
root$2 = module;
} else {
root$2 = Function('return this')();
return Object.getPrototypeOf(obj) === proto;
}
var result = symbolObservablePonyfill(root$2);
/**
* These are private action types reserved by Redux.
* For any unknown actions, you must return the current state.
* If the current state is undefined, you must return the initial state.
* Do not reference these action types directly in your code.
* Creates a Redux store that holds the state tree.
* The only way to change the data in the store is to call `dispatch()` on it.
*
* There should only be a single store in your app. To specify how different
* parts of the state tree respond to actions, you may combine several reducers
* into a single reducer function by using `combineReducers`.
*
* @param {Function} reducer A function that returns the next state tree, given
* the current state tree and the action to handle.
*
* @param {any} [preloadedState] The initial state. You may optionally specify it
* to hydrate the state from the server in universal apps, or to restore a
* previously serialized user session.
* If you use `combineReducers` to produce the root reducer function, this must be
* an object with the same shape as `combineReducers` keys.
*
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
* to enhance the store with third-party capabilities such as middleware,
* time travel, persistence, etc. The only store enhancer that ships with Redux
* is `applyMiddleware()`.
*
* @returns {Store} A Redux store that lets you read the state, dispatch actions
* and subscribe to changes.
*/
var ActionTypes = {
INIT: '@@redux/INIT'
/**
* Creates a Redux store that holds the state tree.
* The only way to change the data in the store is to call `dispatch()` on it.
*
* There should only be a single store in your app. To specify how different
* parts of the state tree respond to actions, you may combine several reducers
* into a single reducer function by using `combineReducers`.
*
* @param {Function} reducer A function that returns the next state tree, given
* the current state tree and the action to handle.
*
* @param {any} [preloadedState] The initial state. You may optionally specify it
* to hydrate the state from the server in universal apps, or to restore a
* previously serialized user session.
* If you use `combineReducers` to produce the root reducer function, this must be
* an object with the same shape as `combineReducers` keys.
*
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
* to enhance the store with third-party capabilities such as middleware,
* time travel, persistence, etc. The only store enhancer that ships with Redux
* is `applyMiddleware()`.
*
* @returns {Store} A Redux store that lets you read the state, dispatch actions
* and subscribe to changes.
*/
};function createStore(reducer, preloadedState, enhancer) {
function createStore(reducer, preloadedState, enhancer) {
var _ref2;

@@ -315,2 +169,6 @@

function getState() {
if (isDispatching) {
throw new Error('You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
}
return currentState;

@@ -347,2 +205,6 @@ }

if (isDispatching) {
throw new Error('You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See http://redux.js.org/docs/api/Store.html#subscribe for more details.');
}
var isSubscribed = true;

@@ -358,2 +220,6 @@

if (isDispatching) {
throw new Error('You may not unsubscribe from a store listener while the reducer is executing. ' + 'See http://redux.js.org/docs/api/Store.html#subscribe for more details.');
}
isSubscribed = false;

@@ -437,3 +303,3 @@

currentReducer = nextReducer;
dispatch({ type: ActionTypes.INIT });
dispatch({ type: ActionTypes.REPLACE });
}

@@ -461,3 +327,3 @@

subscribe: function subscribe(observer) {
if (typeof observer !== 'object') {
if ((typeof observer === 'undefined' ? 'undefined' : _typeof(observer)) !== 'object') {
throw new TypeError('Expected the observer to be an object.');

@@ -518,5 +384,5 @@ }

var actionType = action && action.type;
var actionName = actionType && '"' + actionType.toString() + '"' || 'an action';
var actionDescription = actionType && 'action "' + String(actionType) + '"' || 'an action';
return 'Given action ' + actionName + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state. ' + 'If you want this reducer to hold no value, you can return null instead of undefined.';
return 'Given ' + actionDescription + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state. ' + 'If you want this reducer to hold no value, you can return null instead of undefined.';
}

@@ -544,2 +410,4 @@

if (action && action.type === ActionTypes.REPLACE) return;
if (unexpectedKeys.length > 0) {

@@ -647,3 +515,3 @@ return 'Unexpected ' + (unexpectedKeys.length > 1 ? 'keys' : 'key') + ' ' + ('"' + unexpectedKeys.join('", "') + '" found in ' + argumentName + '. ') + 'Expected to find one of the known reducer keys instead: ' + ('"' + reducerKeys.join('", "') + '". Unexpected keys will be ignored.');

return function () {
return dispatch(actionCreator.apply(undefined, arguments));
return dispatch(actionCreator.apply(this, arguments));
};

@@ -678,4 +546,4 @@ }

if (typeof actionCreators !== 'object' || actionCreators === null) {
throw new Error('bindActionCreators expected an object or a function, instead received ' + (actionCreators === null ? 'null' : typeof actionCreators) + '. ' + 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');
if ((typeof actionCreators === 'undefined' ? 'undefined' : _typeof(actionCreators)) !== 'object' || actionCreators === null) {
throw new Error('bindActionCreators expected an object or a function, instead received ' + (actionCreators === null ? 'null' : typeof actionCreators === 'undefined' ? 'undefined' : _typeof(actionCreators)) + '. ' + 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');
}

@@ -728,4 +596,2 @@

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; };
/**

@@ -753,5 +619,11 @@ * Creates a store enhancer that applies middleware to the dispatch method

return function (createStore) {
return function (reducer, preloadedState, enhancer) {
var store = createStore(reducer, preloadedState, enhancer);
var _dispatch = store.dispatch;
return function () {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
var store = createStore.apply(undefined, args);
var _dispatch = function dispatch() {
throw new Error('Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
};
var chain = [];

@@ -761,4 +633,4 @@

getState: store.getState,
dispatch: function dispatch(action) {
return _dispatch(action);
dispatch: function dispatch() {
return _dispatch.apply(undefined, arguments);
}

@@ -779,5 +651,5 @@ };

/*
* This is a dummy function to check if the function name has been altered by minification.
* If the function has been minified and NODE_ENV !== 'production', warn the user.
*/
* This is a dummy function to check if the function name has been altered by minification.
* If the function has been minified and NODE_ENV !== 'production', warn the user.
*/
function isCrushed() {}

@@ -794,2 +666,3 @@

exports.compose = compose;
exports.__DO_NOT_USE__ActionTypes = ActionTypes;

@@ -796,0 +669,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Redux=t.Redux||{})}(this,function(t){"use strict";function e(t){var e=h.call(t,g),n=t[g];try{t[g]=void 0;var r=!0}catch(t){}var o=v.call(t);return r&&(e?t[g]=n:delete t[g]),o}function n(t){return j.call(t)}function r(t){return null==t?void 0===t?m:w:O&&O in Object(t)?e(t):n(t)}function o(t){return null!=t&&"object"==typeof t}function i(t){if(!o(t)||r(t)!=E)return!1;var e=x(t);if(null===e)return!0;var n=N.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&S.call(n)==A}function u(t,e,n){function r(){p===l&&(p=l.slice())}function o(){return s}function c(t){if("function"!=typeof t)throw Error("Expected listener to be a function.");var e=!0;return r(),p.push(t),function(){if(e){e=!1,r();var n=p.indexOf(t);p.splice(n,1)}}}function a(t){if(!i(t))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===t.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(y)throw Error("Reducers may not dispatch actions.");try{y=!0,s=d(s,t)}finally{y=!1}for(var e=l=p,n=0;e.length>n;n++)(0,e[n])();return t}var f;if("function"==typeof e&&void 0===n&&(n=e,e=void 0),void 0!==n){if("function"!=typeof n)throw Error("Expected the enhancer to be a function.");return n(u)(t,e)}if("function"!=typeof t)throw Error("Expected the reducer to be a function.");var d=t,s=e,l=[],p=l,y=!1;return a({type:P.INIT}),f={dispatch:a,subscribe:c,getState:o,replaceReducer:function(t){if("function"!=typeof t)throw Error("Expected the nextReducer to be a function.");d=t,a({type:P.INIT})}},f[R]=function(){var t,e=c;return t={subscribe:function(t){function n(){t.next&&t.next(o())}if("object"!=typeof t)throw new TypeError("Expected the observer to be an object.");return n(),{unsubscribe:e(n)}}},t[R]=function(){return this},t},f}function c(t,e){var n=e&&e.type;return"Given action "+(n&&'"'+n+'"'||"an action")+', reducer "'+t+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.'}function a(t){Object.keys(t).forEach(function(e){var n=t[e];if(void 0===n(void 0,{type:P.INIT}))throw Error('Reducer "'+e+"\" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.");if(void 0===n(void 0,{type:"@@redux/PROBE_UNKNOWN_ACTION_"+Math.random().toString(36).substring(7).split("").join(".")}))throw Error('Reducer "'+e+"\" returned undefined when probed with a random type. Don't try to handle "+P.INIT+' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.')})}function f(t,e){return function(){return e(t.apply(void 0,arguments))}}function d(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return 0===e.length?function(t){return t}:1===e.length?e[0]:e.reduce(function(t,e){return function(){return t(e.apply(void 0,arguments))}})}var s,l="object"==typeof global&&global&&global.Object===Object&&global,p="object"==typeof self&&self&&self.Object===Object&&self,y=(l||p||Function("return this")()).Symbol,b=Object.prototype,h=b.hasOwnProperty,v=b.toString,g=y?y.toStringTag:void 0,j=Object.prototype.toString,w="[object Null]",m="[object Undefined]",O=y?y.toStringTag:void 0,x=function(t,e){return function(n){return t(e(n))}}(Object.getPrototypeOf,Object),E="[object Object]",I=Function.prototype,T=Object.prototype,S=I.toString,N=T.hasOwnProperty,A=S.call(Object),R=function(t){var e,n=t.Symbol;return"function"==typeof n?n.observable?e=n.observable:(e=n("observable"),n.observable=e):e="@@observable",e}(s="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),P={INIT:"@@redux/INIT"},k=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};t.createStore=u,t.combineReducers=function(t){for(var e=Object.keys(t),n={},r=0;e.length>r;r++){var o=e[r];"function"==typeof t[o]&&(n[o]=t[o])}var i=Object.keys(n),u=void 0;try{a(n)}catch(t){u=t}return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments[1];if(u)throw u;for(var r=!1,o={},a=0;i.length>a;a++){var f=i[a],d=n[f],s=t[f],l=d(s,e);if(void 0===l){var p=c(f,e);throw Error(p)}o[f]=l,r=r||l!==s}return r?o:t}},t.bindActionCreators=function(t,e){if("function"==typeof t)return f(t,e);if("object"!=typeof t||null===t)throw Error("bindActionCreators expected an object or a function, instead received "+(null===t?"null":typeof t)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var n=Object.keys(t),r={},o=0;n.length>o;o++){var i=n[o],u=t[i];"function"==typeof u&&(r[i]=f(u,e))}return r},t.applyMiddleware=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return function(t){return function(n,r,o){var i=t(n,r,o),u=i.dispatch,c=[],a={getState:i.getState,dispatch:function(t){return u(t)}};return c=e.map(function(t){return t(a)}),u=d.apply(void 0,c)(i.dispatch),k({},i,{dispatch:u})}}},t.compose=d,Object.defineProperty(t,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.Redux={})}(this,function(e){"use strict";function t(e){if("object"!==(void 0===e?"undefined":d(e))||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function r(e,n,o){function i(){b===y&&(b=y.slice())}function u(){if(v)throw Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return h}function a(e){if("function"!=typeof e)throw Error("Expected listener to be a function.");if(v)throw Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See http://redux.js.org/docs/api/Store.html#subscribe for more details.");var t=!0;return i(),b.push(e),function(){if(t){if(v)throw Error("You may not unsubscribe from a store listener while the reducer is executing. See http://redux.js.org/docs/api/Store.html#subscribe for more details.");t=!1,i();var r=b.indexOf(e);b.splice(r,1)}}}function s(e){if(!t(e))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(v)throw Error("Reducers may not dispatch actions.");try{v=!0,h=p(h,e)}finally{v=!1}for(var r=y=b,n=0;r.length>n;n++)(0,r[n])();return e}var l;if("function"==typeof n&&void 0===o&&(o=n,n=void 0),void 0!==o){if("function"!=typeof o)throw Error("Expected the enhancer to be a function.");return o(r)(e,n)}if("function"!=typeof e)throw Error("Expected the reducer to be a function.");var p=e,h=n,y=[],b=y,v=!1;return s({type:f.INIT}),l={dispatch:s,subscribe:a,getState:u,replaceReducer:function(e){if("function"!=typeof e)throw Error("Expected the nextReducer to be a function.");p=e,s({type:f.REPLACE})}},l[c]=function(){var e,t=a;return e={subscribe:function(e){function r(){e.next&&e.next(u())}if("object"!==(void 0===e?"undefined":d(e)))throw new TypeError("Expected the observer to be an object.");return r(),{unsubscribe:t(r)}}},e[c]=function(){return this},e},l}function n(e,t){var r=t&&t.type;return"Given "+(r&&'action "'+r+'"'||"an action")+', reducer "'+e+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.'}function o(e){Object.keys(e).forEach(function(t){var r=e[t];if(void 0===r(void 0,{type:f.INIT}))throw Error('Reducer "'+t+"\" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.");if(void 0===r(void 0,{type:"@@redux/PROBE_UNKNOWN_ACTION_"+Math.random().toString(36).substring(7).split("").join(".")}))throw Error('Reducer "'+t+"\" returned undefined when probed with a random type. Don't try to handle "+f.INIT+' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.')})}function i(e,t){return function(){return t(e.apply(this,arguments))}}function u(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce(function(e,t){return function(){return e(t.apply(void 0,arguments))}})}var a,c=function(e){var t,r=e.Symbol;return"function"==typeof r?r.observable?t=r.observable:(t=r("observable"),r.observable=t):t="@@observable",t}(a="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),f={INIT:"@@redux/INIT"+Math.random().toString(36).substring(7).split("").join("."),REPLACE:"@@redux/REPLACE"+Math.random().toString(36).substring(7).split("").join(".")},d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};e.createStore=r,e.combineReducers=function(e){for(var t=Object.keys(e),r={},i=0;t.length>i;i++){var u=t[i];"function"==typeof e[u]&&(r[u]=e[u])}var a=Object.keys(r),c=void 0;try{o(r)}catch(e){c=e}return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];if(c)throw c;for(var o=!1,i={},u=0;a.length>u;u++){var f=a[u],d=r[f],s=e[f],l=d(s,t);if(void 0===l){var p=n(f,t);throw Error(p)}i[f]=l,o=o||l!==s}return o?i:e}},e.bindActionCreators=function(e,t){if("function"==typeof e)return i(e,t);if("object"!==(void 0===e?"undefined":d(e))||null===e)throw Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":void 0===e?"undefined":d(e))+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var r=Object.keys(e),n={},o=0;r.length>o;o++){var u=r[o],a=e[u];"function"==typeof a&&(n[u]=i(a,t))}return n},e.applyMiddleware=function(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return function(e){return function(){for(var r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];var i=e.apply(void 0,n),a=function(){throw Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},c=[],f={getState:i.getState,dispatch:function(){return a.apply(void 0,arguments)}};return c=t.map(function(e){return e(f)}),a=u.apply(void 0,c)(i.dispatch),s({},i,{dispatch:a})}}},e.compose=u,e.__DO_NOT_USE__ActionTypes=f,Object.defineProperty(e,"__esModule",{value:!0})});

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

/**

@@ -15,19 +16,9 @@ * An *action* is a plain object that represents an intention to change the

* how actions should be constructed.
*
* @template T the type of the action's `type` tag.
*/
export interface Action {
type: any;
export interface Action<T = any> {
type: T;
}
/**
* An Action type which accepts any other properties.
* This is mainly for the use of the `Reducer` type.
* This is not part of `Action` itself to prevent users who are extending `Action.
* @private
*/
export interface AnyAction extends Action {
// Allows any extra properties to be defined in an action.
[extraProps: string]: any;
}
/* reducers */

@@ -56,11 +47,14 @@

*
* @template S State object type.
* @template S The type of state consumed and produced by this reducer.
* @template A The type of actions the reducer can potentially respond to.
*/
export type Reducer<S> = (state: S, action: AnyAction) => S;
export type Reducer<S = any, A extends Action = Action> = (state: S | undefined, action: A) => S;
/**
* Object whose values correspond to different reducer functions.
*
* @template A The type of actions the reducers can potentially respond to.
*/
export interface ReducersMapObject {
[key: string]: Reducer<any>;
export type ReducersMapObject<S = any, A extends Action = Action> = {
[K in keyof S]: Reducer<S[K], A>;
}

@@ -86,3 +80,3 @@

*/
export function combineReducers<S>(reducers: ReducersMapObject): Reducer<S>;
export function combineReducers<S, A extends Action = Action>(reducers: ReducersMapObject<S, A>): Reducer<S, A>;

@@ -109,5 +103,7 @@

* before passing them to the next middleware.
*
* @template D the type of things (actions or otherwise) which may be dispatched.
*/
export interface Dispatch<S> {
<A extends Action>(action: A): A;
export interface Dispatch<D = Action> {
<A extends D>(action: A): A;
}

@@ -127,5 +123,7 @@

*
* @template S State object type.
* @template S The type of state held by this store.
* @template A the type of actions which may be dispatched by this store.
* @template N The type of non-actions which may be dispatched by this store.
*/
export interface Store<S> {
export interface Store<S = any, A extends Action = Action, N = never> {
/**

@@ -157,3 +155,3 @@ * Dispatches an action. It is the only way to trigger a state change.

*/
dispatch: Dispatch<S>;
dispatch: Dispatch<A | N>;

@@ -202,5 +200,7 @@ /**

*/
replaceReducer(nextReducer: Reducer<S>): void;
replaceReducer(nextReducer: Reducer<S, A>): void;
}
export type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
/**

@@ -212,7 +212,9 @@ * A store creator is a function that creates a Redux store. Like with

*
* @template S State object type.
* @template S The type of state to be held by the store.
* @template A The type of actions which may be dispatched.
* @template D The type of all things which may be dispatched.
*/
export interface StoreCreator {
<S>(reducer: Reducer<S>, enhancer?: StoreEnhancer<S>): Store<S>;
<S>(reducer: Reducer<S>, preloadedState: S, enhancer?: StoreEnhancer<S>): Store<S>;
<S, A extends Action, N>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<N>): Store<S, A, N>;
<S, A extends Action, N>(reducer: Reducer<S, A>, preloadedState: DeepPartial<S>, enhancer?: StoreEnhancer<N>): Store<S, A, N>;
}

@@ -237,6 +239,7 @@

* middleware implementation is itself a store enhancer.
*
*/
export type StoreEnhancer<S> = (next: StoreEnhancerStoreCreator<S>) => StoreEnhancerStoreCreator<S>;
export type GenericStoreEnhancer = <S>(next: StoreEnhancerStoreCreator<S>) => StoreEnhancerStoreCreator<S>;
export type StoreEnhancerStoreCreator<S> = (reducer: Reducer<S>, preloadedState?: S) => Store<S>;
export type StoreEnhancer<N = never> = (next: StoreEnhancerStoreCreator<N>) => StoreEnhancerStoreCreator<N>;
export type GenericStoreEnhancer<N = never> = StoreEnhancer<N>;
export type StoreEnhancerStoreCreator<N = never> = <S = any, A extends Action = Action>(reducer: Reducer<S, A>, preloadedState?: DeepPartial<S>) => Store<S, A, N>;

@@ -276,4 +279,4 @@ /**

export interface MiddlewareAPI<S> {
dispatch: Dispatch<S>;
export interface MiddlewareAPI<S = any, D = Action> {
dispatch: Dispatch<D>;
getState(): S;

@@ -292,3 +295,3 @@ }

export interface Middleware {
<S>(api: MiddlewareAPI<S>): (next: Dispatch<S>) => Dispatch<S>;
<S = any, D = Action>(api: MiddlewareAPI<S, D>): (next: Dispatch<D>) => Dispatch<D>;
}

@@ -342,4 +345,4 @@

*/
export interface ActionCreatorsMapObject {
[key: string]: ActionCreator<any>;
export interface ActionCreatorsMapObject<A = any> {
[key: string]: ActionCreator<A>;
}

@@ -366,3 +369,3 @@

*/
export function bindActionCreators<A extends ActionCreator<any>>(actionCreator: A, dispatch: Dispatch<any>): A;
export function bindActionCreators<A, C extends ActionCreator<A>>(actionCreator: C, dispatch: Dispatch<A>): C;

@@ -374,7 +377,7 @@ export function bindActionCreators<

export function bindActionCreators<M extends ActionCreatorsMapObject>(actionCreators: M, dispatch: Dispatch<any>): M;
export function bindActionCreators<A, M extends ActionCreatorsMapObject<A>>(actionCreators: M, dispatch: Dispatch<A>): M;
export function bindActionCreators<
M extends ActionCreatorsMapObject,
N extends ActionCreatorsMapObject
M extends ActionCreatorsMapObject<any>,
N extends ActionCreatorsMapObject<any>
>(actionCreators: M, dispatch: Dispatch<any>): N;

@@ -381,0 +384,0 @@

{
"name": "redux",
"version": "3.7.2",
"version": "4.0.0-beta.1",
"description": "Predictable state container for JavaScript apps",
"main": "lib/index.js",
"module": "es/index.js",
"jsnext:main": "es/index.js",
"main": "lib/redux.js",
"module": "es/redux.js",
"typings": "./index.d.ts",

@@ -19,11 +18,12 @@ "files": [

"lint": "eslint src test build",
"pretest": "npm run build:commonjs",
"test": "cross-env BABEL_ENV=commonjs jest",
"test:watch": "yarn test -- --watch",
"test:cov": "yarn test -- --coverage",
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
"build:umd": "cross-env BABEL_ENV=es NODE_ENV=development rollup -c -i src/index.js -o dist/redux.js",
"build:umd:min": "cross-env BABEL_ENV=es NODE_ENV=production rollup -c -i src/index.js -o dist/redux.min.js",
"build": "yarn run build:commonjs && yarn run build:es && yarn run build:umd && yarn run build:umd:min",
"prepare": "yarn run clean && yarn run lint && yarn test && yarn run build",
"test:watch": "npm test -- --watch",
"test:cov": "npm test -- --coverage",
"build:commonjs": "cross-env NODE_ENV=cjs rollup -c -o lib/redux.js",
"build:es": "cross-env BABEL_ENV=es NODE_ENV=es rollup -c -o es/redux.js",
"build:umd": "cross-env BABEL_ENV=es NODE_ENV=development rollup -c -o dist/redux.js",
"build:umd:min": "cross-env BABEL_ENV=es NODE_ENV=production rollup -c -o dist/redux.min.js",
"build": "npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min",
"prepare": "npm run clean && npm run lint && npm test && npm run build",
"examples:lint": "eslint examples",

@@ -33,5 +33,5 @@ "examples:test": "cross-env CI=true babel-node examples/testAll.js",

"docs:prepare": "gitbook install",
"docs:build": "yarn run docs:prepare && gitbook build -g reactjs/redux && cp logo/apple-touch-icon.png _book/gitbook/images/apple-touch-icon-precomposed-152.png && cp logo/favicon.ico _book/gitbook/images",
"docs:watch": "yarn run docs:prepare && gitbook serve",
"docs:publish": "yarn run docs:clean && yarn run docs:build && cp CNAME _book && cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push git@github.com:reactjs/redux gh-pages --force"
"docs:build": "npm run docs:prepare && gitbook build -g reactjs/redux && cp logo/apple-touch-icon.png _book/gitbook/images/apple-touch-icon-precomposed-152.png && cp logo/favicon.ico _book/gitbook/images",
"docs:watch": "npm run docs:prepare && gitbook serve",
"docs:publish": "npm run docs:clean && npm run docs:build && cp CNAME _book && cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push git@github.com:reactjs/redux gh-pages --force"
},

@@ -65,4 +65,2 @@ "repository": {

"dependencies": {
"lodash": "^4.2.1",
"lodash-es": "^4.2.1",
"loose-envify": "^1.1.0",

@@ -72,47 +70,29 @@ "symbol-observable": "^1.0.3"

"devDependencies": {
"babel-cli": "^6.3.15",
"babel-core": "^6.3.15",
"babel-eslint": "^7.0.0",
"babel-jest": "^20.0.3",
"babel-plugin-check-es2015-constants": "^6.3.13",
"babel-plugin-transform-es2015-arrow-functions": "^6.3.13",
"babel-plugin-transform-es2015-block-scoped-functions": "^6.3.13",
"babel-plugin-transform-es2015-block-scoping": "^6.3.13",
"babel-plugin-transform-es2015-classes": "^6.3.13",
"babel-plugin-transform-es2015-computed-properties": "^6.3.13",
"babel-plugin-transform-es2015-destructuring": "^6.3.13",
"babel-plugin-transform-es2015-for-of": "^6.3.13",
"babel-plugin-transform-es2015-function-name": "^6.3.13",
"babel-plugin-transform-es2015-literals": "^6.3.13",
"babel-plugin-transform-es2015-modules-commonjs": "^6.3.13",
"babel-plugin-transform-es2015-object-super": "^6.3.13",
"babel-plugin-transform-es2015-parameters": "^6.3.13",
"babel-plugin-transform-es2015-shorthand-properties": "^6.3.13",
"babel-plugin-transform-es2015-spread": "^6.3.13",
"babel-plugin-transform-es2015-sticky-regex": "^6.3.13",
"babel-plugin-transform-es2015-template-literals": "^6.3.13",
"babel-plugin-transform-es2015-unicode-regex": "^6.3.13",
"babel-plugin-transform-es3-member-expression-literals": "^6.5.0",
"babel-plugin-transform-es3-property-literals": "^6.5.0",
"babel-plugin-transform-object-rest-spread": "^6.3.13",
"babel-register": "^6.3.13",
"cross-env": "^5.0.1",
"eslint": "^4.0.0",
"eslint-config-react-app": "^1.0.4",
"eslint-plugin-flowtype": "^2.29.2",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.1",
"babel-jest": "^21.2.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-register": "^6.26.0",
"cross-env": "^5.1.0",
"eslint": "^4.9.0",
"eslint-config-react-app": "^2.0.1",
"eslint-plugin-flowtype": "^2.39.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^5.0.3",
"eslint-plugin-react": "^7.1.0",
"gitbook-cli": "^2.3.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.4.0",
"gitbook-cli": "^2.3.2",
"glob": "^7.1.1",
"jest": "^20.0.4",
"rimraf": "^2.3.4",
"rollup": "^0.43.0",
"rollup-plugin-babel": "^2.7.1",
"jest": "^21.2.1",
"rimraf": "^2.6.2",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-replace": "^1.1.1",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^2.0.1",
"rxjs": "^5.0.0-beta.6",
"typescript": "^1.8.0",
"typescript-definition-tester": "0.0.4"
"rxjs": "^5.5.0",
"typescript": "^2.4.2",
"typescript-definition-tester": "0.0.5"
},

@@ -119,0 +99,0 @@ "npmName": "redux",

# <a href='http://redux.js.org'><img src='https://camo.githubusercontent.com/f28b5bc7822f1b7bb28a96d8d09e7d79169248fc/687474703a2f2f692e696d6775722e636f6d2f4a65567164514d2e706e67' height='60'></a>
Redux is a predictable state container for JavaScript apps.
(If you're looking for a WordPress framework, check out [Redux Framework](https://reduxframework.com/).)
(Not to be confused with a WordPress framework – [Redux Framework](https://reduxframework.com/).)

@@ -161,3 +161,3 @@ It helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test. On top of that, it provides a great developer experience, such as [live code editing combined with a time traveling debugger](https://github.com/gaearon/redux-devtools).

If you enjoyed my course, consider supporting Egghead by [buying a subscription](https://egghead.io/pricing). Subscribers have access to the source code for the example in every one of my videos, as well as to tons of advanced lessons on other topics, including JavaScript in depth, React, Angular, and more. Many [Egghead instructors](https://egghead.io/instructors) are also open source library authors, so buying a subscription is a nice way to thank them for the work that they've done.
If you enjoyed my course, consider supporting Egghead by [buying a subscription](https://egghead.io/pricing). Subscribers have access to the source code of every example in my videos and tons of advanced lessons on other topics, including JavaScript in depth, React, Angular, and more. Many [Egghead instructors](https://egghead.io/instructors) are also open source library authors, so buying a subscription is a nice way to thank them for the work that they've done.

@@ -232,3 +232,3 @@ ### Documentation

[See the full list of Redux patrons.](PATRONS.md), as well as the always-growing list of [people and companies that use Redux](https://github.com/reactjs/redux/issues/310).
[See the full list of Redux patrons](PATRONS.md), as well as the always-growing list of [people and companies that use Redux](https://github.com/reactjs/redux/issues/310).

@@ -235,0 +235,0 @@ ### License

@@ -20,5 +20,10 @@ import compose from './compose'

export default function applyMiddleware(...middlewares) {
return (createStore) => (reducer, preloadedState, enhancer) => {
const store = createStore(reducer, preloadedState, enhancer)
let dispatch = store.dispatch
return (createStore) => (...args) => {
const store = createStore(...args)
let dispatch = () => {
throw new Error(
`Dispatching while constructing your middleware is not allowed. ` +
`Other middleware would not be applied to this dispatch.`
)
}
let chain = []

@@ -28,3 +33,3 @@

getState: store.getState,
dispatch: (action) => dispatch(action)
dispatch: (...args) => dispatch(...args)
}

@@ -31,0 +36,0 @@ chain = middlewares.map(middleware => middleware(middlewareAPI))

function bindActionCreator(actionCreator, dispatch) {
return (...args) => dispatch(actionCreator(...args))
return function() { return dispatch(actionCreator.apply(this, arguments)) }
}

@@ -4,0 +4,0 @@

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

import { ActionTypes } from './createStore'
import isPlainObject from 'lodash/isPlainObject'
import ActionTypes from './utils/actionTypes'
import warning from './utils/warning'
import isPlainObject from './utils/isPlainObject'
function getUndefinedStateErrorMessage(key, action) {
const actionType = action && action.type
const actionName = (actionType && `"${actionType.toString()}"`) || 'an action'
const actionDescription = (actionType && `action "${String(actionType)}"`) || 'an action'
return (
`Given action ${actionName}, reducer "${key}" returned undefined. ` +
`Given ${actionDescription}, reducer "${key}" returned undefined. ` +
`To ignore an action, you must explicitly return the previous state. ` +

@@ -47,2 +47,4 @@ `If you want this reducer to hold no value, you can return null instead of undefined.`

if (action && action.type === ActionTypes.REPLACE) return
if (unexpectedKeys.length > 0) {

@@ -49,0 +51,0 @@ return (

@@ -1,13 +0,5 @@

import isPlainObject from 'lodash/isPlainObject'
import $$observable from 'symbol-observable'
/**
* These are private action types reserved by Redux.
* For any unknown actions, you must return the current state.
* If the current state is undefined, you must return the initial state.
* Do not reference these action types directly in your code.
*/
export const ActionTypes = {
INIT: '@@redux/INIT'
}
import ActionTypes from './utils/actionTypes'
import isPlainObject from './utils/isPlainObject'

@@ -75,2 +67,10 @@ /**

function getState() {
if (isDispatching) {
throw new Error(
'You may not call store.getState() while the reducer is executing. ' +
'The reducer has already received the state as an argument. ' +
'Pass it down from the top reducer instead of reading it from the store.'
)
}
return currentState

@@ -107,2 +107,11 @@ }

if (isDispatching) {
throw new Error(
'You may not call store.subscribe() while the reducer is executing. ' +
'If you would like to be notified after the store has been updated, subscribe from a ' +
'component and invoke store.getState() in the callback to access the latest state. ' +
'See http://redux.js.org/docs/api/Store.html#subscribe for more details.'
)
}
let isSubscribed = true

@@ -118,2 +127,9 @@

if (isDispatching) {
throw new Error(
'You may not unsubscribe from a store listener while the reducer is executing. ' +
'See http://redux.js.org/docs/api/Store.html#subscribe for more details.'
)
}
isSubscribed = false

@@ -203,3 +219,3 @@

currentReducer = nextReducer
dispatch({ type: ActionTypes.INIT })
dispatch({ type: ActionTypes.REPLACE })
}

@@ -206,0 +222,0 @@

@@ -7,7 +7,8 @@ import createStore from './createStore'

import warning from './utils/warning'
import __DO_NOT_USE__ActionTypes from './utils/actionTypes'
/*
* This is a dummy function to check if the function name has been altered by minification.
* If the function has been minified and NODE_ENV !== 'production', warn the user.
*/
* This is a dummy function to check if the function name has been altered by minification.
* If the function has been minified and NODE_ENV !== 'production', warn the user.
*/
function isCrushed() {}

@@ -34,3 +35,4 @@

applyMiddleware,
compose
compose,
__DO_NOT_USE__ActionTypes
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc