import { Page , Layer } from 'sketch' ; import { getParents } from './get-colors' ; export const traverse = ( layer , layers = [ ] , parents = [ ] ) : any => { if ( ( 'layers' in layer ) && layer . layers ! . length ) { layer . layers ! . forEach ( ( subLayer ) => ( traverse ( subLayer , layers , getParents ( parents , { id : layer . id , type : layer . type , name : layer . name } ) ) ) ) ; } const layerWithParents = { layer , parents , } ; layers . push ( layerWithParents ) ; return layers ; } ;