Skip to content
This repository was archived by the owner on Oct 26, 2018. It is now read-only.

Change to ES6 imports and exports #110

Merged
merged 1 commit into from
Dec 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const deepEqual = require('deep-equal')
import deepEqual from 'deep-equal'

// Constants

const INIT_PATH = '@@router/INIT_PATH'
const UPDATE_PATH = '@@router/UPDATE_PATH'
export const UPDATE_PATH = '@@router/UPDATE_PATH'
const SELECT_STATE = state => state.routing

// Action creators
Expand All @@ -20,7 +20,7 @@ function initPath(path, state) {
}
}

function pushPath(path, state, { avoidRouterUpdate = false } = {}) {
export function pushPath(path, state, { avoidRouterUpdate = false } = {}) {
return {
type: UPDATE_PATH,
payload: {
Expand All @@ -32,7 +32,7 @@ function pushPath(path, state, { avoidRouterUpdate = false } = {}) {
}
}

function replacePath(path, state, { avoidRouterUpdate = false } = {}) {
export function replacePath(path, state, { avoidRouterUpdate = false } = {}) {
return {
type: UPDATE_PATH,
payload: {
Expand Down Expand Up @@ -81,7 +81,7 @@ function createPath(location) {
return result
}

function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
export function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
const getRouterState = () => selectRouterState(store.getState())

// To properly handle store updates we need to track the last route.
Expand Down Expand Up @@ -158,10 +158,4 @@ function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
}
}

module.exports = {
UPDATE_PATH,
pushPath,
replacePath,
syncReduxAndRouter,
routeReducer: update
}
export { update as routeReducer }
4 changes: 2 additions & 2 deletions test/browser/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { createHashHistory, createHistory } = require('history')
const createTests = require('../createTests.js')
import { createHashHistory, createHistory } from 'history'
import createTests from '../createTests.js'

createTests(createHashHistory, 'Hash History', () => window.location = '#/')
createTests(createHistory, 'Browser History', () => window.history.replaceState(null, null, '/'))
12 changes: 6 additions & 6 deletions test/createTests.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*eslint-env mocha */

const expect = require('expect')
const { pushPath, replacePath, UPDATE_PATH, routeReducer, syncReduxAndRouter } = require('../src/index')
const { createStore, combineReducers, compose } = require('redux')
const { devTools } = require('redux-devtools')
const { ActionCreators } = require('redux-devtools/lib/devTools')
const { useBasename } = require('history')
import expect from 'expect'
import { pushPath, replacePath, UPDATE_PATH, routeReducer, syncReduxAndRouter } from '../src/index'
import { createStore, combineReducers, compose } from 'redux'
import { devTools } from 'redux-devtools'
import { ActionCreators } from 'redux-devtools/lib/devTools'
import { useBasename } from 'history'

expect.extend({
toContainRoute({
Expand Down
4 changes: 2 additions & 2 deletions test/node/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { createMemoryHistory } = require('history')
const createTests = require('../createTests.js')
import { createMemoryHistory } from 'history'
import createTests from '../createTests.js'

createTests(createMemoryHistory, 'Memory History')