Created
July 9, 2018 20:53
-
-
Save harrietty/a60fdb36f3a1e34b48ec273633f8f45f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const zlib = require('zlib'); | |
const directoryFiles = fs.readdirSync('./data'); | |
Promise.all(directoryFiles.map(filename => { | |
return new Promise((resolve, reject) => { | |
const fileContents = fs.createReadStream(`./data/${filename}`); | |
const writeStream = fs.createWriteStream(`./data/${filename.slice(0, -3)}`); | |
const unzip = zlib.createGunzip(); | |
fileContents.pipe(unzip).pipe(writeStream).on('finish', (err) => { | |
if (err) return reject(err); | |
else resolve(); | |
}) | |
}) | |
})) | |
.then(console.log('done')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment