Created
October 12, 2018 19:35
-
-
Save kmaher9/7dc13c3a64116541c6bf191c49800110 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
open: function(filePath) { | |
return new Promise( | |
function(resolve, reject) { | |
const zip = new StreamZip({ | |
file: filePath, | |
storeEntries: true | |
}) | |
zip.on('ready', () => { | |
var chunks = [] | |
var content = '' | |
zip.stream('word/document.xml', (err, stream) => { | |
if (err) { | |
reject(err) | |
} | |
stream.on('data', function(chunk) { | |
chunks.push(chunk) | |
}) | |
stream.on('end', function() { | |
content = Buffer.concat(chunks) | |
zip.close() | |
resolve(content.toString()) | |
}) | |
}) | |
}) | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment