import { get } from '../util/get' ; import { files } from '../util/category' ; import { write } from '../util/write' ; import { width } from '../util/width' ; const keys = [ 'style1' , 'style2' , 'color1' , 'color2' , 'hhaConcept1' , 'hhaConcept2' , 'hhaSet' , 'hhaSeries' , 'labelThemes' , ] ; param object function sanitize ( object ) { if ( object . hasOwnProperty ( 'color1' ) ) { object . colors = [ object . color1 , object . color2 ] . filter ( ( color ) => ! ! color ) ; } if ( object . hasOwnProperty ( 'hhaConcept1' ) ) { object . concepts = [ object . hhaConcept1 , object . hhaConcept2 ] . filter ( ( concept ) => ! ! concept ) ; } if ( object . hasOwnProperty ( 'hhaSet' ) ) { object . set = object . hhaSet ; } if ( object . hasOwnProperty ( 'hhaSeries' ) ) { object . series = object . hhaSeries ; } if ( object . hasOwnProperty ( 'style1' ) ) { object . styles = [ object . style1 , object . style2 ] . filter ( ( style ) => ! ! style ) ; } if ( object . hasOwnProperty ( 'labelThemes' ) ) { object . themes = object . labelThemes ; } for ( const key of keys ) { if ( object . hasOwnProperty ( key ) ) delete object [ key ] ; } } for ( const file of files ( 'Items' ) ) { const items = get ( file ) ; for ( const item of items ) { if ( item . variations ) { for ( const variation of item . variations ) sanitize ( variation ) ; } sanitize ( item ) ; } write ( file , items , width ( 'Items' ) ) ; }