I am using JSZip to unzip a directory, which runs async. I want to write a function that unzips a file and returns the files associated with it, like this:
function unzipFile(filename){
const zipper = new jsZip()
return fs.readFile(filename, function(err, data) {
return jsZip.loadAsync(data).then(function(zip) {
return zip.files
})
})
}
but this is just return undefined
. How can I make this async so that it returns the unzipped directory in a single function, and if I wanted to set a variable equal to its output would await its completion?