1- import isFunction from 'lodash/isFunction' ;
2- import isPlainObject from 'lodash/isPlainObject' ;
3- import identity from 'lodash/identity' ;
4- import isNil from 'lodash/isNil' ;
5- import isUndefined from 'lodash/isUndefined' ;
6- import includes from 'lodash/includes' ;
71import invariant from 'invariant' ;
2+ import isFunction from 'is-function' ;
3+ import isPlainObject from 'is-plain-object' ;
4+ import identity from './utils/identity' ;
5+ import isNil from './utils/isNil' ;
6+ import isUndefined from './utils/isUndefined' ;
7+ import toString from './utils/toString' ;
88import { ACTION_TYPE_DELIMITER } from './constants' ;
99
1010export default function handleAction ( type , reducer = identity , defaultState ) {
11- const types = type . toString ( ) . split ( ACTION_TYPE_DELIMITER ) ;
11+ const types = toString ( type ) . split ( ACTION_TYPE_DELIMITER ) ;
1212 invariant (
1313 ! isUndefined ( defaultState ) ,
1414 `defaultState for reducer handling ${ types . join ( ', ' ) } should be defined`
@@ -26,7 +26,7 @@ export default function handleAction(type, reducer = identity, defaultState) {
2626
2727 return ( state = defaultState , action ) => {
2828 const { type : actionType } = action ;
29- if ( ! actionType || ! includes ( types , actionType . toString ( ) ) ) {
29+ if ( ! actionType || ! types . includes ( toString ( actionType ) ) ) {
3030 return state ;
3131 }
3232
0 commit comments