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

Commit c0cc79c

Browse files
committed
Merge pull request #110 from kjbekkelund/es6-import-export
Change to ES6 imports and exports
2 parents 823ce18 + ce918aa commit c0cc79c

File tree

4 files changed

+16
-22
lines changed

4 files changed

+16
-22
lines changed

src/index.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const deepEqual = require('deep-equal')
1+
import deepEqual from 'deep-equal'
22

33
// Constants
44

55
const INIT_PATH = '@@router/INIT_PATH'
6-
const UPDATE_PATH = '@@router/UPDATE_PATH'
6+
export const UPDATE_PATH = '@@router/UPDATE_PATH'
77
const SELECT_STATE = state => state.routing
88

99
// Action creators
@@ -20,7 +20,7 @@ function initPath(path, state) {
2020
}
2121
}
2222

23-
function pushPath(path, state, { avoidRouterUpdate = false } = {}) {
23+
export function pushPath(path, state, { avoidRouterUpdate = false } = {}) {
2424
return {
2525
type: UPDATE_PATH,
2626
payload: {
@@ -32,7 +32,7 @@ function pushPath(path, state, { avoidRouterUpdate = false } = {}) {
3232
}
3333
}
3434

35-
function replacePath(path, state, { avoidRouterUpdate = false } = {}) {
35+
export function replacePath(path, state, { avoidRouterUpdate = false } = {}) {
3636
return {
3737
type: UPDATE_PATH,
3838
payload: {
@@ -81,7 +81,7 @@ function createPath(location) {
8181
return result
8282
}
8383

84-
function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
84+
export function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
8585
const getRouterState = () => selectRouterState(store.getState())
8686

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

161-
module.exports = {
162-
UPDATE_PATH,
163-
pushPath,
164-
replacePath,
165-
syncReduxAndRouter,
166-
routeReducer: update
167-
}
161+
export { update as routeReducer }

test/browser/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { createHashHistory, createHistory } = require('history')
2-
const createTests = require('../createTests.js')
1+
import { createHashHistory, createHistory } from 'history'
2+
import createTests from '../createTests.js'
33

44
createTests(createHashHistory, 'Hash History', () => window.location = '#/')
55
createTests(createHistory, 'Browser History', () => window.history.replaceState(null, null, '/'))

test/createTests.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*eslint-env mocha */
22

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

1010
expect.extend({
1111
toContainRoute({

test/node/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { createMemoryHistory } = require('history')
2-
const createTests = require('../createTests.js')
1+
import { createMemoryHistory } from 'history'
2+
import createTests from '../createTests.js'
33

44
createTests(createMemoryHistory, 'Memory History')

0 commit comments

Comments
 (0)