New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

redux-first-history

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-first-history - npm Package Compare versions

Comparing version 4.0.3 to 4.0.4

1

.eslintrc.json

@@ -6,3 +6,2 @@ {

"extends": "airbnb",
"parser": "babel-eslint",
"rules": {

@@ -9,0 +8,0 @@ "max-len": "off",

163

lib/redux-first-history.js

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

'use strict';
"use strict";

@@ -6,11 +6,24 @@ Object.defineProperty(exports, "__esModule", {

});
exports.createReduxHistoryContext = exports.goForward = exports.goBack = exports.go = exports.replace = exports.push = exports.LOCATION_CHANGE = exports.CALL_HISTORY_METHOD = exports.reachify = void 0;
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
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; }
/************************************************* reachify ******************************************************/
var reachify = function reachify(reduxHistory) {
var transitioning = false;
var reachify = exports.reachify = function reachify(reduxHistory) {
var transitioning = false;
var resolveTransition = function resolveTransition() {};

@@ -25,3 +38,6 @@

return reduxHistory.listen(function (location, action) {
return listener({ location: location, action: action });
return listener({
location: location,
action: action
});
});

@@ -33,9 +49,18 @@ },

_ref$replace = _ref.replace,
replace = _ref$replace === undefined ? false : _ref$replace;
replace = _ref$replace === void 0 ? false : _ref$replace;
if (transitioning || replace) {
reduxHistory.replace({ pathname: to, state: state, key: '' + Date.now() });
reduxHistory.replace({
pathname: to,
state: state,
key: "".concat(Date.now())
});
} else {
reduxHistory.push({ pathname: to, state: state, key: '' + Date.now() });
reduxHistory.push({
pathname: to,
state: state,
key: "".concat(Date.now())
});
}
transitioning = true;

@@ -47,3 +72,2 @@ return new Promise(function (res) {

};
Object.defineProperty(rrHistory, 'location', {

@@ -54,3 +78,2 @@ get: function get() {

});
Object.defineProperty(rrHistory, 'transitioning', {

@@ -61,14 +84,16 @@ get: function get() {

});
return rrHistory;
};
/************************************************* REDUX ACTIONS *****************************************************/
var CALL_HISTORY_METHOD = exports.CALL_HISTORY_METHOD = '@@router/CALL_HISTORY_METHOD';
var LOCATION_CHANGE = exports.LOCATION_CHANGE = '@@router/LOCATION_CHANGE';
exports.reachify = reachify;
var CALL_HISTORY_METHOD = '@@router/CALL_HISTORY_METHOD';
exports.CALL_HISTORY_METHOD = CALL_HISTORY_METHOD;
var LOCATION_CHANGE = '@@router/LOCATION_CHANGE';
exports.LOCATION_CHANGE = LOCATION_CHANGE;
var updateLocation = function updateLocation(method) {
return function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];

@@ -79,3 +104,6 @@ }

type: CALL_HISTORY_METHOD,
payload: { method: method, args: args }
payload: {
method: method,
args: args
}
};

@@ -86,29 +114,37 @@ };

var _push = updateLocation('push');
exports.push = _push;
var _replace = updateLocation('replace');
exports.replace = _replace;
var _go = updateLocation('go');
exports.go = _go;
var _goBack = updateLocation('goBack');
exports.goBack = _goBack;
var _goForward = updateLocation('goForward');
/************************************************* CONTEXT **********************************************************/
exports.goForward = _goForward;
var createReduxHistoryContext = function createReduxHistoryContext(_ref2) {
var history = _ref2.history,
_ref2$routerReducerKe = _ref2.routerReducerKey,
routerReducerKey = _ref2$routerReducerKe === undefined ? 'router' : _ref2$routerReducerKe,
routerReducerKey = _ref2$routerReducerKe === void 0 ? 'router' : _ref2$routerReducerKe,
_ref2$oldLocationChan = _ref2.oldLocationChangePayload,
oldLocationChangePayload = _ref2$oldLocationChan === undefined ? false : _ref2$oldLocationChan,
oldLocationChangePayload = _ref2$oldLocationChan === void 0 ? false : _ref2$oldLocationChan,
_ref2$reduxTravelling = _ref2.reduxTravelling,
reduxTravelling = _ref2$reduxTravelling === undefined ? false : _ref2$reduxTravelling,
reduxTravelling = _ref2$reduxTravelling === void 0 ? false : _ref2$reduxTravelling,
_ref2$showHistoryActi = _ref2.showHistoryAction,
showHistoryAction = _ref2$showHistoryActi === undefined ? false : _ref2$showHistoryActi,
showHistoryAction = _ref2$showHistoryActi === void 0 ? false : _ref2$showHistoryActi,
_ref2$selectRouterSta = _ref2.selectRouterState,
selectRouterState = _ref2$selectRouterSta === undefined ? null : _ref2$selectRouterSta;
selectRouterState = _ref2$selectRouterSta === void 0 ? null : _ref2$selectRouterSta;
/********************************************** REDUX REDUCER ******************************************************/
if (typeof selectRouterState !== 'function') {

@@ -123,3 +159,8 @@ selectRouterState = function selectRouterState(state) {

type: LOCATION_CHANGE,
payload: oldLocationChangePayload ? Object.assign({}, location, { action: action }) : { location: location, action: action }
payload: oldLocationChangePayload ? _objectSpread({}, location, {
action: action
}) : {
location: location,
action: action
}
};

@@ -144,5 +185,8 @@ };

_action = _ref4.action,
_location = _objectWithoutProperties(_ref4, ['action']);
_location = _objectWithoutProperties(_ref4, ["action"]);
return Object.assign({}, state, { location: _location, action: _action });
return _objectSpread({}, state, {
location: _location,
action: _action
});
}

@@ -154,10 +198,14 @@

return Object.assign({}, state, { location: location, action: action });
return _objectSpread({}, state, {
location: location,
action: action
});
}
return state;
};
/*********************************************** REDUX MIDDLEWARE **************************************************/
// eslint-disable-next-line
// eslint-disable-next-line
var routerMiddleware = function routerMiddleware() {

@@ -169,6 +217,6 @@ return function (next) {

}
var _action$payload = action.payload,
method = _action$payload.method,
args = _action$payload.args;
history[method].apply(history, _toConsumableArray(args));

@@ -179,5 +227,5 @@ if (showHistoryAction) return next(action);

};
/******************************************** REDUX TRAVELLING ***************************************************/
var isReduxTravelling = false;

@@ -193,11 +241,16 @@

var hLoc = history.location;
if (sLoc && hLoc && !locationEqual(sLoc, hLoc)) {
isReduxTravelling = true;
history.push({ pathname: sLoc.pathname, search: sLoc.search, hash: sLoc.hash });
history.push({
pathname: sLoc.pathname,
search: sLoc.search,
hash: sLoc.hash
});
}
});
};
/******************************************** REDUX FIRST HISTORY ************************************************/
var createReduxHistory = function createReduxHistory(store) {

@@ -208,13 +261,12 @@ if (reduxTravelling) {

var registeredCallback = [];
var registeredCallback = []; //init location store
//init location store
store.dispatch(locationChangeAction(history.location, history.action));
store.dispatch(locationChangeAction(history.location, history.action)); //listen to history API
//listen to history API
history.listen(function (location, action) {
if (isReduxTravelling) {
isReduxTravelling = false;
//notify registered callback travelling
isReduxTravelling = false; //notify registered callback travelling
var _routerState = selectRouterState(store.getState());
registeredCallback.forEach(function (c) {

@@ -225,2 +277,3 @@ return c(_routerState.location, _routerState.action);

}
store.dispatch(locationChangeAction(location, action));

@@ -232,21 +285,19 @@ var routerState = selectRouterState(store.getState());

});
var reduxFirstHistory = {
createHref: history.createHref,
push: function push() {
return store.dispatch(_push.apply(undefined, arguments));
return store.dispatch(_push.apply(void 0, arguments));
},
replace: function replace() {
return store.dispatch(_replace.apply(undefined, arguments));
return store.dispatch(_replace.apply(void 0, arguments));
},
go: function go() {
return store.dispatch(_go.apply(undefined, arguments));
return store.dispatch(_go.apply(void 0, arguments));
},
goBack: function goBack() {
return store.dispatch(_goBack.apply(undefined, arguments));
return store.dispatch(_goBack.apply(void 0, arguments));
},
goForward: function goForward() {
return store.dispatch(_goForward.apply(undefined, arguments));
return store.dispatch(_goForward.apply(void 0, arguments));
},
//listen tunnel

@@ -257,2 +308,3 @@ listen: function listen(callback) {

}
return function () {

@@ -264,5 +316,4 @@ registeredCallback = registeredCallback.filter(function (c) {

}
};
}; //location tunnel
//location tunnel
Object.defineProperty(reduxFirstHistory, 'location', {

@@ -272,5 +323,4 @@ get: function get() {

}
});
}); //action tunnel
//action tunnel
Object.defineProperty(reduxFirstHistory, 'action', {

@@ -280,5 +330,4 @@ get: function get() {

}
});
}); //length tunnel
//length tunnel
Object.defineProperty(reduxFirstHistory, 'length', {

@@ -289,8 +338,12 @@ get: function get() {

});
return reduxFirstHistory;
};
return { routerReducer: routerReducer, routerMiddleware: routerMiddleware, createReduxHistory: createReduxHistory };
return {
routerReducer: routerReducer,
routerMiddleware: routerMiddleware,
createReduxHistory: createReduxHistory
};
};
exports.createReduxHistoryContext = createReduxHistoryContext;
{
"name": "redux-first-history",
"version": "4.0.3",
"version": "4.0.4",
"description": "Redux First History - Make Redux 100% SINGLE-AND-ONLY source of truth again! - Tested on react-router v4 and reach-router.",
"main": "lib/redux-first-history.js",
"scripts": {
"compile": "cross-env NODE_ENV=production babel src --out-dir lib",
"prepublish": "npm run compile"
"build": "cross-env NODE_ENV=production babel src --out-dir lib",
"prepare": "npm run build",
"prepublishOnly": "npm run build"
},

@@ -39,20 +40,18 @@ "repository": {

"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "6.24.1",
"babel-eslint": "^8.0.3",
"babel-jest": "20.0.3",
"babel-loader": "7.0.0",
"babel-plugin-import": "^1.2.1",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react-app": "^3.0.0",
"babel-runtime": "6.23.0",
"cross-env": "^5.1.4",
"eslint": "^4.12.1",
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/polyfill": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"@babel/runtime-corejs2": "^7.4.5",
"cross-env": "^5.2.0",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-defaults": "^9.0.0",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-react": "^7.13.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.13.0"
"history": "^4.9.0",
"redux": "^4.0.1"
}
}
# redux-first-history
<p align="center">
<a href="https://www.npmjs.com/package/redux-first-history"><img src="https://img.shields.io/npm/v/redux-first-history.svg?style=flat-square"></a>
<a href="https://www.npmjs.com/packageredux-first-history"><img src="https://img.shields.io/npm/dm/redux-first-history.svg?style=flat-square"></a>
<a href="https://www.npmjs.com/package/redux-first-history"><img src="https://img.shields.io/npm/dm/redux-first-history.svg?style=flat-square"></a>
</p>

@@ -6,0 +6,0 @@ Redux First History - Make Redux 100% SINGLE-AND-ONLY source of truth again!

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc