electron-react-boilerplate
Version:
Electron application boilerplate based on React, React Router, Webpack, React Hot Loader for rapid application development
51 lines (35 loc) • 1.75 kB
JavaScript
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _warning = require('warning');
var _warning2 = _interopRequireDefault(_warning);
var _Actions = require('./Actions');
var _PathUtils = require('./PathUtils');
function createLocation() {
var location = arguments.length <= 0 || arguments[0] === undefined ? '/' : arguments[0];
var action = arguments.length <= 1 || arguments[1] === undefined ? _Actions.POP : arguments[1];
var key = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2];
var _fourthArg = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3];
if (typeof location === 'string') location = _PathUtils.parsePath(location);
if (typeof action === 'object') {
process.env.NODE_ENV !== 'production' ? _warning2['default'](false, 'The state (2nd) argument to createLocation is deprecated; use a ' + 'location descriptor instead') : undefined;
location = _extends({}, location, { state: action });
action = key || _Actions.POP;
key = _fourthArg;
}
var pathname = location.pathname || '/';
var search = location.search || '';
var hash = location.hash || '';
var state = location.state || null;
return {
pathname: pathname,
search: search,
hash: hash,
state: state,
action: action,
key: key
};
}
exports['default'] = createLocation;
module.exports = exports['default'];
;