param value param target param propertyPath export function assignProperty ( value , target , propertyPath ) { const propertyPaths = Array . isArray ( propertyPath ) ? propertyPath : [ propertyPath ] ; propertyPaths . forEach ( ( propPath ) => { const propsList = propPath . split ( '.' ) ; propsList . forEach ( ( prop , index ) => { const arrayRegex = /(?<arrayName>.*)\[(?<arrayIndexString>\d+)\]$/ ; const match = prop . match ( arrayRegex ) ; if ( match && ( match as any ) . groups ) { const { arrayName , arrayIndexString } = ( match as any ) . groups ; const arrayIndex = parseInt ( arrayIndexString ) ; const arrayProp = target [ arrayName ] ; if ( arrayProp === undefined || ! Array . isArray ( arrayProp ) || arrayIndex >= arrayProp . length ) { console . error ( `Array not found or missing index (skipping) for property assignment: '${ arrayName }[${ arrayIndex }]'` , target ) ; } else { if ( index === propsList . length - 1 ) { arrayProp [ arrayIndex ] = value ; } else { target = arrayProp [ arrayIndex ] ; } } } else { if ( target [ prop ] === undefined ) { console . warn ( `Created property ${ prop } on: (from ${ propsList })` , target ) ; target [ prop ] = { } ; } if ( index === propsList . length - 1 ) { target [ prop ] = value ; } else { target = target [ prop ] ; } } } ) ; } ) ; }