import * as React from 'react' ; import traverseFileTree from './traverseFileTree' ; const transformFiles = async ( e ) => { const d = e . dataTransfer || { } ; const items = d . items || [ ] ; let images = [ ] ; for ( let i = 0 ; i < items . length ; i ++ ) { const item = items [ i ] . webkitGetAsEntry ( ) ; if ( item ) { const folder = await traverseFileTree ( item ) ; images = images . concat ( folder ) ; } } const folders = images . reduce ( ( allImages , image ) => { if ( image . path ) { return { ... allImages , [ image . path ] : ( allImages [ image . path ] || [ ] ) . concat ( image ) , } ; } return allImages ; } , { } ) ; return folders ; } ; export default transformFiles ;