redux-promise-thunk
Version:
Thunk generator to dispatch Flux-Standard-Action in each phase of promise
39 lines (28 loc) • 1.17 kB
JavaScript
exports.__esModule = true;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _Actions = require('./Actions');
var _parsePath = require('./parsePath');
var _parsePath2 = _interopRequireDefault(_parsePath);
function createLocation() {
var location = arguments.length <= 0 || arguments[0] === undefined ? '/' : arguments[0];
var state = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
var action = arguments.length <= 2 || arguments[2] === undefined ? _Actions.POP : arguments[2];
var key = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3];
if (typeof location === 'string') location = _parsePath2['default'](location);
var pathname = location.pathname || '/';
var search = location.search || '';
var hash = location.hash || '';
// TODO: Deprecate passing state directly into createLocation.
state = location.state || state;
return {
pathname: pathname,
search: search,
hash: hash,
state: state,
action: action,
key: key
};
}
exports['default'] = createLocation;
module.exports = exports['default'];
;