File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,21 +31,16 @@ function normalizeTopic(
3131 return [ { value : '' } ] ;
3232 }
3333
34+ const getTopicValue = ( t : { value ?: string ; type ?: string ; _ ?: string } ) : string =>
35+ typeof t . _ === 'string' ? t . _ :
36+ typeof t . value === 'string' ? t . value :
37+ typeof t . type === 'string' ? t . type :
38+ '' ;
39+
3440 if ( Array . isArray ( topic ) ) {
35- const normalized = topic . map ( ( t ) : Topic => ( {
36- value : typeof t . _ === 'string' ? t . _ :
37- typeof t . value === 'string' ? t . value :
38- typeof t . type === 'string' ? t . type :
39- ''
40- } ) ) ;
41-
41+ const normalized = topic . map ( ( t ) : Topic => ( { value : getTopicValue ( t ) } ) ) ;
4242 return normalized . length > 0 ? [ normalized [ 0 ] ] : [ { value : '' } ] ;
4343 }
4444
45- return [ {
46- value : typeof topic . _ === 'string' ? topic . _ :
47- typeof topic . value === 'string' ? topic . value :
48- typeof topic . type === 'string' ? topic . type :
49- ''
50- } ] ;
45+ return [ { value : getTopicValue ( topic ) } ] ;
5146}
You can’t perform that action at this time.
0 commit comments