Skip to content

Don't include standard utilities in redux #1225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,11 @@
"*.js"
]
}
]
],
"dependencies": {
"@f/compose": "^0.1.2",
"@f/is-object": "^1.1.2",
"@f/map-obj": "^1.2.2",
"@f/pick": "^1.1.2"
}
}
2 changes: 1 addition & 1 deletion src/createStore.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isPlainObject from './utils/isPlainObject'
import isPlainObject from '@f/is-object'

/**
* These are private action types reserved by Redux.
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import createStore from './createStore'
import combineReducers from './utils/combineReducers'
import bindActionCreators from './utils/bindActionCreators'
import applyMiddleware from './utils/applyMiddleware'
import compose from './utils/compose'
import compose from '@f/compose'

export {
createStore,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/applyMiddleware.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import compose from './compose'
import compose from '@f/compose'

/**
* Creates a store enhancer that applies middleware to the dispatch method
Expand Down
6 changes: 3 additions & 3 deletions src/utils/bindActionCreators.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mapValues from './mapValues'
import mapValues from '@f/map-obj'

function bindActionCreator(actionCreator, dispatch) {
return (...args) => dispatch(actionCreator(...args))
Expand Down Expand Up @@ -37,7 +37,7 @@ export default function bindActionCreators(actionCreators, dispatch) {
)
}

return mapValues(actionCreators, actionCreator =>
return mapValues(actionCreator =>
bindActionCreator(actionCreator, dispatch)
)
, actionCreators)
}
12 changes: 6 additions & 6 deletions src/utils/combineReducers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ActionTypes } from '../createStore'
import isPlainObject from './isPlainObject'
import mapValues from './mapValues'
import pick from './pick'
import isPlainObject from '@f/is-object'
import mapValues from '@f/map-obj'
import pick from '@f/pick'

/* eslint-disable no-console */

Expand Down Expand Up @@ -95,7 +95,7 @@ function assertReducerSanity(reducers) {
*/

export default function combineReducers(reducers) {
var finalReducers = pick(reducers, (val) => typeof val === 'function')
var finalReducers = pick((val) => typeof val === 'function', reducers)
var sanityError

try {
Expand All @@ -117,7 +117,7 @@ export default function combineReducers(reducers) {
}

var hasChanged = false
var finalState = mapValues(finalReducers, (reducer, key) => {
var finalState = mapValues((reducer, key) => {
var previousStateForKey = state[key]
var nextStateForKey = reducer(previousStateForKey, action)
if (typeof nextStateForKey === 'undefined') {
Expand All @@ -126,7 +126,7 @@ export default function combineReducers(reducers) {
}
hasChanged = hasChanged || nextStateForKey !== previousStateForKey
return nextStateForKey
})
}, finalReducers)

return hasChanged ? finalState : state
}
Expand Down
19 changes: 0 additions & 19 deletions src/utils/compose.js

This file was deleted.

24 changes: 0 additions & 24 deletions src/utils/isPlainObject.js

This file was deleted.

13 changes: 0 additions & 13 deletions src/utils/mapValues.js

This file was deleted.

15 changes: 0 additions & 15 deletions src/utils/pick.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/utils/isPlainObject.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import expect from 'expect'
import isPlainObject from '../../src/utils/isPlainObject'
import isPlainObject from '@f/is-object'
import vm from 'vm'

describe('isPlainObject', () => {
Expand Down
5 changes: 3 additions & 2 deletions test/utils/mapValues.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import expect from 'expect'
import mapValues from '../../src/utils/mapValues'
import mapValues from '@f/map-obj'

describe('mapValues', () => {
it('returns object with mapped values', () => {
const test = {
a: 'c',
b: 'd'
}
expect(mapValues(test, (val, key) => val + key)).toEqual({

expect(mapValues((val, key) => val + key, test)).toEqual({
a: 'ca',
b: 'db'
})
Expand Down
4 changes: 2 additions & 2 deletions test/utils/pick.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import expect from 'expect'
import pick from '../../src/utils/pick'
import pick from '@f/pick'

describe('pick', () => {
it('returns object with picked values', () => {
Expand All @@ -8,7 +8,7 @@ describe('pick', () => {
age: 20
}
expect(
pick(test, x => typeof x === 'string')
pick(x => typeof x === 'string', test)
).toEqual({
name: 'lily'
})
Expand Down