@@ -3,8 +3,9 @@ import arrayToObject from './lib/array-to-object';
33function normalizeNamespace ( fn ) {
44 return ( ...params ) => {
55 // eslint-disable-next-line prefer-const
6- let [ namespace , map , getterType , mutationType ] =
7- typeof params [ 0 ] === `string` ? [ ...params ] : [ `` , ...params ] ;
6+ let [ namespace , map , getterType , mutationType ] = typeof params [ 0 ] === `string`
7+ ? [ ...params ]
8+ : [ `` , ...params ] ;
89
910 if ( namespace . length && namespace . charAt ( namespace . length - 1 ) !== `/` ) {
1011 namespace += `/` ;
@@ -70,8 +71,8 @@ export const mapMultiRowFields = normalizeNamespace((
7071 const store = this . $store ;
7172 const rows = store . getters [ getterType ] ( path ) ;
7273
73- return rows . map ( ( fieldsObject , index ) =>
74- Object . keys ( fieldsObject ) . reduce ( ( prev , fieldKey ) => {
74+ return rows
75+ . map ( ( fieldsObject , index ) => Object . keys ( fieldsObject ) . reduce ( ( prev , fieldKey ) => {
7576 const fieldPath = `${ path } [${ index } ].${ fieldKey } ` ;
7677
7778 return Object . defineProperty ( prev , fieldKey , {
@@ -93,8 +94,16 @@ export const mapMultiRowFields = normalizeNamespace((
9394export const createHelpers = ( { getterType, mutationType } ) => ( {
9495 [ getterType ] : getField ,
9596 [ mutationType ] : updateField ,
96- mapFields : normalizeNamespace ( ( namespace , fields ) =>
97- mapFields ( namespace , fields , getterType , mutationType ) ) ,
98- mapMultiRowFields : normalizeNamespace ( ( namespace , paths ) =>
99- mapMultiRowFields ( namespace , paths , getterType , mutationType ) ) ,
97+ mapFields : normalizeNamespace ( ( namespace , fields ) => mapFields (
98+ namespace ,
99+ fields ,
100+ getterType ,
101+ mutationType ,
102+ ) ) ,
103+ mapMultiRowFields : normalizeNamespace ( ( namespace , paths ) => mapMultiRowFields (
104+ namespace ,
105+ paths ,
106+ getterType ,
107+ mutationType ,
108+ ) ) ,
100109} ) ;
0 commit comments