@@ -43,20 +43,18 @@ export const fromMatrix = <T extends Record<string, any> = ConfigAll>(configMatr
4343 const samples = configEntries . reduce (
4444 ( previousValue , currentValue ) => {
4545 const [ config , configValues ] = currentValue ;
46- return previousValue
47- . map ( ( [ previousName , previousConfig ] ) =>
48- configValues . map ( ( value : ValueType ) => {
49- return [
50- // @ts -expect-error fix type
51- appendTitle ( previousName as string , config , value ) ,
52- {
53- ...( previousConfig as Record < string , ValueType > ) ,
54- [ config ] : value ,
55- } ,
56- ] ;
57- } ) ,
58- )
59- . flat ( ) ;
46+ return previousValue . flatMap ( ( [ previousName , previousConfig ] ) =>
47+ configValues . map ( ( value : ValueType ) => {
48+ return [
49+ // @ts -expect-error fix type
50+ appendTitle ( previousName as string , config , value ) ,
51+ {
52+ ...( previousConfig as Record < string , ValueType > ) ,
53+ [ config ] : value ,
54+ } ,
55+ ] ;
56+ } ) ,
57+ ) ;
6058 } ,
6159 [ [ '' , { } ] ] ,
6260 ) ;
@@ -73,9 +71,7 @@ const applyExtendedMatrix = <M extends Record<string, any> = ConfigAll, A extend
7371 const currentConfigObjects = configValues . map ( configValue => ( {
7472 [ configName ] : configValue ,
7573 } ) ) ;
76- return currentArray
77- . map ( existingConfig => currentConfigObjects . map ( currentObject => ( { ...existingConfig , ...currentObject } ) ) )
78- . flat ( ) ;
74+ return currentArray . flatMap ( existingConfig => currentConfigObjects . map ( currentObject => ( { ...existingConfig , ...currentObject } ) ) ) ;
7975 } ,
8076 [ { } as Record < keyof A , AdditionalValue < A , keyof A > > ] ,
8177 ) ;
0 commit comments