import * as get from 'get-value' ; const defaultGetter = ( prop ) => ( state ) => get ( state , prop ) ; const simpleMappers = ( props , getter ) => function ( ) { const slices = [ ] . concat . apply ( [ ] , props ) ; const state = this [ this . REDUX_VUEX_STORE ] . getState ( ) ; this . REDUX_VUEX_BINDINGS = slices . reduce ( ( result , prop ) => Object . assign ( { } , result , { [ prop ] : getter ( prop ) } ) , this . REDUX_VUEX_BINDINGS || { } ) ; return slices . reduce ( ( result , prop ) => Object . assign ( { } , result , { [ prop ] : getter ( prop ) ( state ) } ) , { } ) ; } ; const objectMappers = ( obj , fallbackGetter ) => function ( ) { const slices = Object . keys ( obj ) ; const state = this [ this . REDUX_VUEX_STORE ] . getState ( ) ; this . REDUX_VUEX_BINDINGS = slices . reduce ( ( result , prop ) => Object . assign ( { } , result , { [ prop ] : typeof obj [ prop ] === 'function' ? obj [ prop ] . bind ( this ) : fallbackGetter ( obj [ prop ] ) } ) , this . REDUX_VUEX_BINDINGS || { } ) ; return slices . reduce ( ( result , prop ) => Object . assign ( { } , result , { [ prop ] : typeof obj [ prop ] === 'function' ? obj [ prop ] . call ( this , state ) : fallbackGetter ( obj [ prop ] ) ( state ) } ) , { } ) ; } ; param { * } props export default ( ... props ) => { const [ obj ] = props ; /**
     * mapState({ foo: 'bar', foo: state => state('bar') })
     */ if ( ! Array . isArray ( obj ) && typeof obj === 'object' ) { return objectMappers ( obj , defaultGetter ) ; } /**
     * mapState(['foo', 'bar', 'baz']) \\ mapState('foo', 'bar', 'baz')
     */ return simpleMappers ( props , defaultGetter ) ; } ;