File tree Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -31,21 +31,16 @@ function normalizeTopic(
31
31
return [ { value : '' } ] ;
32
32
}
33
33
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
+
34
40
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 ) } ) ) ;
42
42
return normalized . length > 0 ? [ normalized [ 0 ] ] : [ { value : '' } ] ;
43
43
}
44
44
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 ) } ] ;
51
46
}
You can’t perform that action at this time.
0 commit comments