let klaw=require('klaw')
let folder='/Users/serkan/Desktop/yedek/nodeplayerv2/files'


async function test() {

   let q=await getFiles(folder)

    console.log(q.length)
}



async function getFiles(pathOfFolder){

    let path=require('path')
    let q = await (new Promise((resolve, reject) => {
        let files = []
        let q = klaw(pathOfFolder).on('data', (item) => {
            files.push({path: item.path, size: item.stats.size,
                isFile:item.stats.isDirectory()?false:true,
                filename:item.path.split(path.sep).pop(),
                directory:item.path.replace(item.path.split(path.sep).pop(),'')
            })
        }).on('end',()=>{
            resolve(files);
        })

    }))
  return q;
}

test();