import getFile from './getFile' ; const readDir = async ( dir , path ) => new Promise ( resolve => { const dirReader = dir . createReader ( ) ; let items = [ ] ; dirReader . readEntries ( async ( entries ) => { for ( let i = 0 ; i < entries . length ; i ++ ) { const item = entries [ i ] ; if ( item . isFile ) { const file = await getFile ( item , path ) ; items . push ( file ) ; } else { const subImages = await traverseFileTree ( item , path + item . name + "/" ) ; items = items . concat ( subImages ) ; } } return resolve ( items ) ; } ) ; } ) ; const traverseFileTree = async ( item , path = "" ) => { return await readDir ( item , path ) ; } ; export default traverseFileTree ;