File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import _ from 'lodash'
22
3- export const flattenNames = ( things ) => {
3+ export const flattenNames = ( things = [ ] ) => {
44 const names = [ ]
55
6- things . map ( ( thing ) => {
7- Array . isArray ( thing ) && flattenNames ( thing ) . map ( name => names . push ( name ) )
8- _ . isPlainObject ( thing ) && _ . forOwn ( thing , ( value , key ) => {
9- value === true && names . push ( key )
10- names . push ( `${ key } -${ value } ` )
11- } )
12- _ . isString ( thing ) && names . push ( thing )
13- return thing
6+ _ . map ( things , ( thing ) => {
7+ if ( Array . isArray ( thing ) ) {
8+ flattenNames ( thing ) . map ( name => names . push ( name ) )
9+ } else if ( _ . isPlainObject ( thing ) ) {
10+ _ . forOwn ( thing , ( value , key ) => {
11+ value === true && names . push ( key )
12+ names . push ( `${ key } -${ value } ` )
13+ } )
14+ } else if ( _ . isString ( thing ) ) {
15+ names . push ( thing )
16+ }
1417 } )
1518
1619 return names
You can’t perform that action at this time.
0 commit comments